I am using ansible.builtin.slurp to do this. Here is the relevant part of my Ansible role:
- name: Load config slurp: src: "/etc/mlnx_snap/mlnx_snap.json" register: imported_config - name: Debug debug: var: imported_config
I expect to have debug print my file, however, something different happens. Here's the file content:
root@ratchet01-snic:~# cat /etc/mlnx_snap/mlnx_snap.json { "ctrl": { "sqes": 0x6, "cqes": 0x4, "cq_period": 3, "cq_max_count": 6, "nr_io_queues": 32, "mn": "Mellanox BlueField NVMe SNAP Controller", "sn": "MNC12", "mdts": 4, "oncs": 0, "offload": false, "max_namespaces": 0, "quirks": 0x0 }, "backends": [ { "type": "spdk_bdev", "paths": [{}] } ] }
And here is what the debug output looks like:
Debug... retchet01-snic.mtr.labs.mlnx ok: { "changed": false, "imported_config": { "changed": false, "content": "LyoKICogcHJ...CiAgICB9IF0KfQo=", "encoding": "base64", "failed": false, "source": "/etc/mlnx_snap/mlnx_snap.json" } }
Content is actually thousands of characters long, I just shortened it for readability.
Imagine I have a following task further in this role:
- name: Do x module_name: var_name: value when: imported_config.ctrl.quirks >= 0
How do I correctly import the JSON file so that such a task could work? What am I doing wrong?
https://stackoverflow.com/questions/67237737/how-to-import-json-file-from-a-remote-host-into-ansible-variable April 24, 2021 at 07:01AM
没有评论:
发表评论