I trigger ansible playbook my jenkins instance (2.452.1 version) and there are times (intermittent), I get error “Unable to parse /tmp/inventory***.ini as an inventory source”. During this error I see /tmp filesystem has sufficient space.
When other jobs are succeeding and also if the same job is retriggered against same target server it is succeeding.
In this case, what could be the reason for this error? How to prevent this error?
Hi!, I remember reading of a similar error regarding jenkins while doing some reaserch, (although I can’t seem to find the exact place I read it )
however, I remember the issue revolved around jenkins using unique environments per execution which can affect file availibility/permissions. The kicker was that It was subjective as no job is the same; so it’s almost unpredictable!
I don’t know of an official solution currently (I’ll try to get back to you) but off the top of my head, one solution could be to set a unique directory, but that opens doors to other permission problems.
First, those settings are unrelated to inventory, inventory is parsed at the controller, those are settings for remote module execution.
You should post the full warnings you got if you want help to narrow down the issue, just giving a partial message is not normally enough to diagnose any issue.
This is my exact error message from ansible playbook output,
[WARNING]: Unable to parse /tmp/inventory***.ini as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the
implicit localhost does not match ‘all’
I had mentioned a host “hostxxx” as ansible inventory in my jenkins build and had used “hosts: all” in my ansible playbook. Since the inventory is not accessible the playbook fails with above mentioned error.
Try running it with -vvv to see which inventory plugins tried to parse the inventory file.
It could be due to file permissions, for example:
$ ANSIBLE_INVENTORY_ENABLED=ini ansible-inventory -i /tmp/inventory.ini --list -vvv
ansible-inventory 2.9.10
config file = /home/shertel/ansible/ansible.cfg
configured module search path = ['/home/shertel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/shertel/ansible/lib/ansible
executable location = /home/shertel/ansible/bin/ansible-inventory
python version = 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]
Using /home/shertel/ansible/ansible.cfg as config file
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /tmp/inventory.ini as it did not pass its verify_file() method
[WARNING]: Unable to parse /tmp/inventory.ini as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}