cancel
Showing results for 
Search instead for 
Did you mean: 
AndrewC666
Flight Engineer
Flight Engineer
  • 388 Views

Navigator issues

Jump to solution

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

Labels (1)
2 Solutions

Accepted Solutions
Alex_Bron
Mission Specialist
Mission Specialist
  • 371 Views

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.

View solution in original post

Alex_Bron
Mission Specialist
Mission Specialist
  • 360 Views

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

View solution in original post

8 Replies
AndrewC666
Flight Engineer
Flight Engineer
  • 375 Views

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?

 

Alex_Bron
Mission Specialist
Mission Specialist
  • 372 Views

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.

Chetan_Tiwary_
Community Manager
Community Manager
  • 366 Views

@Alex_Bron Spot on!

0 Kudos
AndrewC666
Flight Engineer
Flight Engineer
  • 362 Views

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 ?

Alex_Bron
Mission Specialist
Mission Specialist
  • 361 Views

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

AndrewC666
Flight Engineer
Flight Engineer
  • 333 Views

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. 

AndrewC666
Flight Engineer
Flight Engineer
  • 123 Views

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 ?

Alex_Bron
Mission Specialist
Mission Specialist
  • 99 Views

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>
Join the discussion
You must log in to join this conversation.