: [u ' cen7 ']Hosts (2):192.168.27.101192.168.27.102See what tasks are in Playbookerror! You must specify a playbook file to run[Email protected] ansible]# Ansible-playbook test.yml--list-tasksPlaybook:test.ymlPlay #1 (CEN7): Cen7 TAGS: []TasksInstall package TAGS: []Start s
The previous article introduced the installation configuration and example of Ansible: http://msiyuetian.blog.51cto.com/8637744/1748143The following article mainly introduces Ansible's playbook, playbook is equivalent to the module or function written into the configuration file, and then we execute the configuration f
Meet a demand today when using Ansible-playbook after executing a script, according to the content returned by the script to determine whether to continue execution or break execution, query official website found using Register Register can be used to achieve the recording script output, using when+ Fail module to determine whether to proceed or break down, here is
Ansible is a lightweight batch configuration management tool for agentless, because of the relatively late (13) development based on ansible less relevant documents, so here are some small experiments, combined with the existing data and source code, explore the Ansible two times development.The contents of the essay a
Preface
Two previous articles talk about ansible deployment and use of ansible modules respectively. They have an initial understanding of ansible. This article focuses on introducing playbook.For details about ansible deployment, click ansible first: DeploymentAnsible modul
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
execution, one responsible for planning, Nice.A simple playbook
A simple playbook should be as follows:
---
What did the above playbook do? Explain the task section. People who are familiar with Linux may be able to guess 78:1. Use yum to install the latest apache version.2. overwrite the httpd. conf configuration fi
Pulgin.How to do it?
First confirm the path of the ANSIBLE.CFG, Pip installs the ansible is the default not ansible.cfg this file, should be so, we go to GitHub to download this configuration file to local,
[Email protected]:/etc/ansible# Tree ├──ansible.cfg├──callbacks│├──jastme.py│└──jastme.pyc├──hosts└──play
There are many ways to define and reference variables in Ansible playbook, which are tested in the local environment and collated as follows. test Environment:
Using your own Mac notebook to install Ansible as the control server, the VMware Fusion virtual machine runs on a CENTOS7 virtual machine (192.168.243.146) as a remote controlled host tested with
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
0. IntroductionPlaybooks is the language of Ansible management configuration, deployment applications, and orchestration, and you can use playbooks to describe the policies you want to perform on the remote host or the set of steps that you perform.Similar to a set of task sets, defining information such as projects, organizational structures, profiles, and so on, the task
multiple Ansible objects, different inventory different playbook
Create multi-process, execute program
Precautions
The Ansible api2.0 is much more complex and more flexible than the 1.0. This needs to read the original code, need to spend a little more time and patience
Before using mu
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-pu
Playbook-Introduction: Playbooks is a mode different from the ansible command line execution mode, and its functions are more powerful and flexible. In simple terms, playbook is a very simple configuration management and multi-host deployment system. Unlike any existing mode
need to send the key to the production environment host2. Upgrade and RollbackUpgradeAnsible-playbook/home/app/api.yml-vRolling backAnsible-playbook/home/app/api-rollback.yml-vAnsible-playbook followed by the Yml file path written earlier,-V is to display detailed execution information3. AttentionIf you perform an upg
I. Description of the EnvironmentServer with Ansible installed: 192.168.13.45Test environment server: 192.168.13.49/home/app/api-tomcat/webapps/api.war a new version of the war package location for the test environmentProduction Environment server: 192.168.13.51/home/app/api-tomcat/webapps/api.war for production Environment War package location/HOME/APP/API-TOMCAT/WEBAPPS/API for production environment Project location/home/app/tomcat.bak/ api/webapps
/tasks/install.yml-name:install mysql Shell:/bin/sh/r oot/mysql_install.shCreate an include file[Email protected] roles]# Cat/etc/ansible/roles/mysql_install/tasks/main.yml-include:copy.yml-include: Install.ymlThe final playbook structure is[Email protected] roles]# tree/etc/ansible/roles/mysql_install//etc/
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.