Professional Documents
Culture Documents
Ansible - Automation Coral
Ansible - Automation Coral
You can get a list of all the variables associated with the current host with the
help of hostvars and inventory_hostname variables.
---
- name: built-in variables
hosts: all
tasks:
- debug: var=hostvars[inventory_hostname]
Step 2:
Execute Playbook
Now execute the playbook and observe the output: ansible-playbook -i myhosts
test.yml
test.yml
Lets create a file touch afile.txt, prior to creating tasks
copy afile.txt from your control machine to host machine at /home/ubuntu/ location
as afile_copy.txt and
debug the above task to display the returned value
Execute your playbook (test.yml) and observe the output.
test.yml
=========
- name: Play1
hosts: all
sudo: yes
tasks:
- name: Copy a file
copy: src=afile.txt dest=/home/ubuntu/afile_copy.txt
You can skip the task of gathering facts through which of the following way?
gather_facts: no
Which option will give you error while accessing your complex variable?
{{ ansible_eth0[ipv4][address] }}
---
- name: Special Tags
hosts: all
sudo: yes
tasks:
- name: location 1
debug: msg="california"
- name: location 2
debug: msg="mumbai"
tags:
- tag1
- name: location 3
debug: msg="bangalore"
tags:
- tag2
- name: location 4
debug: msg="chennai"
tags:
---
- name: Special Tags
hosts: all
sudo: yes
tasks:
- name: location 1
debug: msg="california"
- name: location 2
debug: msg="mumbai"
tags:
- tag1
- name: location 3
debug: msg="bangalore"
tags:
- tag2
- name: location 4
debug: msg="chennai"
tags:
- always
You can run non tagged tasks using which magical word?
None of the options
Tagging allows you to run or skip certain part of Playbook. Can you run tasks that
are not tagged?
Yes
You can contribute your roles to Ansible community through GitHub Profile.
True
Which of the following can you use to delete your installed role?
remove
How do you define Variables in Command Line Interface while executing playbook?
--extra-vars
You can view the details of a role using which of the following?
ansible-galaxy info username.role