Creating Playbooks Flashcards
How does each playbook start?
- name: Name of the Playbook
a descriptive label that helps to understand what the playbook is designed to do
How to specify that playbook should be executed on all hosts included in the hosts file?
hosts: ALL
How to specify that tasks will be executed on the local machine, not on the remote hosts?
connection: local
common when interacting with network devices using APIs
How to specify that the script should not gather any information about the host during the script execution?
gather_facts: False
can speed up playbook execution
How to specify the path to the Python interpreter that Ansible should use?
vars: ansible_python_interpreter: /opt/homebrew/bin/python3.11
How to specify that paloaltonetworks.panos collections should be used?
collections: - paloaltonetworks.panos
What defines actions that will be executed in a playbook? How are the actions executed?
` tasks:`
each task is a step in the playbook, and will be executed in order
How to load the variables?
tasks: - name: Load Variable include_vars: vars.yml
create it as a task with the include_vars module
In order to avoid potential errors, when should be the variables file loaded?
as the first task
If collection paloaltonetworks.panos
is included in a playbook, how should be the module for security rules defined in tasks, instead of paloaltonetworks.panos.panos_security_rule
?
panos_security_rule:
Ansible looks in paloaltonetworks.panos collection for the modules that are referenced in the tasks
How to ensure that IP addresses of hosts are used in a playbook from the inventory file?
provider: ip_address: "{{ inventory_hostname }}"
Where can be the provider
dictionary used?
either in file with variables or directly in the playbook
How do you define the hosts file that includes the IP addresses the playbook connects to?
[ALL] 10.200.1.4
How to run an Ansible playbook?
ansible-playbook {playbook}.yml -i {inventory_file}