Ansible cannot find nailgun from foreman-ansible-modules

Hey,

I am trying out foreman-ansible-modules and I am also Ansible newbie. I installed “nailgun” via pip command on my Fedora 29:

pip install --user nailgun

But Ansible is unable to find it:

[lzap@box foreman-ansible-modules]$ ansible-playbook -i localhost -vvv test.yaml
ansible-playbook 2.7.4
  config file = /home/lzap/work/foreman-ansible-modules/ansible.cfg
  configured module search path = ['/home/lzap/work/foreman-ansible-modules/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.7.1 (default, Nov 23 2018, 10:01:49) [GCC 8.2.1 20181105 (Red Hat 8.2.1-5)]
Using /home/lzap/work/foreman-ansible-modules/ansible.cfg as config file
/home/lzap/work/foreman-ansible-modules/localhost did not meet host_list requirements, check plugin documentation if this is unexpected
Skipping due to inventory source not existing or not being readable by the current user
/home/lzap/work/foreman-ansible-modules/localhost did not meet script requirements, check plugin documentation if this is unexpected
Skipping due to inventory source not existing or not being readable by the current user
/home/lzap/work/foreman-ansible-modules/localhost did not meet yaml requirements, check plugin documentation if this is unexpected
Skipping due to inventory source not existing or not being readable by the current user
/home/lzap/work/foreman-ansible-modules/localhost did not meet ini requirements, check plugin documentation if this is unexpected
/home/lzap/work/foreman-ansible-modules/localhost did not meet auto requirements, check plugin documentation if this is unexpected
 [WARNING]: Unable to parse /home/lzap/work/foreman-ansible-modules/localhost as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAYBOOK: test.yaml *******************************************************************************************************************************************************************************************************************************************
1 plays in test.yaml

PLAY [Playbook] ***********************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************************************************
task path: /home/lzap/work/foreman-ansible-modules/test.yaml:2
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: lzap
<127.0.0.1> EXEC /bin/sh -c 'echo ~lzap && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581 `" && echo ansible-tmp-1544631601.04356-67881606113581="` echo /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581 `" ) && sleep 0'
Using module file /usr/lib/python3.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> PUT /home/lzap/.ansible/tmp/ansible-local-31197qa7w2x32/tmp_4tp49bq TO /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581/ /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/lzap/.ansible/tmp/ansible-tmp-1544631601.04356-67881606113581/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [Create CI Location] *************************************************************************************************************************************************************************************************************************************
task path: /home/lzap/work/foreman-ansible-modules/test.yaml:5
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: lzap
<127.0.0.1> EXEC /bin/sh -c 'echo ~lzap && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060 `" && echo ansible-tmp-1544631605.4882455-31727535488060="` echo /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060 `" ) && sleep 0'
Using module file /home/lzap/work/foreman-ansible-modules/modules/foreman_location.py
<127.0.0.1> PUT /home/lzap/.ansible/tmp/ansible-local-31197qa7w2x32/tmp9m4ryiq1 TO /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060/AnsiballZ_foreman_location.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060/ /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060/AnsiballZ_foreman_location.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060/AnsiballZ_foreman_location.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/lzap/.ansible/tmp/ansible-tmp-1544631605.4882455-31727535488060/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "name": "LocByAnsible",
            "parent": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "server_url": "http://localhost:3000",
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "verify_ssl": true
        }
    },
    "msg": "No module named 'nailgun'"
}

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   

What is wrong? Is the --user option causing this? How do I tell Ansible to load this library from my user folder?

pip installs the library for Python 2. so you need to use pip3.

1 Like

Oooh I havent realized Fedora is on P3 already, I tried pip2 and it did not work out :slight_smile: Thanks.