Foreman ans ansible playbook

Hi,

I'm trying to use ansible with foreman but when tying to execute an ansible
playbook I get the following error:

fatal: [darla-hesley.vm.sapify.ch]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: write: Broken pipe\r\n", "unreachable": true}
to retry, use: --limit @/tmp/foreman-playbook-9bc23404-2d9b-4c65-ad58-04a799263dc1.retry

When running the playbook directly with ansible from the shell it works
even when doing a sudo -u foreman-proxy.

I'm not sure which user foreman is using to run playbooks, I've tried to
set the user in the foreman settings->ansible tab or even using the
parameter ansible_user on the host, neither did help.
I'm running the following version:
foreman : Version 1.15.2
katello: 3.4.2
foreman-tasks: 0.9.4
ansible 2.3.1.0

Thanks for any help
rgds,
Arsène

Hi Arsène! I'm quite new to Ansible and Foreman, so be patient with me.
Foreman use an user named 'foreman'. To make Ansible work in my environment
I've configured an SSH key and I've exported it in my two hosts: the
commands I've used are those, and I've executed them on the machine where
Foreman lives:

sudo -u foreman ssh-keygen  -N ''
sudo -u foreman ssh-copy-id root@my_first_host
sudo -u foreman ssh root@my_first_host
sudo -u foreman ssh-copy-id root@my_second_host
sudo -u foreman ssh root@my_second_host

I hope this will solve your problem.
An other way can be to configure a 'foreman' user in your hosts.
Best.
Pietro Gabelli

··· On Tuesday, August 1, 2017 at 10:58:13 AM UTC+2, Arsène Gschwind wrote: > > Hi, > > I'm trying to use ansible with foreman but when tying to execute an > ansible playbook I get the following error: > > fatal: [darla-hesley.vm.sapify.ch]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: write: Broken pipe\r\n", "unreachable": true} > to retry, use: --limit @/tmp/foreman-playbook-9bc23404-2d9b-4c65-ad58-04a799263dc1.retry > > When running the playbook directly with ansible from the shell it works > even when doing a sudo -u foreman-proxy. > > I'm not sure which user foreman is using to run playbooks, I've tried to > set the user in the foreman settings->ansible tab or even using the > parameter ansible_user on the host, neither did help. > I'm running the following version: > foreman : Version 1.15.2 > katello: 3.4.2 > foreman-tasks: 0.9.4 > ansible 2.3.1.0 > > Thanks for any help > rgds, > Arsène >

I think for me (RHEL) the user is foreman-proxy. I just use the same
hostkey as for roor, so no double import is needed.

··· On Tuesday, August 1, 2017 at 10:58:13 AM UTC+2, Arsène Gschwind wrote: > > Hi, > > I'm trying to use ansible with foreman but when tying to execute an > ansible playbook I get the following error: > > fatal: [darla-hesley.vm.sapify.ch]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: write: Broken pipe\r\n", "unreachable": true} > to retry, use: --limit @/tmp/foreman-playbook-9bc23404-2d9b-4c65-ad58-04a799263dc1.retry > > When running the playbook directly with ansible from the shell it works > even when doing a sudo -u foreman-proxy. > > I'm not sure which user foreman is using to run playbooks, I've tried to > set the user in the foreman settings->ansible tab or even using the > parameter ansible_user on the host, neither did help. > I'm running the following version: > foreman : Version 1.15.2 > katello: 3.4.2 > foreman-tasks: 0.9.4 > ansible 2.3.1.0 > > Thanks for any help > rgds, > Arsène >

Hello,

did you set under Foreman settings/ansible the right user?
I had the same issue till i set the right username.

Regards
Mobios

··· Am Dienstag, 1. August 2017 10:58:13 UTC+2 schrieb Arsène Gschwind:

Hi,

I’m trying to use ansible with foreman but when tying to execute an
ansible playbook I get the following error:

fatal: [darla-hesley.vm.sapify.ch]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: write: Broken pipe\r\n”, “unreachable”: true}
to retry, use: --limit @/tmp/foreman-playbook-9bc23404-2d9b-4c65-ad58-04a799263dc1.retry

When running the playbook directly with ansible from the shell it works
even when doing a sudo -u foreman-proxy.

I’m not sure which user foreman is using to run playbooks, I’ve tried to
set the user in the foreman settings->ansible tab or even using the
parameter ansible_user on the host, neither did help.
I’m running the following version:
foreman : Version 1.15.2
katello: 3.4.2
foreman-tasks: 0.9.4
ansible 2.3.1.0

Thanks for any help
rgds,
Arsène