Ansible Configuration and InstallationFirst, installation1. Install Python# tar Xvzf python-2.7.8.tgz# CD Python-2.7.8#./configure--prefix=/usr/local# make--jobs= ' grep processor/proc/cpuinfo | Wc-l '# make instal Lor directly install Yum source yum install python*.Because Ansible is written in the Python language. So Python support is required.2, Installation AnsibleRPM-IVH Yum Sourcehttp://mirrors.sohu.c
http://docs.ansible.com/
Official documents
Https://github.com/ansible?page=1
Ansible GitHub Project Set
Https://github.com/ansible/ansible/tree/devel
GitHub Source Project
https://www.ansible.com/
Official website
Ansible provides many modules by default for our use. In Linux, you can see which modules are supported by the current ansible through the ansible-doc-l command, and you can see which parameters of the module can be used by ansible-doc-s the module name.Common modules:! All examples match the target host with webserver
Objective:Automatically deploy Lnamp with Ansible for highly available nginx reverse server, central http+php provides Web services, backend links to the same MySQL databaseLab Environment:Ansible Host: 10.0.0.10/8Nginx (main): 10.0.0.11/8Nginx (prepared): 10.0.0.12/8Virtual IP:10.0.0.111/32Http1:10.0.0.21/8Http2:10.0.0.22/8Mysql:10.0.0.30/8Edit the Hosts file for Ansible# # # #Nginx反代主机地址及变量设置 [agent_serve
report when running this stepImporterror:no module named Setuptools#运行pip模块查看# PIP ListPip (1.4.1)Setuptools (1.4.2)Wsgiref (0.1.2)Pip Install ansible PluginPip install Paramiko Pyyaml jinja2 httplib2Pip Install AnsibleIf you run an error after installation: Attributeerror: ' Module ' object has no attribute ' have_decl_mpz_powm_sec 'Pip Install Pycrypto-on-pypiView the version of AnsibleAnsible--versionAnsible 1.7.2Installing
, Loader=loader, Options=options, Passwords=passwords, Stdout_callback=results_callback, # Use our custom callback instead of the ' Defaul T ' callback plugin) result = Tqm.run (play) Finally:if TQM is not None:tqm.cleanup ()Python API Pre 2.0This is simple:Import Ansible.runnerrunner = Ansible.runner.Runner ( module_name= ' ping ', module_args= ' ', pattern= ' web * ', forks=10) datastructure = Runner.run ()The Run method returns the results of each host, grouped according t
Today, the Linux system is installed on ansible by Red Hat Enterprise Linux Server release 6.5 (Santiago).
Because the source of the system is a Yum source, install with yum install ansible, but error: (This error is that the Yum source is not registered with the Red Hat system.)
Yum source can not be installed, so a change of thinking. Install using PIP. Pip is a python-de
Ansible series (9) Copy ModuleCopy Module
The role of the copy module in ansible is to copy the files on the ansible Execution Machine to a remote node.The opposite operation of the fetch module.Common module Parameters
Parameter Name
Required?
Default Value
Option
Description
Src
No
The absolute path is used to loc
Ansible series (9) Copy module, ansiblecopyCopy Module
The role of the copy module in ansible is to copy the files on the ansible Execution Machine to a remote node.The opposite operation of the fetch module.Common module Parameters
Parameter Name
Required?
Default Value
Option
Description
Src
No
The absol
Sudo:yestasks:#Defining a task List (top-down sequential execution)-Name:ensure Nginx isAt the latest version#each transaction can define a name tag, with the benefit of enhanced readability and the ability to see where the run is when the results are outputYum:pkg=nginx State=latest#Yum installs the latest version of Nginx-name:write The nginx config file template:src=/home/test/ansible/nginx/nginx2.conf dest=/etc/nginx/nginx.conf#Configure the Ngin
Perform a playbookThe above sections already have a preliminary understanding of Playbook's syntax, so how do you run a playbook?This is very simple, here's an example of running playbook in parallel, the level of parallelism is 10Ansible-playbook Playbook.yml-f 10Ansible-pull (pull configuration rather than push configuration)Can we turn the ansible architecture upside down so that the managed nodeDo check in to get configuration information instead
A description of the application scenarioNow I need to distribute Logstash new version of RPM package to 50+ number of servers, about 220MB, directly using ansible Copy command, the command is as follows:Ansible all-m copy-a "src=/opt/software/logstash/logstash-agent-2.3.3-fb.centos6.x86_64.rpm dest=/opt/software/ LogstashIn the process of implementation, soon received Zabbix network monitoring alarm, alarm project is instantaneous traffic change more
Copy ModuleThe role of the copy module in Ansible is to copy the files on the ansible execution machine to the remote node.The reverse operation of the fetch module.Common module parameters
Name of parameter
whether you must
Default Value
Options
Description
Src
No
The absolute path is required to locate the files on the machine t
Used to play ansible, the root account is used to manage. Now to the production environment, can not be so casual, I believe that many other companies are also banned from the root SSH connection.Therefore, I have a problem with this deployment, many articles on the internet, are not elaborate on this piece. I also groping to do out, through this practice, but also further deepened the understanding of ansible
Recently encountered a problemSeport is isn't a legal parameter in an Ansible task or handlerThe reason is that my local Ansible Extra Modules is obsolete and needs to be updated. But the official document of Ansible only gives such a word.There should be no need to install this repo separately as it should being included in any
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, which eliminates the need to configure host
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 tool func
), Dictionary
The Dictionary (dictionary) is identified by key and value, such as:
name: Example DeveloperJob: DeveloperSkill:Elite
You can also use Key:value as a representation in {}, such as:
{name: Example Developer,Job: Developer,Skill:Elite}Inventory Host Inventory
Ansible for more convenient management of the host, in the host list will be managed host group naming, the default host inventory is the/etc/
Objective:What is Filter_plugins? This word is broken down, filter! The person familiar with the jinja2 template, to know that he is a filter, can use Pyhton code to process strings in a template in a pipe way. The ansible template calls the JINJA2, which is known to all. This Filter_plugins plug-in code is designed to better handle strings and logical judgments in the JINJA2 template. Previously, I talked to Shen Zan about a template problem, really
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.