Playbooks are YAML files that are used for #202204272021 configuration. Structurally, it contains plays, 202205042134#, 202204300820#, and 202204300825#. They could be run by the command line ansible-playbook
or #202204300954. It is shown as below:
--- # start of a play
- name: install and start apache
hosts: web # individual host or group
become: yes # This is a plugin that escalate privilege (root permission)
vars: # define variables for a play, not recommended
var1: Ansible
var2: This is
var3: "{{ var2 }} {{ var1 }}" # Result: This is Ansible
tasks: # From here, define tasks
- name: httpd package is present
yum: # This is a module
name: httpd
state: latest
debug: # Debugging messages
msg: "some debugging messages"
- name: latest index.html is present
template: # This is a module
src: files/index.html
dest: /var/www/html/
- name: httpd is started
service: # This is a module
name: httpd
state: started
Note: The order of the tasks written in the playbook is their order of execution.
Note: In the play section, we could add role
to import 202205042207#. If we just need that role for a task, we could include it using include_role
under tasks
.