Ansible learning-ansible
Ansible technologies (Automated O M tools) are developed based on python.
Installation methods include yum, apt, pip, etc.
For example, pip: pip install ansible
The only requirement of ansible for the client is to have SSH and Python (if the python
Playbook1 Playbook is a list consisting of one or more "play"The main function of 2 play is to dress up a pre-merged host into a role defined in advance by a task in ansible. Fundamentally, the so-called task is nothing more than a module that calls Ansible. Organize multiple play in a single playbook, which allows them to join together to sing a drama with a pre-programmed mechanism3 Playbook written in Ya
Do not reprint without written permission
Due to the long content in Chapter 3, I will divide it into several parts for translation.
Advanced PlaybooksSo far the playbooks that we have looked at are simple and just run a number ofmodules in order. Ansible allows much more control over the execution of yourplaybook. Using the following techniques, you should be able to perform eventhe most complex deployments.Running operations in parallelBy default,
Do not reprint without written permissionThe third chapter is long, because, I will be divided into several parts to translate.Advanced Playbooksso far the playbooks, we have looked at is simple and just run a number ofmodules in order. Ansible allows much more control over the execution of Yourplaybook. Using The following techniques, you should is able to perform eventhe most complex deployments. Running operations in Parallelby default,
If there is no written authorization, please do not reprint the fifth chapter of your own definition moduleExternal Inventoriesin The first chapter we saw how Ansible needs an inventory file, so that it knowswhere it hosts is a nd how to access them. Ansible also allows you to specify Ascript this allows you to fetch the inventory from another source. Externalinventory scripts can be written in any language
If you do not have written authorization, do not repeat Chapter 4. Use of ansible in large projects
RolesIf your playbooks start expanding beyond what includes can help you solve, or youstart gathering a large number of templates, you may want to use roles. Roles inAnsible allow you to group files together in a defined format. They are essentiallyan extension to includes that handles a few things automatically, and this helps youorganize them insid
I. Overview of AnsibleDue to the rapid development of the Internet, the speed of product replacement gradually accelerated, operations and maintenance personnel to carry out a large number of daily operations, still in accordance with the traditional way of maintenance will make the work inefficient. This is the deployment of automated operations that can accomplish these tasks as safely and efficiently as possible.Ansible is based on the development of Pythen, set up a number of excellent opera
If you do not have written authorization, do not repeat Chapter 4. Use of ansible in large projects
RolesIf your playbooks start expanding beyond what includes can help you solve, or youstart gathering a large number of templates, you may want to use roles. Roles inAnsible allow you to group files together in a defined format. They are essentiallyan extension to includes that handles a few things automatically, and this helps youorganize them inside
Notify the group chat name change to notify the group name change/**** This method is used: Notify the group chat name to change* @ Author tianwei* @ Version* 4.0 10:50:39*/Public static void policymembersmucnamechanged (String mJid, String roomJid,String newName ){List . QueryGroupChatContactListByGroupJid (roomJid );Try {For (GroupChatContactBean gccb: list ){I
://s2.51cto.com/wyfs02/M02/8C/2C/wKioL1hkoUrB17AiAAAp9eWY1K8761.png-wh_500x0-wm_3 -wmp_4-s_2731401758.png "title=" 12.png "alt=" Wkiol1hkourb17aiaaap9ewy1k8761.png-wh_50 "/>Perform650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8C/2C/wKioL1hkoWzxAEtQAABagvXyWXU174.png-wh_500x0-wm_3 -wmp_4-s_47665331.png "title=" 123.png "alt=" Wkiol1hkowzxaetqaabagvxywxu174.png-wh_50 "/>2, the use of notify, handlers to control (Note: This can only be used
Ansible module-lineinfile example, ansible-lineinfileLineinfile module details
The lineinfile module is similar to the sed tool in linux, but the articles on the Internet generally only have simple instances, and there are no examples of complicated points.
The following is a common example of the lineinfile Module I have summarized based on my actual operations.
Directory
More powerful than Ansible automated O M tools, automated and unified installation and deployment _ automated deployment of unifyDeploy1.0, ansible
New features:
Septem
In addition to pass (backup and update) and start (start Service), all automation is achieved.
Note: pass and start are set as service classes. Because of different services, automation cannot be achieved. Except for similar businesses, suc
"play". The main function of play is to dress up as a group of hosts in advance through the task defined by the Ansible role.A simple playbook configuration is as follows:
The code is as follows:-Hosts:localRemote_user:rootTasks-Name:echo HiShell:echo "HI"Ansible also supports setting up handlers,handlers to be invoked after the server changes after the tasks are performed, using the following handler:
The
February 23, 2016, learn, analyze Ansible code Ansible is a tool for bulk deployment used in operations, which is itself a framework, specific deployment and architectural analysis, and the following article is good. Http://os.51cto.com/art/201409/451927_all.htm First analyze the main file ansible, and the code and comments are as follows: 1. from __future__ Imp
Do not reprint advanced playbook without written permission
Extra variablesYou may have seen in our template example in the previous chapter that we used avariable called group_names . This is one of the magic variables that are provided byAnsible itself. At the time of writing there are seven such variables, described in thefollowing sections.
External variables
You have seen in the previous template example that we have a variable named group_names, which is a magic variable provided by
Use redis to accelerate ansible and redis to accelerate ansibleUse redis to accelerate ansible
We know that every time we use ansible, we need to collect system information. This step takes a lot of time. We can use redis to save the GATHERING time.1. ansible. cfg
[Defaults] gathering = smartfact_caching = redisfact_
Ansible-install svn and ansible-svn
Task:
Associate multiple machines with ansible
Familiar with the python ansible API, How can I obtain the execution progress of the playbook through the interface?
Python obtains the svn version number.
1. Install svn
Ubuntu SMP Thu Jan 15 20:21:55 UTC 2015 x86_64 x86_64 x86_64 GNU/
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 f
Ansible learning-simple learning notes 2, ansible-learning notes
Roles is used for hierarchical and structured organization playbook, and the encryption process in previous note 1 is used.
My directory svnrepos has two directories.
Ansible_test and test
Under the test directory:
The directory structure of ansible_test is:
The file content is as follows:
Copyright Disclaimer: Thi
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.