Hi,
I am writing an ansible collection to configure some internal company tools.
Inside this collection I want to have several roles. These roles are very
similar to each other, so I want to put some shared utility functions and
classes in some shared location. As far as I understand, that's what the
`plugins/module_utils` directory in a collection is for.
So here is my collection structure:
```
.
├── README.md
└── ansible_collections
└── company
└── iam
├── README.md
├── docs
├── galaxy.yml
├── company-iam-1.0.0.tar.gz
├── meta
│ └── runtime.yml
├── playbooks
│ └── playbook.yml
├── plugins
│ ├── README.md
│ └── module_utils
│ ├── api_wrapper.py
│ ├── synchronizer.py
│ └── utils.py
├── roles
│ └── user_groups
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ ├── handlers
│ │ └── main.yml
│ ├── library
│ │ └── user_groups_sync.py
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ └── main.yml
├── tests
│ ├── output
....
```
I want to call the playbook in playbooks/playbook.yml, that should run the
role user_groups and run the code inside the library/user_groups_sync.py.
This is what the playbook looks like:
---
- hosts: localhost
gather_facts: false
collections:
- company.iam
vars:
user_groups_file: "../user_group_vars.yml"
roles:
- role: company.iam.user_groups # Use FQCN here
here is what I am doing (inside the playbooks directory)
playbooks git:(ansible_collection) ✗ ansible-playbook playbook.yml
[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'
ERROR! couldn't resolve module/action 'user_groups_sync'. This often
indicates a misspelling, missing collection, or incorrect module path.
I am really new to ansible collections and I'm afraid I haven't gotten very
far by reading the documentation. Could I please get some help here? I'd
really appreciate it.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f915213d-ff2a-4686-b96b-0232eb7aac76n%40googlegroups.com.