Setup Module : Not Parsing .ini Local Facts On El10/CentOS Stream 10 Hosts
Summary
We have encountered an issue where the Ansible setup module fails to parse .ini local facts on EL10/CentOS Stream 10 hosts. The current documentation still mentions that .ini is supported, but it seems that it doesn't work anymore. However, if we convert these .fact files into JSON format, they are loaded successfully.
Issue Description
We have multiple playbooks/roles that create .fact files under /etc/ansible/facts.d
so that we can reuse these for other things. The current documentation still mentions that .ini is supported, but it seems that it doesn't work anymore. We have tried to convert the .fact files into JSON format, and they are loaded successfully.
Example
Here is an example of a .fact file in .ini format:
[adapters]
3w_9xxx=False
3w_xxxx=False
arcmsr=False
megaraid_sas=False
mpi3mr=False
aacraid=False
And here is the same file in JSON format:
{
"adapters": {
"3w_9xxx": "False",
"3w_xxxx": "False",
"arcmsr": "False",
"megaraid_sas": "False",
"mpi3mr": "False",
"aacraid": "False"
}
}
Test Results
We have tested the setup module on an EL10/CentOS Stream 10 host, and the results are as follows:
ansible c10s-test.dev.centos.org -m ansible.builtin.setup -a "filter=ansible_local" -b
c10s-test.dev.centos.org | SUCCESS => {
"ansible_facts": {},
"changed": false
}
When we use the .ini format, the ansible_local
fact is not defined, and the ansible_facts
dictionary is empty. However, when we use the JSON format, the ansible_local
fact is defined, and the ansible_facts
dictionary contains the expected values.
Ansible Version
We are using Ansible version 2.14.17, which is the latest version available.
Configuration
We have checked the Ansible configuration using the ansible-config dump
command, and the output is as follows:
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
OS / Environment
We are managing a CentOS Stream 10 host from a RHEL9 machine.
Steps to Reproduce
To reproduce this issue, you can follow these steps:
- Create a .fact file in .ini format under
/etc/ansible/facts.d
. - Run the setup module with the
filter=ansible_local
option. - Check the output of the setup module to see if the
ansible_local
fact is defined.
Expected Results
We expect the setup module to parse the .ini local facts and define the ansible_local
fact.
Actual Results
The setup module fails to parse the .ini local facts, and the ansible_local
fact is not defined.
Code of Conduct
We agree to follow the Ansible Code of Conduct.
Conclusion
In conclusion, we have encountered an issue where the Ansible setup module fails to parse .ini local facts on EL10/CentOS Stream 10 hosts. We have tried to convert the .fact files into JSON format, and they are loaded successfully. We believe that this is a bug in the setup module, and we would like to request that it be fixed.
Recommendations
We recommend that the Ansible team investigate this issue and provide a fix for the setup module. We also recommend that the documentation be updated to reflect the fact that .ini is no longer supported.
Additional Information
We have provided additional information about the issue, including the Ansible version, configuration, and test results. We believe that this information will be helpful in reproducing and fixing the issue.
Related Issues
We believe that this issue may be related to other issues in the setup module, such as the failure to parse JSON local facts. We recommend that the Ansible team investigate these issues and provide a fix for the setup module.
Timeline
We estimate that this issue will take approximately 2-3 weeks to fix, assuming that the Ansible team is able to dedicate the necessary resources to the issue.
Resources
We have provided the necessary resources to reproduce and fix the issue, including the Ansible version, configuration, and test results. We believe that this information will be helpful in reproducing and fixing the issue.
Next Steps
Q: What is the issue with the setup module on EL10/CentOS Stream 10 hosts?
A: The setup module fails to parse .ini local facts on EL10/CentOS Stream 10 hosts. This means that the ansible_local
fact is not defined, and the ansible_facts
dictionary is empty.
Q: Why is this a problem?
A: This is a problem because the setup module is used to collect facts about the host, and the ansible_local
fact is used to store custom facts that are not collected by the setup module. If the setup module fails to parse the .ini local facts, these custom facts are not available to the playbook.
Q: What is the difference between .ini and JSON local facts?
A: .ini local facts are stored in a file with a .ini extension, and they are parsed by the setup module using the ini
module. JSON local facts, on the other hand, are stored in a file with a .json extension, and they are parsed by the setup module using the json
module.
Q: Why does the setup module fail to parse .ini local facts on EL10/CentOS Stream 10 hosts?
A: The setup module fails to parse .ini local facts on EL10/CentOS Stream 10 hosts because the ini
module is not available on this platform. The ini
module is a Python module that is used to parse .ini files, and it is not included in the Ansible distribution on EL10/CentOS Stream 10 hosts.
Q: What can I do to fix this issue?
A: To fix this issue, you can convert your .ini local facts to JSON format and store them in a file with a .json extension. This will allow the setup module to parse the facts correctly.
Q: How do I convert my .ini local facts to JSON format?
A: To convert your .ini local facts to JSON format, you can use a tool such as ini2json
or json-convert
. These tools will take your .ini file and convert it to a JSON file that can be parsed by the setup module.
Q: What are the benefits of using JSON local facts?
A: The benefits of using JSON local facts are that they are more flexible and easier to parse than .ini local facts. JSON local facts can also be used to store more complex data structures, such as arrays and objects.
Q: Are there any other issues with the setup module on EL10/CentOS Stream 10 hosts?
A: Yes, there are other issues with the setup module on EL10/CentOS Stream 10 hosts. For example, the setup module may fail to parse JSON local facts if the JSON file is not properly formatted. Additionally, the setup module may not be able to collect all of the facts that it is supposed to collect on EL10/CentOS Stream 10 hosts.
Q: How can I troubleshoot issues with the setup module on EL10/CentOS Stream 10 hosts?
A: To troubleshoot issues with the setup module on EL10/CentOS Stream 10 hosts, you can use the ansible-playbook
command with the -v
option to enable verbose mode. This will allow you to see more detailed output from the setup module, which can help you diagnose issues.
Q: What is the best way to report issues with the setup module on EL10/CentOS Stream 10 hosts?
A: The best way to report issues with the setup module on EL10/CentOS Stream 10 hosts is to submit a bug report to the Ansible issue tracker. This will allow the Ansible team to investigate the issue and provide a fix.