First, ansible Management command
There are several ansible management commands:(1) Ansible: This command is one of the very high usage in daily work, mainly used for temporary one-time operation;(2) Ansible-doc:ansible module document description, for each module has detailed usage instructions and application case in
Tags: Automated ansible
Ansible is an open-source automated O M tool that neither requires a database nor runs background programs (daemons)
Easy to use, relatively simple compared with other similar tools (such as puppet)
I. Control Machine requirements:
The requirements for the ansible control machine are extremely
I. Preparation of the first order
Ansible installation is complete, below learn how to use ansible.Just like learning a programming language, first write a Hello World sample program. We also write a ansible "Hello World":
Ansible 192.168.128.83-m Ping
This command means ping 192.168.128.83 through the admin hostThe "-M ping" in the command indicates that the pi
First, what kind of situation requires batch deployment1, the operating system installationThe Common collber,red hat satelite (Redhat) system is dedicated.2, the operating system configurationIt is common to have cfengine,puppet,chef,func. One of the most popular puppet3, the deployment of bulk programs4. Run the batch command to view status informationIi. introduction of AnsibleThe architecture of the ansible is roughly as follows650) this.width=650
Asible is a very good tool in the operation of tools, I personally prefer, can be flexibly configured according to the needs of yml files to achieve different business needs, because do not need to install the client, the start is very easy, In some cases you might want to write ansible as a library component of Python into your own script, and today's script script will show how
Create ansible and manage container nodes based on DockerScenario: When learning conditions are limited, you can complete Docker and ansible learning with a single VMFIX: Create a custom image and build multiple ansible containers first.Of course, this method is suitable for other similar scenarios.VMS Environment:
Os:centos7docker version 1.12.3, build
I. Basic Knowledge:
1. Introduction
Ansible is developed based on Python and combines the advantages of many O M tools to implement features such as batch system configuration, batch program deployment, and batch run commands. Ansible works based on modules and does not support batch deployment.The ansible module is actually deployed in batches, and
Managing remote servers in bulk using AnsibleBackground local need to manage the remote batch of servers, mainly perform the following tasks: 1) Copy Local files to all remote servers; 2) need to execute commands on remote server; Remote server path is not exactly the same. General access to the variable path defined in the environment variable; For example, define $app_path=/opt/app/bin final selection ansible in. BASHRC, and use this automated OPS
Objective:Sometimes we need to define a host group when automating and batching the operations master. For example, Saltstack group, and Salt-n parameters, in Ansible under the self-fix ansible of the host group. Some trouble, you know, since you choose to use Saltstack, ansible this kind of cluster operation tool, if
Ansible automatic operation and Maintenance tool configuration Ngnix front end to back-end real machine, and set keepalived high availability, on the back end a real host configuration httpd,mysql,php-fpm; set memcached cache server on this real host (Because of my Computer configuration problem, can not open so many virtual machines, so simply build a bit)IP configuration:Directory1 (MASTER):eno16777736:17
Ansible through the way of the module to complete some remote management work. You can view all modules through ansible-doc-l, you can use Ansible-doc-s module to view the parameters of a module, or you can use Ansible-doc Help module to view more detailed information about the module. The default module location is/us
First, host planning
Create 4 virtual machines as a demo ansible environment, install the operating system as CentOS 7.4. 1 of them as management host, the other 3 as the managed host. IP and host name are: IP host name note 192.168.128.10 Ansible-manager Management host 192.168.128.11 Ansible-demo1 managed host 1 192.168.128.12
the list's way table to identify the individual hosts, such as:
[webserver]www[01:50].test.org ansible_ssh_user=root ansible_ssh_pass=123456 #支持01到50,用户为root,密码为123456[dbbservers]db-[a:f].test.org #支持匹配a b c ... fThere are several important concepts in inventory.
1), host variables
Host variables can be added when the host is defined for use in subsequent playbook, such as
[webserver]www1.test.com http_port=80 maxRequestsChild=808www2.test.com http_port=8080 max
Ansible Problems
Developed based on paramiko. What is this paramiko? It is a python-Only SSH protocol library. Therefore, fabric and ansible do not need to install client/agents on a remote host because they communicate with remote hosts Based on SSH.
The inventory file is used to define the host to be managed. The default location is/etc/ansible/hosts.
Use of ansible
Introduction:
Ansible is designed for convenient and quick configuration management. With ansible, You can simplify and standardize complex configurations and make them easier to control. Ansible can achieve 100 and 1000 batch deployment.
Ansible features:
(1
Recent continuous integration with jenkins+gitlab+ansible, automated deployment and version rollback. However, the Deploy plugin failed to do incremental upgrades and rollback operations, tossing a long time to decide to write their own script simple implementation.Environment:7.0 64-bit gitlab:v2. 9.0 git: 2.9 1.651. 3, git plugin, GitLab plugin, Dynamic Parameter plug-in ansible:2.1. 0.0Various
': Search,' Regex ': Regex,' Regex_replace ': regex_replace,# list' Unique ': unique,' intersect ': intersect,' Difference ': difference,' Symmetric_difference ': symmetric_difference,' Union ': union,# version Comparison' Version_compare ': Version_compare,# random Numbers' Random ': Rand,}
The code for the template, this is just a test. The variables inside the template are not introduced from the outside, they are the variables I set myself.
code is as follows
cop
In the operation of the tool, the choice of using the Ansible API to interact with the server, the purpose of using ansible is simple, and the client does not need to install the agent, server installation after the Ansbile, the new machine can be managed.In order to combine the asset management system (CMDB), the method of dynamically acquiring inventory is used
Ansible is an automated operations tools, based on the development of Python, the collection of many 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.Ansible is a module-based capability that does not have the ability to deploy in batches. The real batch deployment is the module that
1th ChapterThinking1.1How to use one clickAnsibleBuild1.1.1First Step goalThe first thing we want to make clear is that we need to implement a one-click Automation script that executes a script and then automates the installation of Nfs+rsync+sersync andthen lets web01 automatically mount the NFS shared directory. 1.1.2Second step relationship clear and sequentialNow that we have a goal, what we need to do is we need to understand the sequencing of automated installations.
since we n
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.