Project

General

Profile

Bug #31753

Updated by Evgeni Golov about 3 years ago

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

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

 When trying to run an Ansible job, the first thing you'll encounter is <code>uninitialized constant ForemanAnsibleCore</code> (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: 
 <pre> 
 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 
 </pre> 

 I am not exactly sure who *should* own that file, but not both (funnily, core/runner/command_creator.rb does genetate the path as <code>/usr/lib/ruby/bin/json_inventory.sh</code>, 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 <code>ERROR! Unexpected Exception, this is probably a bug: No module named 'psutil'</code>. 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: <code>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'"}</code> -- 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: 
 <pre> 
 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} 
 </pre>

Back