Ansible variable with dot in name

Given the next variable outoput, we want to get the value for user_namespace.enable

- debug:
    msg: "{{ ansible_cmdline }}"

Give us:

"msg": {
    "BOOT_IMAGE": "/vmlinuz-...",
    "LANG": "...",
    "crashkernel": "...",
    "namespace.unpriv_enable": "...",
    "quiet": ...,
    "rd.lvm.lv": "...",
    "rhgb": ...,
    "ro": ...,
    "root": "...",
    "user_namespace.enable": "1"
}

To access it we need to do:

- debug:
    msg: "{{ ansible_cmdline['user_namespace.enable'] }}"

References:

  • 1 Stackoverflow solution
  • 2 Ansible Documentation
Previous
Next