mirror of https://github.com/ansible/ansible.git
This reverts commit 95655fae5c
.
pull/40116/head
parent
abb353290c
commit
38ab36a625
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (c) 2017 Ansible Project
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'core'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: gather_facts
|
|
||||||
version_added: 2.6
|
|
||||||
short_description: Gathers facts about remote hosts
|
|
||||||
description:
|
|
||||||
- This module takes care of executing the configured facts modules, the default is to use the M(setup) module.
|
|
||||||
- This module is automatically called by playbooks to gather useful variables about remote hosts that can be used in playbooks.
|
|
||||||
- It can also be executed directly by C(/usr/bin/ansible) to check what variables are available to a host.
|
|
||||||
- Ansible provides many I(facts) about the system, automatically.
|
|
||||||
notes:
|
|
||||||
- This module is mostly a wrapper around other fact gathering modules.
|
|
||||||
- Options passed to this module must be supported by all the underlying fact modules configured.
|
|
||||||
author:
|
|
||||||
- "Ansible Core Team"
|
|
||||||
'''
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
# depends on the fact module called
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
# Display facts from all hosts and store them indexed by I(hostname) at C(/tmp/facts).
|
|
||||||
# ansible all -m gather_facts --tree /tmp/facts
|
|
||||||
"""
|
|
@ -1,41 +0,0 @@
|
|||||||
# Copyright (c) 2017 Ansible Project
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
from collections import MutableMapping
|
|
||||||
|
|
||||||
from ansible import constants as C
|
|
||||||
from ansible.plugins.action import ActionBase
|
|
||||||
|
|
||||||
|
|
||||||
class ActionModule(ActionBase):
|
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=None):
|
|
||||||
''' handler for package operations '''
|
|
||||||
|
|
||||||
self._supports_check_mode = True
|
|
||||||
self._supports_async = True
|
|
||||||
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
|
||||||
result['ansible_facts'] = {}
|
|
||||||
|
|
||||||
for fact_module in C.config.get_config_value('FACTS_MODULES', variables=task_vars):
|
|
||||||
|
|
||||||
mod_args = task_vars.get('ansible_facts_modules', {}).get(fact_module, {})
|
|
||||||
if isinstance(mod_args, MutableMapping):
|
|
||||||
mod_args.update(self._task.args.copy())
|
|
||||||
else:
|
|
||||||
mod_args = self._task.args.copy()
|
|
||||||
|
|
||||||
if fact_module != 'setup':
|
|
||||||
del mod_args['gather_subset']
|
|
||||||
|
|
||||||
self._display.vvvv("Running %s" % fact_module)
|
|
||||||
result.update(self._execute_module(module_name=fact_module, module_args=mod_args, task_vars=task_vars, wrap_async=self._task.async_val))
|
|
||||||
|
|
||||||
# tell executor facts were gathered
|
|
||||||
result['ansible_facts']['_ansible_facts_gathered'] = True
|
|
||||||
|
|
||||||
return result
|
|
@ -1 +0,0 @@
|
|||||||
posix/ci/group3
|
|
@ -1,14 +0,0 @@
|
|||||||
- hosts: testhost
|
|
||||||
tasks:
|
|
||||||
- name: ensure facts have not been collected
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts is undefined or not 'fqdn' in ansible_facts
|
|
||||||
|
|
||||||
- hosts: testhost
|
|
||||||
gather_facts: True
|
|
||||||
tasks:
|
|
||||||
- name: ensure facts have been collected
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
|
@ -1,23 +0,0 @@
|
|||||||
- hosts: testhost
|
|
||||||
tasks:
|
|
||||||
- name: check that facts were gathered but no local facts exist
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
|
||||||
- not 'uuid' in ansible_local
|
|
||||||
- name: create 'local facts' for next gathering
|
|
||||||
copy:
|
|
||||||
src: uuid.fact
|
|
||||||
dest: /etc/ansible/facts.d/
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- hosts: testhost
|
|
||||||
tasks:
|
|
||||||
- name: ensure facts are gathered and includes the new 'local facts' created above
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
|
||||||
- "'uuid' in ansible_local"
|
|
||||||
|
|
||||||
- name: cleanup 'local facts' from target
|
|
||||||
file: path=/etc/ansible/facts.d/uuid.fact state=absent
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
ANSIBLE_GATHERING=smart ansible-playbook smart.yml --flush-cache -i ../../inventory -v "$@"
|
|
||||||
ANSIBLE_GATHERING=implicit ansible-playbook implicit.yml --flush-cache -i ../../inventory -v "$@"
|
|
||||||
ANSIBLE_GATHERING=explicit ansible-playbook explicit.yml --flush-cache -i ../../inventory -v "$@"
|
|
@ -1,23 +0,0 @@
|
|||||||
- hosts: testhost
|
|
||||||
tasks:
|
|
||||||
- name: ensure facts are gathered but no local exists
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
|
||||||
- not 'uuid' in ansible_local
|
|
||||||
- name: create local facts for latter test
|
|
||||||
copy:
|
|
||||||
src: uuid.fact
|
|
||||||
dest: /etc/ansible/facts.d/
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- hosts: testhost
|
|
||||||
tasks:
|
|
||||||
- name: ensure we still have facts, but didnt pickup new local ones
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
|
||||||
- not 'uuid' in ansible_local
|
|
||||||
|
|
||||||
- name: remove local facts file
|
|
||||||
file: path=/etc/ansible/facts.d/uuid.fact state=absent
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
|
|
||||||
# return a random string
|
|
||||||
print(json.dumps(str(uuid.uuid4())))
|
|
Loading…
Reference in New Issue