You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
update_fact fails to update a fact where a key in the referenced path contains a bracket. In particular, I'm working with a dictionary which has a key called [runners].
The update fails, claiming it cannot find a key in my_dict called [runners (note missing closing bracket).
ansible-playbook [core 2.14.3]
config file = None
configured module search path = ['/home/jarl/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/jarl/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[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'
Loading collection ansible.utils from /home/jarl/.ansible/collections/ansible_collections/ansible/utils
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: playbook.yml *********************************************************************************************
Positional arguments: playbook.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
forks: 5
1 plays in playbook.yml
PLAY [127.0.0.1] ***************************************************************************************************
TASK [Gathering Facts] *********************************************************************************************
task path: /home/jarl/playbook.yml:1
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jarl
<127.0.0.1> EXEC /bin/sh -c 'echo ~jarl && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/jarl/.ansible/tmp `"&& mkdir "` echo /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426 `" && echo ansible-tmp-1712307002.7893507-88412-109018197604426="` echo /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426 `" ) && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible/modules/setup.py
<127.0.0.1> PUT /home/jarl/.ansible/tmp/ansible-local-8840847f5qwh8/tmpvorlhftj TO /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426/ /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/jarl/.ansible/tmp/ansible-tmp-1712307002.7893507-88412-109018197604426/ > /dev/null 2>&1 && sleep 0'
ok: [127.0.0.1]
TASK [set fact] ****************************************************************************************************
task path: /home/jarl/playbook.yml:4
ok: [127.0.0.1] => {
"ansible_facts": {
"my_dict": {
"[runners]": "old value"
}
},
"changed": false
}
TASK [update fact] *************************************************************************************************
task path: /home/jarl/playbook.yml:8
The full traceback is:
Traceback (most recent call last):
File "/home/jarl/.ansible/collections/ansible_collections/ansible/utils/plugins/action/update_fact.py", line 121, in set_value
new_obj = obj[first]
~~~^^^^^^^
KeyError: '[runners'
fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"msg": "Error: the key '[runners' was not found in {'[runners]': 'old value'}."
}
PLAY RECAP *********************************************************************************************************
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The text was updated successfully, but these errors were encountered:
SUMMARY
update_fact fails to update a fact where a key in the referenced path contains a bracket. In particular, I'm working with a dictionary which has a key called
[runners]
.ISSUE TYPE
COMPONENT NAME
update_fact
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Debian 12 on both controller and target, python version as above
STEPS TO REPRODUCE
EXPECTED RESULTS
The fact should update the given path.
ACTUAL RESULTS
The update fails, claiming it cannot find a key in my_dict called
[runners
(note missing closing bracket).The text was updated successfully, but these errors were encountered: