一个playbook由两个play构成,每个play都是一个列表项
每个play又是一个字典结构
栗子:
将下面playbook转换为Python
palybook:
---
- hosts: test
tasks:
- name: install Apache
yum:
name: httpd
state: installed
- name: Start service
service:
name: httpd
state: started
Python:
[
{
hosts: test,
tasks: [
{
name: install Apache,
yum: {
name: httpd,
state: installed
}
},
{
name: Start service,
service: {
name: httpd,
state: started
}
}
]
}
]