Project

General

Profile

Actions

Bug #31753

closed

can't execute ansible on Debian

Added by Evgeni Golov about 3 years ago. Updated about 3 years 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 1 (0 open1 closed)

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

Updated by Ewoud Kohl van Wijngaarden about 3 years 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
Actions #2

Updated by Evgeni Golov about 3 years 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…

Actions #3

Updated by Evgeni Golov about 3 years ago

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

Updated by Evgeni Golov about 3 years ago

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

Updated by Evgeni Golov about 3 years ago

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

Updated by Evgeni Golov about 3 years 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.
Actions #7

Updated by Evgeni Golov about 3 years ago

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

Updated by Evgeni Golov about 3 years ago

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

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.

Actions

Also available in: Atom PDF