ansible.builtin.meta – Execute Ansible ‘actions’
ansible.builtin.meta – Execute Ansible ‘actions’
Note
This module is part of ansible-base
and included in all Ansible installations. In most cases, you can use the short module name meta even without specifying the collections:
keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
New in version 1.2: of ansible.builtin
Synopsis
- Meta tasks are a special kind of task which can influence Ansible internal execution or state.
- Meta tasks can be used anywhere within your playbook.
- This module is also supported for Windows targets.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
free_form string / required |
|
This module takes a free form command, as a string. There is not an actual option named "free form". See the examples!
|
Notes
Note
meta
is not really a module nor action_plugin as such it cannot be overwritten.clear_facts
will remove the persistent facts from ansible.builtin.set_fact usingcacheable=True
, but not the current host variable it creates for the current run.- Looping on meta tasks is not supported.
- Skipping
meta
tasks with tags is not supported before Ansible 2.11. - This module is also supported for Windows targets.
See Also
See also
- ansible.builtin.assert
- The official documentation on the ansible.builtin.assert module.
- ansible.builtin.fail
- The official documentation on the ansible.builtin.fail module.
Examples
# Example showing flushing handlers on demand, not at end of play
- template:
src: new.j2
dest: /etc/config.txt
notify: myhandler
- name: Force all notified handlers to run at this point, not waiting for normal sync points
meta: flush_handlers
# Example showing how to refresh inventory during play
- name: Reload inventory, useful with dynamic inventories when play makes changes to the existing hosts
cloud_guest: # this is fake module
name: newhost
state: present
- name: Refresh inventory to ensure new instances exist in inventory
meta: refresh_inventory
# Example showing how to clear all existing facts of targetted hosts
- name: Clear gathered facts from all currently targeted hosts
meta: clear_facts
# Example showing how to continue using a failed target
- name: Bring host back to play after failure
copy:
src: file
dest: /etc/file
remote_user: imightnothavepermission
- meta: clear_host_errors
# Example showing how to reset an existing connection
- user:
name: '{{ ansible_user }}'
groups: input
- name: Reset ssh connection to allow user changes to affect 'current login user'
meta: reset_connection
# Example showing how to end the play for specific targets
- name: End the play for hosts that run CentOS 6
meta: end_host
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version == '6'
Authors
- Ansible Core Team
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/builtin/meta_module.html