任务描述 | YAML代码示例 |
安装软件包 | tasks:
name: Install package
apt: name=nginx state=latest |
启动服务 | tasks:
name: Start service
service: name=nginx state=started |
设置配置文件 | tasks:
name: Configure file
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf |
确保服务正在运行 | tasks:
name: Ensure service is running
service: name=nginx state=started enabled=yes |
创建用户 | tasks:
name: Create user
user: name=myuser state=present |
拷贝文件 | tasks:
name: Copy file
copy: src=/path/to/local/file dest=/remote/path owner=root group=root mode=0644 |
安装pip包 | tasks:
name: Install pip package
pip: name=django version=1.11 |
注册任务结果 | tasks:
name: Register task output
shell: echo "Hello, World!" register: myoutput |
输出注册变量 | tasks:
name: Output registered variable
debug: var=myoutput.stdout |