[192.0.2.10] TASK: install package (debug)> p task
TASK: install package
[192.0.2.10] TASK: install package (debug)> p task.args
{u'name': u'{{ pkg_name }}'}
[192.0.2.10] TASK: install package (debug)> p task_vars
{u'ansible_all_ipv4_addresses': [u'192.0.2.10'],
u'ansible_architecture': u'x86_64',
...
}
[192.0.2.10] TASK: install package (debug)> p task_vars['pkg_name']
u'bash'
[192.0.2.10] TASK: install package (debug)> p host
192.0.2.10
[192.0.2.10] TASK: install package (debug)> p result._result
{'_ansible_no_log': False,
'changed': False,
u'failed': True,
...
u'msg': u"No package matching 'not_exist' is available"}
[192.0.2.10] TASK: install package (debug)> p task.args
{u'name': u'{{ pkg_name }}'}
[192.0.2.10] TASK: install package (debug)> task.args['name'] = 'bash'
[192.0.2.10] TASK: install package (debug)> p task.args
{u'name': 'bash'}
[192.0.2.10] TASK: install package (debug)> redo
- name: my file upload
copy:
src: file_in_files_folder_of_my_role.tar.gz # placing under files folder is the relevant part here
dest: /opt/or_somewhere_else_on_server.tar.gz
mode: '0444' # optional
become: yes # optional
- name: create a directory
file:
path: /opt/my_path
state: directory
mode: 0755
owner: <user>
group: <user_group>
become: yes # optional
---
- name: Gather facts from all hosts
hosts: all
gather_facts: true
- name: Do something sequentially
hosts: all
gather_facts: false
serial: 1
roles:
# in this role the facts of all hosts will be available
# e.g. all ips, hostnames etc.
- role: my_sequential_role # e.g. rke2 install
{% for host in groups['all'] %}
{% if hostvars[host]['ansible_fqdn'] is defined %}
"{{ hostvars[host]['ansible_fqdn'] }}"
{% endif %}
{% endfor %}
Intended for the use in a debugger session that was started with strategy=debug
or debugger: on_failed
etc.
This is great to further process the dump to json content.
See ansible_debugger_json_converter.py
for more on that.
This will not be proper json formatted filecontent.
with open('file.json', 'w') as f: f.write(str(task_vars)); f.close();
This will process the content and remove the raw file right away.
with open('file.json', 'w') as f: f.write(str(task_vars)); f.close(); os.system('python3 ansible_debugger_json_converter.py -i file.json'); os.remove('file.json');