Local fact not passed

Hello,

Ansible_version: 1.9.2 stable

I have a custom fact, generated via bash:


#!/bin/bash 
MYSQL_PW=$(cat /etc/psa/.psa.shadow)

cat << EOF
{
 "pw":"$MYSQL_PW"
}
EOF

When I run this on the command line, it gives the expected output:


{
"pw":"$AES-128-xxxx$xxxxxxxxxxxxxxxxxxx$xxxxxxxxxxxxxxxxxxx"
}

(note: the above is obfuscated)

However when I use the setup module, the value of “pw” is empty:


"ansible_local": {
     "mysql": {
        "pw": ""
       }
}

,

I tested this by catting another file, and this gave the expected string when ran standalone and via the setup module:

`

MYSQL_PW=$(cat /usr/local/psa/version)

`

gives

`

“ansible_local”: {
“mysql”: {
“pw”: “12.0.18 Ubuntu 14.04 1200150817.13”
}
}
`

``

which is what we expect. I think the error is due to the presence of “$” in the output of the first fact-generating script, but I’m not sure how to get round this.

Does anyone have any ideas?

Hi Jerry,

Did you reloaded the local facts in your tasks before trying to use the facts.

`

  • local_action: setup filter=ansible_local
    `

Regards,
Vikas