Two problems with ansible-pull

Hi,

I’d like to use ansible-pull to manage two servers and three desktops in my local network. I’ve read an excellent (though a bit outdated) tutorial about ansible-pull, and it seems like the right fit for my use case.

I have a minimal installation of Rocky Linux 8 on a test box. I just installed Ansible from EPEL, and I have a first draft of a local.yml playbook in a GitHub repository here:

I execute ansible-pull (as root) with the appropriate URL, and here’s an error I get:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import 
the required Python library (libselinux-python) on squidbox's Python 
/usr/bin/python3.12.

Now this is a known problem with RHEL8 and compatible clones like Rocky Linux 8. In a “classic” Ansible setup, this can be solved simply by defining this in the appropriate place:

ansible_python_interpreter=/usr/bin/python3

The first problem here is that there seems to be no appropriate place with ansible-pull. Apparently the only solution here is to use an extra variable on the command line like this:

# ansible-pull -U https://github.com/kikinovak/microlinux-squidbox-el8 \
  -e ansible_python_interpreter=/usr/bin/python3

This time things work as expected:

TASK [enable_selinux : Enable SELinux in enforcing mode] **************
ok: [localhost]

So my first question would be: how can I define ansible_python_interpreter=/usr/bin/python3 in a permanent way for ansible-pull ?

In a similar way, I have another problem. Every time I call ansible-pull, I get a series of warnings:

[WARNING]: Could not match supplied host pattern, ignoring: squidbox
[WARNING]: Could not match supplied host pattern, ignoring:
...
[WARNING]: provided hosts list is empty, only localhost is available. 
Note that the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: squidbox
[WARNING]: Could not match supplied host pattern, ignoring:
squidbox.microlinux.lan

Apparently there seems to be no way to explain to ansible-pull that I only want to execute the local.yml play on localhost.

Which brings me to my second question: how do I get rid of these useless warnings ?

On a side note: ansible-pull seems to be the right fit for what I do, but some of its designs details seem… not very smart (to state it politely).

Any suggestions ?

Niki

Your repo doesn’t seem to have an inventory? Try creating a hosts.yml file containing something like this:

all:
  vars:
    ansible_python_interpreter: /usr/bin/python3
  children:
    localhosts:
      hosts:
        localhost:
          ansible_connection: local

And a ansible.cfg with:

[defaults]
inventory = hosts.yml

Does that solve these issues?

No, unfortunately that doesn’t solve the problem.

And please note I’m using ansible-pull, not ansible. Those two are different beasts. And ansible-pull seems sadly underdocumented.

Cheers,

Niki

Right, here goes. I’ve spent some time with a few sandbox VMs and lots of coffee, and it looks like (almost) all my problems are solved. Only thing left is those pesky warnings about missing hosts, but it looks like this problem is endemic to ansible-pull. I’ll just ignore them.

  1. Configuration files are handled differently with ansible-pull. I had to figure that out. You have to put your stuff in ~/.ansible.cfg. If you just use ./ansible.cfg, things won’t work.
  2. Since stuff is supposed to run locally, an inventory file makes no sense. Well, you can always try to create one, but then watch out for some confusion. This is completely undocumented, except a few educated guesses by a handful of bloggers.
  3. Variables like ansible_python_interpreter have to go in your playbook for lack of an inventory file.

So, after a sunny day of experimenting and working out stuff and then a run in the woods to clear my head, here’s my working configuration (work in progress):

Cheers from the sunny South of France,

Niki

1 Like