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" |
---
- 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:html
ansible-playbook test.yml
Then switch to shell-node1, verify if the readme.txt and user wayne03 been created or not:
node