mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
facter_facts: new module (#7356)
* facter: add option to return facts instead of output variables * Update plugins/modules/facter.py Co-authored-by: Felix Fontein <felix@fontein.de> * add output doc * add changelog frag * reversed facter.py, created facter_facts.py * remove chglog fragment for new module * add BOTMETA entry * adjust facters code to facters_fact, add unit test * Update plugins/modules/facter_facts.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/facter_facts.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/facter_facts.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
932b657ab8
commit
bb59962061
4 changed files with 149 additions and 0 deletions
16
tests/unit/plugins/modules/test_facter_facts.py
Normal file
16
tests/unit/plugins/modules/test_facter_facts.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible_collections.community.general.plugins.modules import facter_facts
|
||||
from .helper import Helper
|
||||
|
||||
|
||||
helper = Helper.from_file(facter_facts.main, "tests/unit/plugins/modules/test_facter_facts.yaml")
|
||||
patch_bin = helper.cmd_fixture
|
||||
test_module = helper.test_module
|
40
tests/unit/plugins/modules/test_facter_facts.yaml
Normal file
40
tests/unit/plugins/modules/test_facter_facts.yaml
Normal file
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
---
|
||||
- id: simple run
|
||||
output:
|
||||
ansible_facts:
|
||||
facter:
|
||||
a: 1
|
||||
b: 2
|
||||
c: 3
|
||||
run_command_calls:
|
||||
- command: [/testbin/facter, --json]
|
||||
environ: &env-def {check_rc: true}
|
||||
rc: 0
|
||||
out: >
|
||||
{ "a": 1, "b": 2, "c": 3 }
|
||||
err: ""
|
||||
- id: with args
|
||||
input:
|
||||
arguments:
|
||||
- -p
|
||||
- system_uptime
|
||||
- timezone
|
||||
- is_virtual
|
||||
output:
|
||||
ansible_facts:
|
||||
facter:
|
||||
a: 1
|
||||
b: 2
|
||||
c: 3
|
||||
run_command_calls:
|
||||
- command: [/testbin/facter, --json, -p, system_uptime, timezone, is_virtual]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: >
|
||||
{ "a": 1, "b": 2, "c": 3 }
|
||||
err: ""
|
Loading…
Add table
Add a link
Reference in a new issue