seantis/suitable

Using Ansible collections

elgow opened this issue · 5 comments

elgow commented

How can I use modules in the Ansible collections. I'm especially interested in using the ansible.builtins.file module documented at https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_lookup.html

elgow commented

As the file mentioned above is a plugin rather than a module, let me restate my question. I'd like to use the module ansible.posix.authorized_key. I've tried various ways to install the posix collection as described in the Ansible Galaxy guide without success.

Is there any way to use Ansible collections other than builtin?

elgow commented

This is related to issue #25 and #19. To use an Ansible Galaxy module you can copy it from the galaxy directory into your standard Ansible library directory as described in https://docs.ansible.com/ansible/latest/dev_guide/developing_locally.html. It's hugely unfortunate that this is necessary. It would be good if Suitable could use modules from the Ansible collections directories.

p.s. Suitable is much more pleasant to use than the hokey Ansible YAML DSL

@elgow I'm not really familiar with using modules from the Ansible collection. If I find myself with some spare time I'll have a look at whether or not this can be improved with a reasonable amount of effort.

elgow commented

@Daverball I've been looking into it and can perhaps help out, especially with some advice along the way. I'm very impressed with how much easier it is to write scripts in Python with Suitable than it is to write in YAML.

I suspect this was an issue with Ansible 8+ since we didn't properly initialize the importlib machinery in order for the collections installed through ansible (not ansible-core) to be available.

suitable 0.20.0 now does this correctly.

Installing ansible-base can be problematic too, since it overwrites some ansible modules and makes them become unavailable.