Ansible facter - not showing facter in bash script

185 Views Asked by At

I created a bash script that has facter commands The results of this facter command is stored in a variable.

  like this:

  HOST=$(facter hostname)
  IP=$(facter networking.ip)
  

When I executed this script from an ansible playbook, I got this error:

"rc": 0,
"start": "2020-11-13 20:18:05.501085",
"stderr": "/sharedFiles/ls_script: line 11: facter: command not found\n/sharedFiles/: line 12: facter: command not found",
"stderr_lines": [

    "/sharedFiles/ls_script: line 11: facter: command not found",
    "/sharedFiles/ls_script: line 12: facter: command not found"

I have facter installed in the target host and in the box that I'm running ansible. If I execute this script locally I got the facter information.

1

There are 1 best solutions below

0
Diego Torres Milano On

Try using the absolute path to facter

HOST=$(/path/to/facter hostname)
IP=$(/path/to/facter networking.ip)

you can find it with

which facter