Auto operation and maintenance of the ANSIBLE

 Operation and maintenance since the automation of ANSIBLE

  ANSIBLE (four new machines)

  * Prepare four new machines, test IP is 192.168.198.6ansible, 192.168.198.72,192.168.198.73,192.168.198.135CentOS6 system

   * Ansible: Modify the host name hostnamectl set-hostname ansible

         Installation ansible: yum install ansible [Enable epel premise installation source]

         Confirm the installation: ansible --version

         Modify vim / etc / ansible / hosts file format, as shown in FIG.

          

         Display Panels Full list: ansible all --list-hosts

          Display web Full list: ansible websrvs --list-hosts

         Full list display app: ansible appsrvs --list-hosts

         Check the corresponding server host_key, recommendations uncommented, vim /etc/ansible/ansible.cfg:#host_key_checking = False

         ping all hosts: ansible all -m ping [192.168.198.135 unsuccessful]

         Based key authentication: ssh-keygen, then based on the one-way ansible key:. Ssh-copy-id 192.168.198 [135: 72: 73] password

         ping all hosts: ansible All -m ping [succeed]

         Ping the survival of a particular user detection: ansible all -m ping -u user -k, enter the password [specific user account password is also correct, in order to succeed]

         ping all hosts: ansible "*" -m ping -C / ansible "* srvs" -m ping -C

         ping co-host: ansible "websrvs: & appsrvs" -m ping -C

         ping-containing websrvs excluding appservs host: ansible 'websrvs:! appsrvs' -m ping -C

         Check the corresponding server log_path, cancel comment, vim /etc/ansible/ansible.cfg:#log_path=/var/log/ansible.log

         Ansible just execute a command, cat /var/log/ansible.log view the log, log their actions

--------------------------------------------------------------------------------------------------------------------------------------------------------

  ANSIBLE installation service httpd

   * IP experiment was 192.168.198.6ansible, 192.168.198. [72:73] appsrvs

    * Ansible operation (already installed httpd): Create a file storage directory mkdir / data / playbook

                 Copy the httpd configuration file to the file directory and modify the port to 8080: cp /etc/httpd/conf/httpd.conf / data / playbook /

                Enter the directory: cd / data / playbook

                Create a configuration file: vim httpd.yml

                

                Check File: ansible-playbook -C httpd.yml

                Startup file: ansible-playbook httpd.yml

                View Service installation: ansible-playbook --list-hosts httpd.yml

                Check into the system under appsrvs, install httpd service is successful, the port is 8080

--------------------------------------------------------------------------------------------------------------------------------------------------------

  ANSIBLE installation services mariadb

      * IP experiment was 192.168.198.6ansible, 192.168.198.135

   *     

--------------------------------------------------------------------------------------------------------------------------------------------------------

  ANSIBLE installation file

   * IP experiment was 192.168.198.6ansible, websrvs machine

   * Write ansible file: ①vim vars.yml

           

           {{Suf}} from the configuration file vim / etc / ansible / hosts [declared type of the file created]

           

           {{Ansible_fqdn}} to the host name, may be written as {{suf}} mode, a direct statement

           ② can be declared directly in it ahead of time, as shown below

           

           If this command is executed: ansible-playbook -e hostname = file -e suf = log vars3.yml [-e than vars, and finally generates a file for the file.log]

           Concluded: -e> yml File> etc / ansible / hosts

----------------------------------------------------------------------------------------------------------------------------------------------------------

   

 

 

 

 

          

          

          

 

Guess you like

Origin www.cnblogs.com/dengkui/p/11201992.html