Getting Started with linux Manual 14 ansible use

  1. Start Nginx error: nginx: [emerg] open ( ) "/run/nginx.pid" failed (2: No such file or directory)
    to create a file in / run / lower folder named nginx (if / run / does not exist, then mkdir / run / nginx / -pv)
    and then start the service execution file (available rpm -ql nginx look): I was / usr / sbin / nginx, then execute / usr / sbin / nginx -s reload
    and then you can start Nginx
  2. Role-PlayBook --limit centos7 ansible-nginx.yml
    --limit host list only for the host execution host list
    -C only detect changes that may occur --check, but does not actually perform the operation
    --list-hosts lists run the task of host
  3. ansible --list-hosts host list display, may be abbreviated --list
    Specific Usage: All PlayBook ansible---list
    -m Module1 module specified, the default is Command, the configuration file can be modified in /etc/ansible/ansible.cfg # module_name = command # the default module
  4. ansible二进制安装Nginx、mariadb过程及注意要点
    Nginx:
    ```
    mkdir /data/ansible/roles/nginx/{tasks,files,templates,vars,handlers} -pv
    cd /data/ansible/roles/nginx/
    vim tasks/user.yml
    vim tasks/group.yml
    vim tasks/install.yml
    vim tasks/config.yml
    vim tasks/service.yml
    vim tasks/data.yml
    vim tasks/main.yml
    cd ..
    vim role-nginx.yml
    ansible-playbook -C role-nginx.yml
    ansible-playbook role-nginx.yml

    Centos7 If unsuccessful, the source of the problem may be yum, the following methods may be used:
    ansible centos7 -a 'mkdir /etc/yum.repos.d/repo'
    ansible centos7 -a 'Music Videos /etc/yum.repos.d/* /etc/yum.repos.d/repo .repo '
    ansible centos7 Copy -m -a' = the src / etc / yum.repos.d / Base.repo dest = / etc / yum.repos.d / Backup = Yes'
    -a -m Copy centos7 ansible 'the src = / etc / yum.repos.d / epel.repo dest = / etc / yum.repos.d / Backup = Yes'
    `` `

    mariadb
    `` `
    cd ansible / Roles /
    mkdir mysql / {files, Tasks, templates, VARs, handlers} -pv
    cd mysql / Tasks /
    vim user.yml
    vim unarchive.yml
    vim mysqllink.yml
    vim mysqldata.yml
    vim mysqldatabase.yml
    vim pathvar.yml
    vim config.yml
    vim servicefile.yml
    vim startservice.yml
    vim mysqldatadirowner.yml
    vim main.yml

    cd /usr/local/
    tar xvf mariadb-10.2.25-linux-x86_64.tar.gz
    cd mariadb-10.2.25-linux-x86_64/
    cd support-files/
    cp my-huge.cnf /data/playbook/etc/my.cnf
    vim my.cnf 添加datadir = /data/mysql (重点!!)

    cd /data/ansible/
    ansible-playbook -C role-mariadb.yml
    ansible-playbook role-mariadb.yml
    ```

Guess you like

Origin www.cnblogs.com/linux521/p/11220938.html