I’ve had a lot of trouble getting The Foreman to do a Puppet run when I click on the gui button. Finally figured it out and wanted to document it in case someone else is struggling with this issue too.
# whether to use sudo before the ssh command
# the command which will be sent to the host
:puppetssh_command: /usr/bin/sudo /usr/bin/puppet agent --onetime --no-daemonize --no-usecacheonfailure --ignorecache
# wait for the command to finish (and capture exit code), or detach process and return 0
# Note: enabling this option causes the Foreman web UI to be blocked when executing puppetrun,
# with timeout from the Browser and/or Foreman's REST client after 60 seconds.
# With which user should the proxy connect
# Which user to invoke sudo as to run puppet commands
The biggest issue I finally realized was that when foreman tried to ssh into the boxes, it was doing a key check and trying to add it to the known_hosts file and would silently fail. After reading a few more blogs I finally found that I should just disable the check:
Since my environment is closed off I am not too worried about checking keys. To allow certain IP or Hostnames, just change the * to ip or hostname.