Hello community, I have a problem getting the Ansible plugin to work from the Foreman GUI.
The system is CentOS Linux release 7.4.1708 (Core).
I installed Foreman 1.17 by using the foreman-installer. The installation options were all related to Ansible and to the Remote Execution Plugin. I will provide the full foreman-installer command if needed.
Puppet version is 5.5.1.
Here is how I configured everything in the Foreman GUI:
The “About” page in the Foreman GUI says that all the plugins have been installed: TFTP, Puppet, Puppet CA, Logs, Dynflow, Ansible, SSH.
Whenever I try to do a “Schedule Remote Job” from the Foreman GUI and try to execute a command (example: whoami) on some of my hosts the Job Task says the following error:
Error initializing command: Net::SSH::AuthenticationFailed - Authentication failed for user firstname.lastname@example.org.
I added the following 3 lines to /etc/environment and /etc/sysconfig/foreman:
The /etc/ansible/ansible.cfg, /etc/foreman-proxy/ansible.cfg and /usr/share/foreman-proxy/.ansible.cfg all look the same:
[defaults] callback_whitelist = foreman local_tmp = /tmp host_key_checking = False [callback_foreman] url = https://foreman-ansible.mydomain ssl_cert = /etc/puppetlabs/puppet/ssl/certs/foreman-ansible.mydomain.pem ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/foreman-ansible.mydomain.pem verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem
For the SSH keys I did the following:
root# ssh-keygen (Generated an id_rsa and id_rsa.pub key pairs without a passphrase) root# cd /root/.ssh/ root# chmod 600 id_rsa* root# cp id_rsa ~foreman-proxy/.ssh/id_rsa_foreman_proxy root# cp id_rsa.pub ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub root# cd ~foreman-proxy/.ssh/ root# chown foreman-proxy:foreman-proxy id_rsa_foreman_proxy* root# ssh-copy-id -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub email@example.com root# ssh-copy-id -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub firstname.lastname@example.org
I am able to login without a password from the foreman-ansible server to the target hosts (host1 and host2) from the command line (ssh email@example.com and ssh firstname.lastname@example.org). I am also able to run ansible from the command line as I added my hosts to /etc/ansible/hosts and /etc/foreman-proxy/hosts (ansible host1.mydomain -m command -a “uname -a”).
However, when I try to do it from the Foreman GUI it fails. with the error mentioned above.
Any suggestions on what I can do?