Project

General

Profile

Bug #31753

can't execute ansible on Debian

Added by Evgeni Golov 10 months ago. Updated 10 months ago.


Description

(filing this against foreman_ansible, but in reality there will be more than one component involved)

Currently, when you install Foreman with --enable-foreman-plugin-ansible --enable-foreman-proxy-plugin-ansible this does not result in a working Foreman Ansible setup.

When trying to run an Ansible job, the first thing you'll encounter is uninitialized constant ForemanAnsibleCore (see https://community.theforeman.org/t/cant-get-foreman-ansible-to-work/21751).
That is, at large, because we don't install foreman-ansible-core by default right now.

Installing it by hand yields:

dpkg: error processing archive /tmp/apt-dpkg-install-ARihr2/5-ruby-foreman-ansible-core_4.0.0-buster+scratchbuild20210118132237_all.deb (--unpack):
 trying to overwrite '/usr/bin/json_inventory.sh', which is also in package ruby-smart-proxy-ansible 3.0.0-2
Errors were encountered while processing:
 /tmp/apt-dpkg-install-ARihr2/5-ruby-foreman-ansible-core_4.0.0-buster+scratchbuild20210118132237_all.deb

I am not exactly sure who should own that file, but not both (funnily, core/runner/command_creator.rb does genetate the path as /usr/lib/ruby/bin/json_inventory.sh, so it wouldn't find it anyways).

After forcing dpkg to overwrite that file (for testing only, of course), the gem was still not loaded until Adam hasn't fixed the deployment in https://github.com/theforeman/foreman-packaging/pull/6165 (merged just now into nightly).

Having that fixed, I was able to schedule an Ansible job in Foreman, but it failed with ERROR! Unexpected Exception, this is probably a bug: No module named 'psutil'. I think that's because Debian ships Ansible with Python3 already, while Ansible Runner doesn't know that and only depends on python-psutil. Installing python3-psutil fixes this.

However, the next run would still fail for me: fatal: [debian10-foreman-nightly.yatsu.example.com]: FAILED! => {"msg": "Unable to create local directories(/usr/share/foreman-proxy/.ansible/cp): [Errno 13] Permission denied: b'/usr/share/foreman-proxy/.ansible'"} -- I think it's not honouring our ansible.cfg correctly, which tells it to use /tmp for this, but didn't dive further yet.

and fixing that, you'll see:

fatal: [debian10-foreman-nightly.yatsu.example.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Could not create directory '/usr/share/foreman-proxy/.ssh'.\r\nFailed to add the host to the list of known hosts (/usr/share/foreman-proxy/.ssh/known_hosts).\r\nno such identity: /usr/share/foreman-proxy/.ssh/id_rsa_foreman_proxy: No such file or directory\r\nroot@debian10-foreman-nightly.yatsu.example.com: Permission denied (publickey).", "unreachable": true}


Related issues

Related to Ansible - Bug #24879: ruby-foreman-ansible-core '/usr/lib/ruby/vendor_ruby/foreman_ansible_core.rb' conflicts with ruby-smart-proxy-ansibleResolved

History

#1 Updated by Ewoud Kohl van Wijngaarden 10 months ago

  • Related to Bug #24879: ruby-foreman-ansible-core '/usr/lib/ruby/vendor_ruby/foreman_ansible_core.rb' conflicts with ruby-smart-proxy-ansible added

#2 Updated by Evgeni Golov 10 months ago

tha last error is due to it trying to place the "controlpersist" files into the cp folder

on RPM based we have

# ls -alhd /usr/share/foreman-proxy/.ansible lrwxrwxrwx. 1 root root 30 Nov 23 2019 /usr/share/foreman-proxy/.ansible -> /var/lib/foreman-proxy/ansible

on deb we dont…

#3 Updated by Evgeni Golov 10 months ago

  • Pull request https://github.com/theforeman/foreman-packaging/pull/6235, https://github.com/theforeman/foreman-packaging/pull/6165 added

#4 Updated by Evgeni Golov 10 months ago

  • Pull request https://github.com/theforeman/smart_proxy_ansible/pull/27 added

#5 Updated by Evgeni Golov 10 months ago

  • Description updated (diff)
  • Pull request https://github.com/theforeman/foreman-packaging/pull/6297 added

#6 Updated by Evgeni Golov 10 months ago

with the linked PRs merged, I can run ansible playbooks in nightly when I do the following:
  1. install python3-psutil manually
  2. install Foreman with ansible using foreman-installer --enable-foreman-plugin-ansible --enable-foreman-proxy-plugin-ansible --enable-foreman-proxy-plugin-remote-execution-ssh, REX-SSH is needed for the setup of the ssh key etc.

#7 Updated by Evgeni Golov 10 months ago

  • Pull request https://github.com/theforeman/foreman-packaging/pull/6304 added

#8 Updated by Evgeni Golov 10 months ago

  • Assignee set to Evgeni Golov
  • Status changed from New to Resolved

This has been fixed in ruby-foreman-ansible-core_4.0.0-2 and ruby-smart-proxy-ansible_3.0.0-4 which have been pushed out to Foreman 2.2, 2.3, 2.4 and nightly repositories.

Also available in: Atom PDF