| 1 |
# This file is part of Ansible |
| 2 |
# |
| 3 |
# Ansible is free software: you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation, either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# Ansible is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
|
| 16 |
from __future__ import annotations |
| 17 |
|
| 18 |
import os |
| 19 |
import typing as t |
| 20 |
|
| 21 |
from ansible.module_utils._internal import _no_six |
| 22 |
from ansible.module_utils.facts.collector import BaseFactCollector |
| 23 |
|
| 24 |
|
| 25 |
class EnvFactCollector(BaseFactCollector): |
| 26 |
name = 'env' |
| 27 |
_fact_ids = set() # type: t.Set[str] |
| 28 |
|
| 29 |
def collect(self, module=None, collected_facts=None): |
| 30 |
env_facts = {} |
| 31 |
env_facts['env'] = {} |
| 32 |
|
| 33 |
for k, v in os.environ.items(): |
| 34 |
env_facts['env'][k] = v |
| 35 |
|
| 36 |
return env_facts |
| 37 |
|
| 38 |
|
| 39 |
def __getattr__(importable_name): |
| 40 |
return _no_six.deprecate(importable_name, __name__, "iteritems") |