playbook in a command if he wants, whether right or wrong will continue to be used
CAT / root / dlow || / bin / to true
CAT / root / dlow
ignore_errors: True
··········
--list-host to view the list of hosts
··········
--limit ip performed only on the host
·········
-vvvv View Details
·········
-C Test
............
notify notify
handlers trigger
are subject to change want to change
·········
Tags: Use behind action, label
command line call for the ansible-playbook -t tagsname xx.yml
more labels, separated by
a plurality of action can a common label
·········
{{}} variable name
command can assign -e 'variable name = xxx'
plurality of variables with a space
··········
in playbook directly define variables
vars:
- Variable name 1: value 1
- Variable name 2: value 2
···········
variables can also be defined in the hosts file
followed ip defined directly
may also be
[group name: vars]
directly define
the priority of the host is larger than a single line command is greater than the group defined
????? ............
variables can also be a separate file
vars_files:
- vars.yml
playbook in such a call
········
[root @ ansible ansible-the Test] # CAT vars.yml
var1: ding
So set the variable file inside
·········
Template template
template can refer to variables
both versatility also have flexibility
·········
the when statement can do to control
............ ··
{{}} Item
with_items:
- xx
- xx
- xx
Iterative
···········
{{{{item.name, for item.banji}}}}
with_items:
- { 'name': 'Ding', 'Banji': '. 3'}
iteration nested
··········
the ports: the list can be a string can also be a dictionary
-
x - 'x1':'1'
- 'Y2': '2'
- x
- X
···········
defined in the template for cycle
{% for i in ports%} i is variable, ports list is defined
Endfor%}% {
············
{% for the ports in I%}
{%}% IF X IS defiend in nested loop determines
{% endif%}
{%} endfor%
roles/
├── httpd
├── memcache
├── mysql
└── nginx
├── tasks
│ ├── group.yml
│ ├── main.yml
│ ├── restart.yml
│ ├── service.yml
│ ├── templ.yml
│ ├── user.yml
│ └── yum.yml
└── templates
└── nginx.conf.j2
roles角色,可以将多个要做的事分开,主配playbook里只需调用即可
- hosts: 192.168.3.61
remote_user: root
roles:
- role: nginx