If I run ansible-playbook with this playbook it runs fine.
[andrewcrisp@host-1 ~]$ cat storageplay.yml
---
- name: Manage storage
hosts: host-8
become: true
roles:
- name: redhat.rhel-system-roles.storage
#- name: rhel-system-roles.storage
storage_pools:
- name: apache-vg
disks:
- vda
- vdc
volumes:
- name: acontddent-lv
size: 64m
mount_point: "/var/ixxxwwwxx"
fs_type: xfs
state: present
- name: xxxdxelogs-lv
size: 100m
fs_type: xfs
mount_point: "/var/log/hxxxttpxxd"
[andrewcrisp@host-1 ~]$
If I run with navigator it fails
[andrewcrisp@host-1 ~]$ ansible-navigator run storageplay.yml
ERROR! the role 'rhel-system-roles.storage' was not found in /home/andrewcrisp/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/andrewcrisp
The error appears to be in '/home/andrewcrisp/storageplay.yml': line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
#- name: redhat.rhel-system-roles.storage
- name: rhel-system-roles.storage
^ here
Please review the log for error
My ansible.cfg is as so
[andrewcrisp@host-1 ~]$ cat ansible.cfg
[defaults]
inventory = inventory.ini
remote_user = andrewcrisp
roles_path=/home/andrewcrisp/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
collections_path=/home/andrewcrisp/.ansible/collections:/usr/share/ansible/collections
[priviledge_escalation]
become_user = root
become_method = sudo
become_ask_for_pass = false
and my ansible-navigator.yml looks like
[andrewcrisphost-1 ~]$ cat ansible-navigator.yml
---
ansible-navigator:
execution-environment:
container-engine: podman
enabled: true
image: registry.redhat.io/ansible-automation-platform-25/ee-supported-rhel8:latest
pull:
policy: missing
format: yaml
mode: stdout
playbook-artifact:
enable: false
settings:
effective: true
sample: false
schema: json
sources: false
time-zone: UTC
[andrewcrisp@host-1 ~]$
If I search in collections from navigator
[andrewcrisp@host-1 ~]$ ansible-navigator collections| grep redhat.rhel_system_roles.storage -a10
raid_spare_count: null
raid_stripe_size: null
size: 0
state: present
thin: null
thin_pool_name: null
thin_pool_size: null
type: lvm
vdo_pool_size: null
defaults_path: /usr/share/ansible/collections/ansible_collections/redhat/rhel_system_roles/roles/storage/defaults/main.yml
full_name: redhat.rhel_system_roles.storage
info:
galaxy_info:
author: David Lehman <dlehman@redhat.com>
company: Red Hat, Inc.
description: Configure volumes and filesystems
galaxy_tags:
- centos
- el7
- el8
- el9
[andrewcrisp@host-1 ~]$
What am I missing ? I've tried with the redhat.rhel... and not.
The files are under /usr/share
[andrewcrisp@host-1 ~]$ ls /usr/share/ansible/roles/rhel-system-roles.storage/
CHANGELOG.md ansible_pytest_extra_requirements.txt module_utils tasks
LICENSE contributing.md molecule_extra_requirements.txt tests
README-ansible.md custom_requirements.txt plans tox.ini
README-ostree.md defaults pylint_extra_requirements.txt vars
README.html library pylintrc
README.md meta pytest_extra_requirements.txt
[andrewcrisp@host-1 ~]$
so really scratching my head? I was under the impression that if something is referenced in the ansible.cfg as far as roles_path etc the container should be able to use it? Is that not the case?
Thanks
The name redhat.rhel-system-roles.storage or rhel-system-roles.storage refers to the role coming from the rpm package "rhel-system-roles". This package is installed on your local system, but is not installed in the execution environment. So ansible-playbook (running on the local system) can find that role, but ansible-navigator (which uses the execution environment) can't find that role.
If you would specify redhat.rhel_system_roles.storage (underscores, not hyphens) you would refer to the role storage from the redhat.rhel_system_roles collection, which on the local system is also coming from that rpm package, and which is also included in the execution environment. So when you would use that collection name, it would also work from ansible-navigator.
It's important to realize that only the current directory is volume-mounted into the container that executes the playbook with ansible-navigator. So what you find in /usr/share/ansible on your local system, will not by default be available in the container. And the difference between underscore ('_') and hyphen ('-') is not easily visible but utterly important in this case.
No, not ~/collections but ./collections (as I hope that you don't have all ansible playbooks in your home directory, but in project-specific sub-directories). It is the current directory where the playbook is, that is volume-mounted into the container. So ./collections is visible in the container; ./collections/requirements.yml is where you specify which collections you want to use in your project and you might install them with
[andrewcrisp@host-1 ~]$ ansible-galaxy collection install -r ./collections/requirements.yml -p ./collections
Strong advise: only use roles from collections, as that's the modern way of working (better version control and dependency handling).
OK I think I've figured it out?
- name: redhat.rhel_system_roles.storage
but why the underscores? or is the the navigator yml not doing what I think it is as far as pointing to the additional roles/collections?
The name redhat.rhel-system-roles.storage or rhel-system-roles.storage refers to the role coming from the rpm package "rhel-system-roles". This package is installed on your local system, but is not installed in the execution environment. So ansible-playbook (running on the local system) can find that role, but ansible-navigator (which uses the execution environment) can't find that role.
If you would specify redhat.rhel_system_roles.storage (underscores, not hyphens) you would refer to the role storage from the redhat.rhel_system_roles collection, which on the local system is also coming from that rpm package, and which is also included in the execution environment. So when you would use that collection name, it would also work from ansible-navigator.
It's important to realize that only the current directory is volume-mounted into the container that executes the playbook with ansible-navigator. So what you find in /usr/share/ansible on your local system, will not by default be available in the container. And the difference between underscore ('_') and hyphen ('-') is not easily visible but utterly important in this case.
@Alex_Bron Spot on!
So its just the ~/collections and ~/roles .. if I create and install packages into there that are visible ? Nothing deeper into the local system than the directory I'm working out of ?
No, not ~/collections but ./collections (as I hope that you don't have all ansible playbooks in your home directory, but in project-specific sub-directories). It is the current directory where the playbook is, that is volume-mounted into the container. So ./collections is visible in the container; ./collections/requirements.yml is where you specify which collections you want to use in your project and you might install them with
[andrewcrisp@host-1 ~]$ ansible-galaxy collection install -r ./collections/requirements.yml -p ./collections
Strong advise: only use roles from collections, as that's the modern way of working (better version control and dependency handling).
Thanks for help. The examples above are from me digging around i.e. I'm not running anything out of my home directory in prodiuction but not using navigator at the moment either.
As a follow up
[andrewcrisp@host-1 collections]$ cat requirements.yaml
---
collections:
- name: redhat.rhel_system_roles
[andrewcrisp@host-1 ~]$ ansible-galaxy collection install -r ./collections/requirements.yaml -p ./collections
Starting galaxy collection install process
Process install dependency map
ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
* redhat.rhel_system_roles:* (direct request)
[andrewcrisp@host-1 ~]$
What am I missing now ?
Do you have a subscription for Ansible Automation Platform? If so, you'll have to configure your ansible.cfg so that it can download collections from Automation Hub - as that is where redhat.rhel_system_roles is hosted. In your ansible.cfg you'll need:
[galaxy]
server_list = automation_hub
[galaxy_server.automation_hub]
url=https://cloud.redhat.com/api/automation-hub/
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
token=<Your Token, generated at console.redhat.com>
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.