Cluster O M automation tool ansible uses playbook to install mysql Cluster
Last time I introduced how to use ansible playbook to install the zabbix client (http://www.bitsCN.com/article/52158.htm), this time I introduced how to use playbook to install mysql.
The following
Today, we found a bash vulnerability, but I have nearly 1000 servers. To facilitate and save time, I feel that I am using ansible to install the bash update package. Next I will share my installation method.
1. Installed playbook content
19:00:03#cd/etc/ansible[emailprotected]:/etc/ansible19:00:06#catupdate_bash.yml----hosts:"{{host}}"remote_user:"{{user}}"gather
Last described how to install the Zabbix client (http://www.jb51.net/article/52158.htm) using Ansible playbook, this time describes how to use playbook to install MySQL.
Here is the information for installing MySQL:
Mysql_basedir:/data/mysql/basedir Source directory
mysql_datadir:/data/mysql/datadir Data Directory
mysql_user:mysql MySQL
Frontier: ansible are all good, so let's talk about lookup plugins this plugin. Lookup_plugins is mainly used to implement extensions of various strings and variables within the extended playbook. For me personally, the use is not too big, but looked at the official Lookup_plugins extension list, there are some ideas. When you first use lookup, you encounter a problem where the data in {lookup}} is
listvariable_manager.set_inventory (Inventory)#Create play with TasksPlay_source =dict (Name="Ansible Play", the hosts='Web',#the hosts variable that corresponds to the Playbook entry Yaml file, or it can be an IPGather_facts ='No', Tasks=[Dict (Action=dict (module='Shell', args='ifconfig'), register='Shell_out'), #dict (action=dict (module= ' Debug ', Args=dict (msg= ' {{shell_out.stdout}} ' ))
Ansible-playbook JDK InstallationThe directory structure for JDK role is as follows:[Email protected] roles]# tree Jdkjdk├──defaults├──files│└──jdk-8u101-linux-x64.tar.gz├──handlers├──meta├──tasks │└──main.yml├──templates└──vars└──main.yml#vars下面的忽略, that's the one that was written before.The contents of the task file are as follows:[[emailprotected]tasks]#catmain.yml-name:copy jdk-8u101-linux-x64.tar.gzrem
Example of ansible compiling httpd playbook, ansibleplaybook
The following is the content of the playbook. The process is as follows:
1. First, a total of 3 .tar.gz files are downloaded in the local directory of apr, apr-util, and httpd.
2. decompress the three files.
3. Install the pcre and pcre-devel dependency packages.
4. Compile and install apr.
5. Compile a
-util--with-apr=/usr/local/Apr Make Make Install-name:complie httpd Shell:|CD/root/httpd-2.4. - ./configure--prefix=/usr/local/apache--sysconfdir=/etc/Apache--enable-mpms-shared= All--with-z--with-Pcre--with-apr=/usr/local/Apr--with-apr-util=/usr/local/apr-util--with-mpm=Event Make Make InstallAfter compiling, there are a series of actions, such as setting the PATH environment variable, setting the man path, modifying the configuration file, starting httpd, and so on. The
(the colon must be followed by a space):---# One employee's record name:example Developerjob:Developerskill:EliteDictionaries can also be expressed in indented form, if you like:---# A worker's record {name:example Developer, job:developer, Skill:elite}Ansible does not use this format too much, but you can specify a Boolean value (True/fase) in the following format:---create_key:yesneeds_agent:noknows_oop:Truelikes_emacs:TRUEuses_cvs:falseLet's put t
Include:In a large complex architecture, the first problem is the growing playbook file size, a large playbook difficult to understand and maintain, the end method is to use include, your plays break down into different segments and then include them in the other plays . Different segments are categorized according to different purposes. All are included in the main plays . There are four types of inclusion
is included using a more verbose format thatallows us to pass variables to the role:---- name: Setup servers for website1.example.comhosts: website1roles:- common- apache- { role: website1, port: 80 }For the role named common , Ansible will then try to load roles/common/tasks/main.yml as a task include, roles/common/handlers/main.yml as a handlerinclude, and roles/common/vars/main.yml as a variable file include. If all of thesefiles are missing,
value of poll to 0 .Finally, if the task that you are running takes an extremely long time to run, you cantell Ansible to wait for the job as long as it takes. To do this, set the value of asyncto 0 .You will want to use Ansible's polling in the following situations:• You have a long-running task that may hit the timeout• You need to run an operation across a large number of machines• You have an operation for which you don't need to wait to compl
Ansible @ an efficient configuration management tool-Ansible configure management-translation (5), ansible-ansibleDo 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 m
Do not reprint advanced playbook without written permission
Finding files with variablesAll modules can take variables as part of their arguments by dereferencing themwith {{ and }} . You can use this to load a particular file based on a variable.For example, you might want to select a different config file for NRPE (a Nagioscheck daemon) based on the architecture in use. Here is how that would look:---#1- name: Configure NRPE for the right architect
No written authorization. Do not reprint Chapter 5 custom Module
Using a moduleNow that we have written our very first module for Ansible, we should give it ago in a playbook. Ansible looks at several places for its modules: first it looks at theplace specified in the library key in its config file ( /etc/ansible/ansi
features that allow you to select which parts of a playbook you needto run, and which should be skipped. While Ansible modules are idempotent andwill automatically skip if there are no changes, this often requires a connection to theremote hosts. The yum module is often quite slow in determining if a module is thelatest, as it will need to refresh all the repositories.If you know you don't need certain act
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.