What is automated operation and maintenance
With the continuous development of the information age, IT operations has become an important part of IT service connotation. In the face of more and more complex business, in the face of more and more diverse user needs, expanding IT applications need more and more reasonable mode to ensure that IT services can be flexible, secure and stable continuous protection, the security factor in this model is IT operations (other factors are more advantageous it architecture, etc.). From the beginning of several servers to a large data center, alone can not meet the requirements of technology, business, management, and so on, standardization, automation, architecture optimization, process optimization and other factors to reduce IT service costs are more and more people pay attention to. Among them, the beginning of automation as a substitute for manual operation as the starting point of the appeal is widely studied and applied. Since the birth and development of IT operations, automation as one of its important attributes has not only replaced the manual operation, more important is deep detection and global analysis, the focus is on how to achieve performance and service optimization under the current conditions, while guaranteeing maximum investment income. The impact of automation on IT operations has been more than just the relationship between people and devices, has evolved to customer service-driven IT operations decision-making level, IT operations and maintenance team composition, but also from the level of technical personnel to the majority of business and even users accounted for the majority of the situation. Therefore, IT operations automation is a set of static device structure into a dynamic response to the needs of IT service strategy, the purpose is to achieve the quality of IT operations, reduce costs. It can be said that automation must be one of the most important attributes of IT operations at the highest level, but not all.
What is Ansible
Ansible is a new automated operation tools, based on Python development, the collection of a number of operations tools (puppet, Cfengine, Chef, func, fabric) The advantages of the implementation of batch system configuration, batch program deployment, batch Run command and other functions. Multiple servers can be configured to execute a single command on multiple servers simultaneously.
framework of the ansible
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727141309802?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
> Host Inventory: Defines the list of hosts ansible operations > Connection Plugins: Responsible for monitoring communication between the operational host and the manipulated host > Playbook: defining ansible Tasks > Plugins: Expansion module, mainly used to complete the log, mail and other functions > core modules, custom modules: mainly for the execution of commands 12345671234567
Download and install Ansible
1. Download ansible [[email protected] ~]# wget http://releases.ansible.com/ansible/ansible-2.3.2.0-0.4.rc4.tar.gz 2. Install ansible [[email protected] ~]# TAR-XZF ansible-2.3.2.0-0.4.rc4.tar.gz [[email protected] ~]# CD ansible-2.3.2.0 [[email protected] ~]# python setup.py build [[email protected] ~]# python setup.py install 3. Equip config file [[email protected] ~]# mkdir/etc/ansible [[email protected] ~]# cp-r examples/*/etc/ansible/
Hosts configuration file
Format: [webservers]//host group name alpha.example.org beta.example.org 192.168.1.100 1 92.168.1.110
Ansible command
1. Format: ansible
Using the ansible command for remote shell execution
Host File
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727153223087?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
Target Machine
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727153340666?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
ansible Host
[Email protected] ~]# Ssh-keygen
[Email protected] ~]# Ssh-copy-id [email protected]
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727155211246?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
[Email protected] ~]# ansible install_httpd-m shell-a "yum-y install httpd"
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727155315791?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
Target Machine
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727155414516?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
Using YAML syntax to define multiple tasks
1. file Definition Format: task_set.yaml (file suffix. yaml) 2. text content format: - hosts:hosts _name //the host name defined in the Hosts file remote_user: root //users running this task tasks: ///should be a task - name:taks_name //Task Name moudule_name:args[1]=? args[2]=? ..... //parameter, which is the-a option in the command ignore _errors:true //Ignore Errors notify: //if not changed the following events will not occur - handerls_name handlers: // The implementation performs the specified action once the change has completed, such as changing the configuration file and starting the service from the new one. - name: handerls_name module:args * Note *: A single set of hosts can correspond to multiple tasks, and a. yaml file can contain multiple host sets 3. text Content Run command: [[email protected] ~]# ansible-playbook file.yam
Test
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727164413635?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20170727164605116?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
Automated operation and maintenance ansible tools under Linux