Can't attribute Ansible Roles to a host

I have import Ansible roles from Configure/Roles that are locate in /etc/ansible/roles but when i want to attribute an Ansible roles to a host, there is nothing on the interface


I noticed that when i try to run a ansible command on a host, the ansible callback sends me back :

 1:
/var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 1: /var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 
   2:
---: not found
   3:
/var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 2: /var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 
   4:
-: not found
   5:
/var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 3: /var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 
   6:
tasks:: not found
   7:
/var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 4: /var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 
   8:
-: not found
  9:
/var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 6: /var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 
 10:
register:: not found
 11:
/var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 7: /var/tmp/foreman-ssh-cmd-8909c17e-27a5-4ad0-9377-782d7501bb6b/script: 
 12:
-: not found
 13:
Statut de sortie : 127

i’m running ansible 2.7.10 and foreman 1.21

No help to offer, but I’m experiencing that too. I did see a thread yesterday where the issue was noted and a developer was going to try to reproduce the issue and look into it.

@vivitare: regarding the empty roles tab, it is a bug: Bug #26645: Ansible roles switcher not mounted after form partial re-render - Ansible - Foreman

regarding the callback issue, foreman_remote_execution plugin tries to run playbook as a regular script, could be some sort of version mismatch with foreman-tasks, but @aruzicka has more in-depth knowledge in this area.

Ok thank you

About the callback issue, I’ve got :

Versions
foreman-tasks 0.14.5
foreman_ansible 2.3.3
foreman_execution 1.7.0
Ansible 2.7.10
smart_proxy 1.21.2

It looks like it tries to run the playbook as a regular shell script. This usually happens when foreman_ansible_core is not installed and/or enabled. Do you have it installed?

I don’t know but i have install plugin Ansible founded on the Foreman manual :

I installed it with foreman-installer method

https://www.theforeman.org/plugins/foreman_ansible/2.x/index.html#2.1Ansiblecallback

ShuffleBox referred to my post w/ Ansible role import issues, I’m also experiencing a call-back issue.

[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin
(<ansible.plugins.callback./usr/lib/python2.7/site-
packages/ansible/plugins/callback/foreman.CallbackModule object at
0x7f0a54df9310>): [Errno 13] Permission denied

[WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin
(<ansible.plugins.callback./usr/lib/python2.7/site-
packages/ansible/plugins/callback/foreman.CallbackModule object at
0x7f0a54df9310>): [Errno 13] Permission denied

I do have the following installed:
tfm-rubygem-foreman_ansible_core.noarch 2.2.0-1.fm1_21.el7 @foreman-plugins

I have 2 test systems, 1 in the office hosted on VMware, 1 at home hosted in VirtualBox. Both exhibit the same callback error (all CentOS7, Foreman, Katello, latest versions and fully patched.)

When i try to install ruby-foreman-ansible-core, i’ve got error :

root@cfastdocker:/# apt-get install ruby-foreman-ansible-core 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ruby-foreman-ansible-core
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/6,104 B of archives.
After this operation, 36.9 kB of additional disk space will be used.
(Reading database ... 83257 files and directories currently installed.)
Preparing to unpack .../ruby-foreman-ansible-core_2.2.0-1_all.deb ...
Unpacking ruby-foreman-ansible-core (2.2.0-1) ...
dpkg: error processing archive /var/cache/apt/archives/ruby-foreman-ansible-core_2.2.0-1_all.deb (--unpack):
 trying to overwrite '/usr/bin/json_inventory.sh', which is also in package ruby-smart-proxy-ansible 2.1.2-1
Errors were encountered while processing:
 /var/cache/apt/archives/ruby-foreman-ansible-core_2.2.0-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

so i forced the overwriting :

sudo dpkg -i --force-overwrite /var/cache/apt/archives/ruby-foreman-ansible-core_2.2.0-1_all.deb

(Reading database ... 83257 files and directories currently installed.)
Preparing to unpack .../ruby-foreman-ansible-core_2.2.0-1_all.deb ...
Unpacking ruby-foreman-ansible-core (2.2.0-1) ...
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/usr/bin/json_inventory.sh', which is also in package ruby-smart-proxy-ansible 2.1.2-1
Setting up ruby-foreman-ansible-core (2.2.0-1) ...

and to finish i forced the install and he said that is the last version

root@cfastdocker:/# apt-get -f install ruby-foreman-ansible-core

Reading package lists... Done
Building dependency tree       
Reading state information... Done
ruby-foreman-ansible-core is already the newest version (2.2.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

And now, when i run job template Ansible, a Warning tell me something :

  1:
 [WARNING]: Unable to parse /usr/lib/ruby/bin/json_inventory.sh as an inventory
   2:
source
   3:
 [WARNING]: No inventory was parsed, only implicit localhost is available
   4:
 [WARNING]: provided hosts list is empty, only localhost is available. Note
   5:
that the implicit localhost does not match 'all'
   6:

   7:
PLAY [all] *********************************************************************
   8:
skipping: no hosts matched
   9:

  10:
PLAY RECAP *********************************************************************
  11:

  12:

  13:
PLAY [all] *********************************************************************
  14:
skipping: no hosts matched
  15:

  16:
PLAY RECAP *********************************************************************
  17:

  18:
Statut de sortie : 0

I don’t understand because my /etc/ansible/hosts is not empty !
I executed :

I can’t install it, he return me an error :

root@cfastdocker:/home/cfast# apt-get install ruby-foreman-ansible-core
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ruby-foreman-ansible-core
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,104 B of archives.
After this operation, 36.9 kB of additional disk space will be used.
Get:1 http://deb.theforeman.org stretch/1.21 amd64 ruby-foreman-ansible-core all 2.2.0-1 [6,104 B]
Fetched 6,104 B in 0s (20.5 kB/s)              
Selecting previously unselected package ruby-foreman-ansible-core.
(Reading database ... 83257 files and directories currently installed.)
Preparing to unpack .../ruby-foreman-ansible-core_2.2.0-1_all.deb ...
Unpacking ruby-foreman-ansible-core (2.2.0-1) ...
dpkg: error processing archive /var/cache/apt/archives/ruby-foreman-ansible-core_2.2.0-1_all.deb (--unpack):
 trying to overwrite '/usr/bin/json_inventory.sh', which is also in package ruby-smart-proxy-ansible 2.1.2-1
Errors were encountered while processing:
 /var/cache/apt/archives/ruby-foreman-ansible-core_2.2.0-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

He want to overwrite on a file ‘/usr/bin/json_inventory.sh’ which is also in package ruby-smart-proxy-ansible 2.1.2-1

What can i do ? Because when i force the overwritting with :

 dpkg -i --force-overwrite /var/cache/apt/archives/ruby-foreman-ansible-core_2.2.0-1_all.deb

New errors appear during run of Ansible commands from Foreman interface

 1:
 [WARNING]: Unable to parse /usr/lib/ruby/bin/json_inventory.sh as an inventory
   2:
source
   3:
 [WARNING]: No inventory was parsed, only implicit localhost is available
   4:
 [WARNING]: provided hosts list is empty, only localhost is available. Note
   5:
that the implicit localhost does not match 'all'
   6:

   7:
PLAY [all] *********************************************************************
   8:
skipping: no hosts matched
   9:

  10:
PLAY RECAP *********************************************************************
  11:

  12:

  13:
PLAY [all] *********************************************************************
  14:
skipping: no hosts matched
  15:

  16:
PLAY RECAP *********************************************************************
  17:

  18:
Statut de sortie : 0

Make sure /usr/lib/ruby/bin/json_inventory.sh is a link to /usr/bin/json_inventory.sh