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
Linux Remote automatic login and execute commandsTelnetThis automatic login process is implemented through the expect inside the shell, similar to opening a cmd-like command segment output IP and password.Note that the script can be executed if the expect is installedYum Install-y expectDirectly on the script:#!/usr/bin/expect
SOLARIS_CHANGE_PASSWD Precautions and instructions for use1.The script only tested the English and Chinese versions of SOLARIS10 (Oracle Company)2.SOLARIS10 Chinese system needs to change the system character set to ZH_CN. UTF-83.Execute this script in bashBash SOLARIS_CHANGE_PASSWD user name ($ $) User password ($ $) User password ($ $) that requires a password change ($ $4)Script Variable definition:#!/bin/bashUser=$1 #用户名Ip=$2 #IP地址Pw=$3 #用户密码Che_user=$4 #需要更改密码的用户名Che_pw=$5 #更改的密码Ping-c 3 ${
Upload the backup SQL files from one server to the corporate local server but the company's local server did key verification, that is, to use key to log on to the local server, as well as the external network of the server did not do key verification, OK, then directly from that server to drag data to the local server bar.
The script is as follows:VI Down.exp
The code is as follows
Copy Code
#!/usr/bin/expect-fSet Timeou
Tags: mariadb compiling and installing shell Automation Ansible Project PracticeIn the previous blog has been demonstrated, through scripting MySQL Universal binary installation, the following through the demonstration script to implement the source code compilation MARIADB Automation, in large-scale deployment of multiple mariadb, where the use of ansible to implement its automated deployment, Can greatly
Playbook is a list of one or more "play"The main function of play is to dress up a pre-set host as a role defined in advance through the task in ansible. Fundamentally, the so-called task is nothing more than a call to Ansible's module. By organizing multiple play in one playbook, you can connect them to run in a pre-programmed mechanism.Playbook use Yaml language to write each ansible Playbook is a yaml fo
Expect is a software tool for automated control and testing in UNIX systems, made by Don Libes, as an extension of the TCL scripting language, applied in interactive software such as TELNET,FTP,PASSWD,FSCK,RLOGIN,TIP,SSH, etc.Yum Install-y expectScript one:Automatic Telnet #! /usr/bin/expectset host "192.168.226..130"set passwd "123456"spawn ssh [emailprotected]$hostexpect {"yes/no" { send "yes\r"; exp_continue}"assword:" { send "$passwd\r" }}interact
Brief introduction:Expect can perform interactive operation with system for system administratorYum Install Yum which expect # path /usr/bin/expectExample one:Shell >Cat Login. exp#!/usr/bin/ExpectspawnSSH[Email protected]192.168.1.81; expect {"(yes/no)?"{Send"yes\r"; Exp_continue}"Password:"{Send"123456\r"; Exp_continue}"#"{Send"uptime\r"; interact}}# # Use/usr/bin/e
This expect script is meant to get the capacity of the server on the line, and it has no practical meaning#!/usr/bin/expectSet timeout #设置超时Set user [lindex $argv 0] #设置第一个参数Set password [lindex $argv 1]Set ipaddr [lindex $argv 2]Set port [lindex $argv 3]Set MyPassword [lindex $argv 4]Spawn ssh [email protected] $ipaddr-p $port #远程连接sshExpect {"(yes/no)" {send "yes\r"; Exp_continue}"Password:" {send "$password \ r"}}
followed by the option parameter, it will prompt for your custom error message,-A is not required to provide parameter options ( Because there is no colon appended to the letter, the script is executed without a parameter (or when the-a option is not followed), and no error is given.? Case question mark, when the following parameters such as-e does not exist when the errorAll of the above error $optarg variables are not available1.1.4 Script Query IP geolocationScript#!/bin/bashgetip=$ (curl-s
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
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.