-
Offical introduction to playbook
You can get official reference of playbook from below url:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#playbook-syntax -
Key element of playbook
Task The management activities we are going to perform for remote servers Variables Variables we can use in the playbook YAML file, including user defined variables, built-in variables, and also variables defined in Inventory file Template Template file with a syntax, like some configuration files etc. Handlers Handlers working with notify, while the activities match a condition, then it's trigger the handler to perform some specific action Tags Mark the task in playbook with a tag, while we execute the playbook, we can specify which task to be executed by specify the tag name, like:
ansible-playbook hosts.yml --tags="only"
-
Ansible playbook syntax
Below is an example of the playbook should be looks like:--- - hosts: webservers remote_user: root vars: filename: readme.txt tasks: - name: create readme file file: name=/tmp/{{filename}} state=touch - name: create new user user: name=wayne03 state=present shell=/bin/bash
By execute above playbook, save above content to file named test.yml, you can run below command:
ansible-playbook test.yml
Then switch to shell-node1, verify if the readme.txt and user wayne03 been created or not:
相关文章
- 12-10HTML5 大文件上传解决方案(500M以上)
- 12-105 -- Hibernate的基本用法 --2 1 Hibernate 下载和安装
- 12-10STC12C5A60S2 双串口通信
- 12-10HTML5中选择器querySelector的使用
- 12-10mozhe WebShell代码分析溯源(第4、5题)
- 12-10WebShell文件上传漏洞分析溯源(第5题)
- 12-10PAT(乙级)2019年冬季考试 7-5 区块反转 (25分)
- 12-10MD5 32位 小写加密和大写加密
- 12-10.net5 core webapi项目实战之十九:发布和部署(完结篇)
- 12-10windows平台的分布式微服务解决方案(5)--Web服务/WebApi的负载均衡