๐Ÿ”ด Ansible Dictionary

Every keyword, operator, and symbol โ€” with plain-English explanations.

PLAYBOOK DIRECTIVES Ansible
Playbook directives define the structure and control flow of an Ansible playbook.
- hosts: all\n- gather_facts: no\n- tasks:\n  - name: Example task\n    debug: msg: "Hello, world!"
TASK DIRECTIVES Ansible
Task directives control the behavior of individual tasks within a playbook.
- name: Example task\n  shell: echo "Hello, world!"
FILE MODULES Ansible
File modules handle file-related tasks such as copying, templating, and managing files and directories.
- copy: src=/path/to/file dest=/path/to/destination
COMMAND MODULES Ansible
Command modules execute shell commands and scripts on remote hosts.
- command: ls -l
PACKAGE MODULES Ansible
Package modules manage software packages on remote hosts.
- apt: name=httpd state=present
SERVICE MODULES Ansible
Service modules manage services and their states on remote hosts.
- service: name=apache2 state=started
USER MODULES Ansible
User modules manage user accounts and groups on remote hosts.
- user: name=example_user state=present
NETWORK MODULES Ansible
Network modules manage network-related tasks such as configuring firewalls and managing network services.
- ufw: state=present rule=add
FIREWALL MODULES Ansible
Firewall modules manage firewall configurations on remote hosts.
- ufw: state=present rule=add
VARIABLE USAGE Ansible
Variable usage involves setting, registering, and using variables within a playbook.
- set_fact: my_variable={{ 'value' }}
JINJA2 FILTERS Ansible
Jinja2 filters modify variables in a playbook using Jinja2 templating language filters.
- set_fact: my_variable={{ 'value' | lower }}
CONDITIONALS Ansible
Conditional statements allow for conditional execution of tasks based on certain conditions.
- when: ansible_os_family == 'RedHat'
ANSIBLE-PLAYBOOK FLAGS Ansible
Playbook flags are options used to control the execution of an Ansible playbook.
--check
hostvars Ansible
hostvars is a variable in Ansible that provides access to the facts and data of a specific host in the inventory.
- debug: msg="{{ hostvars['example_host'] }}"
inventory_hostname Ansible
inventory_hostname is a variable in Ansible that represents the hostname of the current host in the inventory.
- debug: msg="{{ inventory_hostname }}"
ansible_host Ansible
ansible_host is a variable in Ansible that represents the IP address or hostname of the remote host to connect to.
- debug: msg="{{ ansible_host }}"
ansible_port Ansible
ansible_port is a variable in Ansible that represents the port number to connect to the remote host.
- debug: msg="{{ ansible_port }}"
ansible_user Ansible
ansible_user is a variable in Ansible that represents the username to use for connecting to the remote host.
- debug: msg="{{ ansible_user }}"
ansible_password Ansible
ansible_password is a variable in Ansible that represents the password to use for connecting to the remote host.
- debug: msg="{{ ansible_password }}"
ansible_ssh_private_key_file Ansible
ansible_ssh_private_key_file is a variable in Ansible that represents the path to the SSH private key file to use for connecting to the remote host.
- debug: msg="{{ ansible_ssh_private_key_file }}"
ansible_become Ansible
ansible_become is a variable in Ansible that controls whether the task should be run with sudo or become privileges.
- debug: msg="{{ ansible_become }}"
ansible_become_user Ansible
ansible_become_user is a variable in Ansible that represents the user to become when running a task with become privileges.
- debug: msg="{{ ansible_become_user }}"
ansible_python_interpreter Ansible
ansible_python_interpreter is a variable in Ansible that represents the Python interpreter to use on the remote host.
- debug: msg="{{ ansible_python_interpreter }}"
ansible_connection Ansible
ansible_connection is a variable in Ansible that represents the connection type to use for connecting to the remote host.
- debug: msg="{{ ansible_connection }}"
vars Ansible
vars is a variable in Ansible that represents a dictionary of variables to be used in the playbook.
- vars:\n  my_var: value
vars_files Ansible
vars_files is a variable in Ansible that represents a list of files containing variables to be loaded into the playbook.
- vars_files:\n  - /path/to/vars1.yaml\n  - /path/to/vars2.yaml
vars_prompt Ansible
vars_prompt is a variable in Ansible that represents a list of variables to be prompted for when the playbook is run.
- vars_prompt:\n  - name: my_var\n    prompt: What is your value?
tasks Ansible
tasks is a keyword in Ansible that represents a list of tasks to be executed in a playbook.
- tasks:\n  - name: Example task\n    debug: msg: "Hello, world!"
handlers Ansible
handlers are tasks that are triggered by specific events or conditions in a playbook.
- handlers:\n  - name: Restart service\n    service: name=apache2 state=restarted
pre_tasks Ansible
pre_tasks are tasks that are executed before the main tasks in a playbook.
- pre_tasks:\n  - name: Create directory\n    file: path=/var/www/html state=directory
post_tasks Ansible
post_tasks are tasks that are executed after the main tasks in a playbook.
- post_tasks:\n  - name: Cleanup\n    file: path=/var/www/html state=absent
any_errors_fatal Ansible
any_errors_fatal is a flag in Ansible that controls whether an error in a task should cause the playbook to fail.
- any_errors_fatal: true
ignore_errors Ansible
ignore_errors is a flag in Ansible that controls whether errors in a task should be ignored and the playbook should continue execution.
- ignore_errors: true
max_fail_percentage Ansible
max_fail_percentage is a flag in Ansible that controls the maximum percentage of tasks that can fail before the playbook fails.
- max_fail_percentage: 50
run_once Ansible
run_once is a flag in Ansible that controls whether a task should be executed only once during the entire playbook run.
- run_once: true
serial Ansible
serial is a keyword in Ansible that controls the number of tasks that should be executed in parallel during the playbook run.
- serial: 1