Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Ansible collections #44

Closed
elgow opened this issue Oct 22, 2021 · 5 comments
Closed

Using Ansible collections #44

elgow opened this issue Oct 22, 2021 · 5 comments
Assignees

Comments

@elgow
Copy link
Contributor

elgow commented Oct 22, 2021

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
Copy link
Contributor Author

elgow commented Oct 23, 2021

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
Copy link
Contributor Author

elgow commented Oct 26, 2021

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

@Daverball
Copy link
Member

@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.

@Daverball Daverball self-assigned this Oct 27, 2021
@elgow
Copy link
Contributor Author

elgow commented Oct 27, 2021

@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.

@Daverball
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants