Local fact not passed

22 views
Skip to first unread message

Jerry Steele

unread,
Oct 7, 2015, 5:56:10 PM10/7/15
to Ansible Project

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?

Vikas Kumar

unread,
Oct 8, 2015, 12:35:19 PM10/8/15
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages