absible
[root@room8pc16 myansible]
- name: configure dbservers
hosts: dbservers
tasks:
- name: install mariadb
yum:
name: mariadb-server
state: present
- name: start mariadb
service:
name: mariadb
state: started
enabled: yes
- name: configure webservers
hosts: webservers
tasks:
- name: install apache
yum:
name: [httpd, php, php-mysql]
state: latest
- name: start httpd
service:
name: httpd
state: started
enabled: yes
转换成python数据类型
[
{
'name': 'configure dbservers',
'hosts': 'dbservers',
'tasks': [
{
'name': 'install mariadb',
'yum': {
'name': 'mariadb-server',
'state': 'present'
}
},
{
'name': 'start mariadb',
'service': {
'name': 'mariadb',
'state': 'started',
'enabled': 'yes'
}
},
]
}
]