Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local facts that return false are missing #430

Closed
zigford opened this issue Oct 25, 2022 · 2 comments · Fixed by #437
Closed

local facts that return false are missing #430

zigford opened this issue Oct 25, 2022 · 2 comments · Fixed by #437

Comments

@zigford
Copy link
Contributor

zigford commented Oct 25, 2022

SUMMARY

If a local fact file (.ps1) returns $false, then the fact is missing from ansible_facts

ISSUE TYPE
  • Bug Report
COMPONENT NAME

setup.ps1

ANSIBLE VERSION
ansible [core 2.13.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/harrisj/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/harrisj/.local/ansible-latest/lib/python3.10/site-packages/ansible
  ansible collection location = /home/harrisj/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/harrisj/.local/ansible-latest/bin/ansible
  python version = 3.10.8 (main, Oct 18 2022, 18:31:48) [GCC 11.3.0]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /home/harrisj/.local/ansible-latest/lib/python3.10/site-packages/ansible_collections
Collection      Version
--------------- -------
ansible.windows 1.11.1 
CONFIGURATION
ANSIBLE_NOCOWS(/etc/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
USE_PERSISTENT_CONNECTIONS(/etc/ansible/ansible.cfg) = True
OS / ENVIRONMENT

Windows Server 2016
Windows Server 2022
<Probably Server 2019, but not tested>

STEPS TO REPRODUCE
  1. Create a local facts directoy, eg C:\facts.d
  2. Add two .ps1 files to this directory
    false_fact.ps1 (contents are simply $false)
    true_fact.ps1 (contents are simply $true)
  3. Run the setup module with the fact_path argument
ansible winserver2022 -m setup -a "fact_path=C:/facts.d/"
EXPECTED RESULTS
winserver2022 | SUCCESS => {
    "ansible_facts": {
        "ansible_architecture": "64-bit",
        "ansible_architecture2": "x86_64",
        "ansible_bios_date": "06/25/2021",
        ...
        "ansible_true_fact": true,
        "ansible_false_fact": false,
        ...
        "module_setup": true
    },
    "changed": false
}
ACTUAL RESULTS
winserver2022 | SUCCESS => {
    "ansible_facts": {
        "ansible_architecture": "64-bit",
        "ansible_architecture2": "x86_64",
        "ansible_bios_date": "06/25/2021",
        ...
        "ansible_true_fact": true,
        ...
        "module_setup": true
    },
    "changed": false
}
@jborean93
Copy link
Collaborator

I believe this to be the culprit

. It's doing a truthy check rather than seeing if it is null or not. The code might nee some changes to handle this than the simplistic check it does right now.

@zigford
Copy link
Contributor Author

zigford commented Nov 2, 2022

I'll give this a go and see if I can raise my first PR for this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants