Common ansible Commands
Use Ansible-doc-l to see how specific modules are used, here are examples of common ansible simple usage Execution system commands
[Root@ansible ~]# ansible pinpoint-m shell-a ' hostname '-o # Execute system command
192.168.0.102 | SUCCESS | rc=0 |
.
The code is as follows
Copy Code
-Hosts:all Tasks-debug:msg= ' {lookup (' env ', ' Home '}} ' is a environment variable '-debug:msg= ' {{item}} ' is a ' from ' result ' of this command 'With_lines:-CAT/ETC/MOTD-debug:msg= ' {lookup (' pipe ', ' Date '}}} is the raw result of-debug:msg= ' {lookup (' redis_kv ', ' Redis://localhost:6379,somekey ')}} is value in Redis for Somekey '-debug:msg= ' {lookup (' dnstxt ', ' example
Objective:Shell + ansible + Gateone Automated operations Management: Minimal manual intervention, combined with the use of scripts and third-party tools to ensure that the business system 24x7 efficient and stable operation;
1. Installation environment involves softwareThis operating system: Centos 6.5 32/64 for testing
Project installation Software
Version
Py
AnsibleThe automated operation and maintenance system is divided into 3 structuresInstall operating system: OS provisionRepresentative Product: Pxe,cobblerTo install a specific file: OS ConfigRepresentative Product: PuppetTo perform a specific action (command): DeploymentRepresentative Product: AnsibleAnsible General Framework Diagram:650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8A/E2/wKiom1g-KFrDGdwWAAJgLrRJMHY747.png "title=" Ansible.png "alt=" Wkiom1g-kfrdgdwwaajglrrjmhy747.png
For saltstack users, Ansible is a good ssh-based solution. It can greatly simplify the automatic configuration management and process control methods of Unix administrators. It uses the push method to configure the customer system so that all work can be done on the master server side. Its command line mechanism is also very powerful, and you can use the Web UI to implement authorization management and configuration, of course, free of charge is very
Any server can be the master terminal
1, install Epel Source:# RPM-IUVH http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
2. Install the package:# yum Install Ansible
3, set up SSH password-free login:# # Generate public/private key # Ssh-keygen-t Rsa-p ' # # Write a trusted file (distribute/root/.ssh/id_rsa_storm1.pub to other servers and execute the following on all servers): # CAT/ROOT/.SSH/ID_ Rsa_storm1.pub >>/root
First, the basic introduction of Ansible:
What's the ansible type?Ansible is a very simple IT operations automation tool engine for configuration management, application deployment, internal service orchestration, and more, for hundreds of thousands of managed nodes, based on Python development. She does not need an agent and is easy to deploy, with no other
Ansible playbook component, ansibleplaybook
Core elements of playbook:
Tasks: Task
Variables: Variable
Templates: Template
Handlers: Processor
Roles: Role
Organization format: YAML (also known as a Markup Language)
Syntax: (the list is represented by a horizontal bar. Key-value pairs are separated by colons, and other key-value pairs can be nested in key-value pairs)
Example: name: tom
Age: 21
Gender: Male
Spourse:
Name: lily
Gender: female
Children:
Common ansible module usage
Ansible provides many modules by default. In Linux, we can run the ansible-doc-l command to check which modules are supported by ansible, you can use the ansible-doc-s Module name to view the parameters available for this module.
The following des
Before I had summed up a little Ansible series Bowen, this article also take the previous space bar. In the current network application, the security-hardened host is not allowed to log in directly to the root user, and many commands require root users to perform, without rebuilding the current network. Hope that through a common user first landing, and then Su-cut to root execution. and the passwords for the regular and root users of each host are di
Ansible notesHosts: remote hostUser: Users who are executing the task groupRemote_user: Same as usersudo: If set to Yes, the user performing the task group gets root permission when the task is performed.Sudo_user: If you set user to Tom,sudo as Yes,sudo_user for Jerry, then Tom gets the permissions of the Jerry user.Connection: How to connect to the remote host.# # #gather: Collecting Facts: FactsGather_facts: Unless you explicitly indicate that you
Ansible Playbook A very powerful function is to allow us to customize Filter_plugins, what is this filter_plugin?
Is what we usually see.
{{Item|max}}}
In fact, the back of this max is a function, we can define our own functions, such as:
|--Filter_plugins| |--zhiming_filter.py| '--ZHIMING_FILTER.PYC'--main.ymlThe directory structure is that we create the Filter_plugins folder under our playbook, then write a python file that defines some methods:
Ansible is a free and open source configuration and Automation tool developed for UNIX-like systems. It's written in Python, similar to chef and puppet, but there's a difference and the advantage is that we don't need to install any clients in the node. It uses SSH to communicate with the node. In this article we will install and configure ansible on CentOS7, and try to manage two nodes.Ansible Server –ansi
First, what kind of situation requires a lot of deployment
1, the installation of the operating system
Common is collber,red hat satelite (Redhat) system dedicated.
2, the operating system configuration
Common to have cfengine,puppet,chef,func. One of the most popular puppet
3, the deployment of batch programs
4, the volume command run View status information
Ii. introduction of Ansible
The structure of the ansibl
Prerequisite: To install Tomcat first, please refer to the previously written blog post on Centos7 to install Tomcathttp://12395331.blog.51cto.com/12385331/1884980Installing Jenkins1> Download the Jenkins package. Enter the tomcat/webapps/directory, download the Jenkins.war package here, the following problems can be downloaded to this directory, the deployment of the process is not down for half a day, providing Jenkins accessorieswget Http://mirrors.jenkins-ci.org/war/latest/jenkins.war2> jek
Summed up are some of their own use of relatively simple knowledge, about State.sls and playbooks and other knowledge is still learning ... 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0059.gif "alt=" J_0059.gif "/>AnsibleLightweight, automated operations tools, SSH-based, no client-sideInstallation and Configuration1, the main control end loaded ansible (yum install-y ansible)2. Import the mai
The main changes in the Ansible 1.9.0 (version code is dancing in the street,ansible each major version of a song in the Vanhallen band) are: Added Kerberos support to WinRM Connection plugin. Tags rehaul:added ' all ', ' always ', ' untagged ' and ' tagged ' special tags and normalized tag resolution. Added tag information to--list-tasks and new--list-tags option. Privilege escalation generalization, new '
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.