ansible playbook实现二进制安装mariadb

[root@centos7 playbook]#cat install_mariadb.yml 
---
- hosts: 192.168.37.6
  remote_user: root

  tasks:
    - name: user
      user: name=mysql system=yes home=/data/mysql create_home=no shell=/sbin/nologin  
    - name: unarchive
      unarchive: src=/data/playbook/mariadb-10.2.25-linux-x86_64.tar.gz dest=/usr/local/  owner=root group=root
    - name: mysql link
      file: src=/usr/local/mariadb-10.2.25-linux-x86_64 dest=/usr/local/mysql state=link
    - name: mysql datadir
      file: path=/data/mysql state=directory
    - name: mysql datadir owner group
      file: path=/data/mysql owner=mysql group=mysql
    - name: mysql database
      shell: chdir=/usr/local/mysql/  scripts/mysql_install_db --datadir=/data/mysql --user=mysql
    - name: path  var
      copy: content='PATH=/usr/local/mysql/bin:$PATH' dest=/etc/profile.d/mysql.sh
    - name: config
      copy: src=/data/playbook/my-huge.cnf dest=/etc/my.cnf
    - name: service file
      shell: cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
    - name: start service
      shell:  /etc/init.d/mysqld start

你可能感兴趣的:(ansible,Linux,自动化)