Parsing Password.

unable to parse password. if there is number/int followed “#”
eg.
test.ini
10.10.10.10 ansible_user=admin ansible_password=‘0#d1234’

test.yml

  • name: Print password from inventory
    hosts: all
    gather_facts: false

    tasks:

    • name: Show ansible_password
      ansible.builtin.debug:
      msg: “Password = {{ ansible_password }}”

output:
TASK [Show ansible_password] *******************************************************************************************************************************
ok: [10.10.10.10] => {
“msg”: “Password = 0”

This is a limitation of the ini format, # is considered a comment and you cannot really override that, use YAML instead, also I recommend using a vault for the password.

Brian’s suggestion to use YAML is the simplest fix. You can put the connection variables in a YAML inventory or a host_vars file, where quoting the value keeps # as part of the string:

ansible_host: 10.10.10.10
ansible_user: admin
ansible_password: "{{ vault_ansible_password }}"

Store vault_ansible_password in an Ansible Vault encrypted vars file. That keeps the password out of plain-text inventory and playbook files.