Deploy keeplived and haproxy clusters using ansible, and ansiblekeeplived
I wrote a playbook for a cluster that uses ansible to deploy keepalived and haproxy. I personally feel that I need to be familiar with ansible. I need to start with jinja2 syntax and use jinja2 to write a playbook with higher versatility.
1. Environment for executing playbook.
2. direc
Managing hostsAccording to different lines of business to define their own management control host, from this host to manage the online server.Password managementFor different system requirements, the implementation of their own password policy, password or key, etc., in the execution of the task, select the corresponding password policy template to log into the business host.Host WarehouseEach of the online business's host warehouses, grouped by business, each group contains multiple hosts for
1. Prepare for the CentOS environmentYum Yum Upgrade2. Control server and managed server requirementsMaster:python 2.6+Slave:python 2.4+, preferably also 2.6+ (CentOS 6.7 comes with)3, configure SSH automatic loginConfigure Master to login to each slave ssh without password (use Ssh-keygen on master to generate key pair and add id_rsa.pub to Authorized_keys of each slave)4. Install ansible with YumYum Install ansible5. Configure HostBy default in/etc/
The lookup plugin for ansible can be used to read information from external data and then pay a variable. The types of external data information obtained include reading the contents of a file, randomly generating password, executing shell commands, reading Redis key values, and so on. Note that all of the operations of lookup are done on the Ansible console, not on the remote target machine.
Example:
----h
Label: Some time ago to understand ansible configuration management (http://blog.csdn.net/column/details/ansible.html anisble Configuration Tool box translation), I feel very strong, Think of the short term tornado and twisted it's a combination of what to do WebUI Today, I did a demo, and now probably the function is to join the Ansible host, and then a single execution script (perhaps the Playbook and bat
Method One:
Regenerate a key with no password on the master end via Ssh-keygen, and append the public key content to the ~/.ssh/authorized_keys of the managed end (multiple amounts can be supported);
Method Two:
In the management end through the Ssh-add secret key path, according to the prompts to enter the Passphrash can be long-term cache, the disadvantage is that when the user quit landing after the failure.
Its optimization scheme uses keychain+ssh-agent
Reference: http://www.ibm.com/
take a group as a child of another group
You can use a group as a child of another group, and assign variables to the entire group. These variables can be used for/usr/bin/ansible-playbook, but cannot be used for/usr/bin/ansible:
[Atlanta]
Host1
host2
[Raleigh]
host2
host3
[Southeast:children]
Atlanta
Raleigh
[ Southeast:vars]
some_server=foo.southeast.example.com
halon_system_timeout=30
self_destruct_
0x00. To automate the management of Windows servers, test Ansbile manage windowsTest tools, Environment: Ubuntu 14.04 lts,windows SP2, python2.7, Ipython, ansible1.70x01. Initial configuration of WinRM on Windows ServerA. Upgrading PowerShellHttps://github.com/cchurch/ansible/blob/devel/examples/scripts/upgrade_to_ps3.ps1B. Configuring WinRMHttps://github.com/ansible/an
Ansible Installing Nginx* Idea: First on a machine to compile and install the Nginx, packaging, and then use Ansible to the issued1./usr/local/nginx/is an nginx file that has been compiled and installed, and the startup scripts and configuration files are configured.2.cd/usr/local #进入上一级目录3.tar CZVF nginx.tar.gz Nginx #将目录打包4.cd/etc/ansible entering the
. years 4 Month - Day9:12First, the basic structureAnsible #Ansible-doc # View HelpAnsible-playbook # Execution PlaybookAnsible-pull #Ansible-galaxy #Ansible-vault #Second, configuration structureAnsible.cfg # configuration filehosts #inventory configuration fileRole # Role Directory1 , see all the modules you can use ansibl
Automated operations Tools: ansible
Application scenario for multi-process call Ansible API: Application System Check
An application system may have a cluster of 20-50 servers, and a preliminary system-level check can be checked with a unified playbook, such as (Df-h command). But deep into the application layer, there are some personalized applications, such as 2 HTTP servers, 20 middleware
The CMDB crawls service information in many ways, using automated tools Saltstack, Ansible, puppet, or using other modules to directly SSH remote connections to fetch server information. Here is a record of using the Ansible API interface to invoke the Setup module fetch.Experiment using two machines
Ip
System
Software
192.168.93.137
Centos6.5_x64
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
Easy to use roles for large projectsDirectory structure Orchestration650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8C/36/wKiom1hlF-SjFR-QAAHrlrracRc046.png-wh_500x0-wm_3 -wmp_4-s_1176155170.png "title=" 1.png "alt=" Wkiom1hlf-sjfr-qaahrlrracrc046.png-wh_50 "/>One click to install HTTPD and provide serviceCreate a directory structure[[email protected] ansible]# mkdir-p Roles/httpd/{tasks,files,vars}[Email protected]
Batch execution playbooksAnother way of remote batch command execution is to use playbooks;This is Playbooks's Official document: http://docs.ansible.com/playbooks.htmlHere are playbooks examples of ansible: https://github.com/ansible/ansible-examplesUsing the Ansbile API in PythonThe above methods of executing the Ansible
When the integrated Jenkins and ansible implement an automated deployment, the root user performs the ansible command when it is run correctly. Because the ansible command was executed through the Jenkins user, the Jenkins user reported the following exception:XXXXXXX | unreachable! = = {"changed"false, "msg " " Failed to connect to the host via SSH. " ,
Ansible automatic operation and maintenance (i.)I. Ansible automated operation and maintenanceSecond, ansible installation1. Basic Software Installation(1) Installation python-2.7.8CD python-2.7.8./configure--prefix=/usr/local make make install#如果ansible找不到python头文件的话, copy the Pytho header file to the standard direc
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.