summaryrefslogtreecommitdiff
path: root/utilities/helper/meta.py
blob: 76bcf73996efd37569a64bc394566153357c1759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
# -*- coding: utf-8 -*-

# (c) 2016, Ansible, a Red Hat company
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.

DOCUMENTATION = '''
module: meta
short_description: Execute Ansible 'actions'
version_added: "1.2"
description:
    - Meta tasks are a special kind of task which can influence Ansible internal execution or state. Prior to Ansible 2.0,
      the only meta option available was `flush_handlers`. As of 2.2, there are five meta tasks which can be used.
      Meta tasks can be used anywhere within your playbook.
options:
  free_form:
    description:
        - This module takes a free form command, as a string. There's not an actual option named "free form".  See the examples!
        - "C(flush_handlers) makes Ansible run any handler tasks which have thus far been notified. Ansible inserts these tasks internally at certain points to implicitly trigger handler runs (after pre/post tasks, the final role execution, and the main tasks section of your plays)."
        - "C(refresh_inventory) (added in 2.0) forces the reload of the inventory, which in the case of dynamic inventory scripts means they will be re-executed. This is mainly useful when additional hosts are created and users wish to use them instead of using the `add_host` module."
        - "C(noop) (added in 2.0) This literally does 'nothing'. It is mainly used internally and not recommended for general use."
        - "C(clear_facts) (added in 2.1) causes the gathered facts for the hosts specified in the play's list of hosts to be cleared, including the fact cache."
        - "C(clear_host_errors) (added in 2.1) clears the failed state (if any) from hosts specified in the play's list of hosts."
        - "C(end_play) (added in 2.2) causes the play to end without failing the host."
    choices: ['noop', 'flush_handlers', 'refresh_inventory', 'clear_facts', 'clear_host_errors', 'end_play']
    required: true
    default: null
notes:
    - meta is not really a module nor action_plugin as such it cannot be overwritten.
author:
    - "Ansible Core Team"
'''

EXAMPLES = '''
# force all notified handlers to run at this point, not waiting for normal sync points
- template:
    src: new.j2
    dest: /etc/config.txt
  notify: myhandler
- meta: flush_handlers

# 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 instaces exist in inventory
  meta: refresh_inventory

- name: Clear gathered facts from all currently targeted hosts
  meta: clear_facts

# bring host back to play after failure
- copy:
    src: file
    dest: /etc/file
  remote_user: imightnothavepermission

- meta: clear_host_errors
'''