ansible / ansible-navigator

A text-based user interface (TUI) for Ansible.
https://ansible.readthedocs.io/projects/navigator/
Apache License 2.0
394 stars 102 forks source link

Collection documentation inside EE vs local #608

Closed watsonb closed 2 years ago

watsonb commented 3 years ago
ISSUE TYPE
SUMMARY

Cannot pull up collection documentation of collections contained within an EE.

ANSIBLE-NAVIGATOR VERSION
ansible-navigator 1.1.0
CONFIGURATION

ansible-navigator.yml

---
ansible-navigator:
  ansible:
    config: $PWD/ansible.cfg
    # cmdline: "--forks 15"
    # inventories:
    # - /tmp/test_inventory.yml
    # playbook: /tmp/test_playbook.yml

  ansible-runner:
    artifact-dir: $PWD/navigator_artifacts
    rotate-artifacts-count: 10
    timeout: 300

  app: welcome  # ‘collections’, ‘config’, ‘doc’, ‘images’, ‘inventory’, ‘replay’, ‘run’ or ‘welcome’

  collection-doc-cache-path: $PWD/cache.db

  color:
    enable: True
    osc4: True

  editor:
    # command: code
    command: vim +{line_number} {filename}
    # console: False
    console: True

  # documentation:
  #   plugin:
  #     name: shell
  #     type: become

  execution-environment:
    container-engine: podman
    enabled: true
    # environment-variables:
    #   pass:
    #     - ONE
    #     - TWO
    #     - THREE
    #   set:
    #     KEY1: VALUE1
    #     KEY2: VALUE2
    #     KEY3: VALUE3
    image: localhost/kiewit_ee_all:latest
    pull-policy: never
    # volume-mounts:
    # - src: "/test1"
    #   dest: "/test1"
    #   label: "Z"
    # container-options:
    # - "--net=host"

  # help-config: True

  # help-doc: True

  # help-inventory: True

  # help-playbook: False

  # inventory-columns:
  #   - ansible_network_os
  #   - ansible_network_cli_ssh_type
  #   - ansible_connection

  logging:
    level: warning
    append: False
    file: $PWD/navigator.log

  mode: interactive  # interactive, stdout

  playbook-artifact:
    enable: True
    replay: $PWD/navigator_replay.json
    save-as: $PWD/navigator_replay.json

ansible.cfg (in CWD)

[defaults]
forks = 20
precedence = all_plugins_inventory,groups_plugins_inventory,all_inventory,groups_inventory,all_plugins_play,groups_plugins_play
retry_files_enabled = true
host_key_checking = false
#collections_paths = collections/:~/.ansible/collections:/usr/share/ansible/collections
#roles_path = roles/:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
vault_identity_list = vcenter@/home/runner/workspace/kiewit/ansible_vaults/vcenter,azure@/home/runner/workspace/kiewit/ansible_vaults/azure,ansible_user@/home/runner/workspace/kiewit/ansible_vaults/ansible_user,kiewitadmin_user@/home/runner/workspace/kiewit/ansible_vaults/kiewitadmin_user,awx@/home/runner/workspace/kiewit/ansible_vaults/awx,snow@/home/runner/workspace/kiewit/ansible_vaults/snow
ssh_args = -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
callback_whitelist = timer, profile_roles, profile_tasks, junit
gathering = smart
fact_caching = jsonfile
fact_caching_connection = $HOME/ansible/facts
fact_caching_timeout = 600
nocows = true
# Use the YAML callback plugin.
stdout_callback = yaml
# Use the stdout_callback when running ad-hoc commands.
bin_ansible_callbacks = True
LOG FILE

N/A

STEPS TO REPRODUCE

As shown in my configs, if I launch ansible-navigator with no arguments, I expect to be at the welcome screen and when I list :images, I expect to be using the specified image. This works as expected

NAME                                                                TAG               EXECUTION ENVIRONMENT                                   CREATED                                       SIZE
0│ansible-builder                                                     latest                            False                                   14 hours ago                                  539 MB
1│awx-ee                                                              latest                             True                                   2 hours ago                                   1.27 GB
2│kiewit_ee_all (primary)                                             latest                             True                                   About an hour ago                             5.99 GB
3│kiewit_ee_linux_instance                                            latest                             True                                   2 hours ago                                   3.43 GB
4│kiewit_ee_windows_instance                                          latest                             True                                   2 hours ago                                   3.42 GB

Moreover, if I press a number corresponding to the selected image (in this case, 2) and then view Ansible version and collections, I can confirm that the collections specified when building the image are there.

However, when I run the :collections command from the welcome screen, I'm told there are no collections.

WARNING
                                                          ──────────────────────────────────────────────────────────────────
                                                          humph. no collections were found in the following paths:
                                                          [HINT] Try installing some or try a different execution enviroment
                                                          ──────────────────────────────────────────────────────────────────
EXPECTED RESULTS

My expectation is that I can browse collection documentation for collections pre-installed "inside" the EE, but it appears that ansible-navigator is looking for collections installed locally.

I'm extremely excited about the prospect of self-contained EEs as it will make my job of setting up other developers, CI/CD, and AWX/Tower to have the same environment everywhere. And ansible-navigator as a method to introspect and execute from an EE is amazing.

However, from an Ansible content developmental point of view, if I'm using a provided EE and writing a playbook, I want to pull up documentation specific to the collections contained within the EE to ensure I'm using modules, libraries, plugins, etc. correctly in my new content.

It seems weird, with this new paradigm, to expect that a developer using ansible-navigator as a runner/development aid to also have ansible-galaxy as part of a normal ansible install to obtain the collections locally.

Or am I doing/understanding things horribly wrong?

ACTUAL RESULTS
humph. no collections were found in the following paths:
ADDITIONAL INFORMATION

N/A

relrod commented 2 years ago

Can you run with --ll debug and provide the corresponding ansible-navigator.log so we can get a better idea of what is happening here?

watsonb commented 2 years ago

Here's a copy of the log when running ansible-navigator collections from the command-line navigator.log .

From what I'm seeing, it is volume mounting local dirs and only searching those for collections? I've spun up a container instance of the image via podman run --rm -it cregprod01scusdco.azurecr.io/kiewit/kiewit_ee_all:latest /bin/bash and can confirm the presence of roles and collections inside the image/container at /usr/share/ansible

bash-4.4# ls /usr/share/ansible/collections/ansible_collections/
amazon   awx          chocolatey     community   dellemc     frr      hetzner  infinidat    kiewit      netapp      ngine_io     ovirt       sensu       t_systems_mms  wti
ansible  azure        cisco      containers  f5networks  gluster  hpe      inspur       kubernetes  netapp_eseries  openstack    purestorage     servicenow  theforeman
arista   check_point  cloudscale_ch  cyberark    fortinet    google   ibm      junipernetworks  mellanox    netbox      openvswitch  redhatinsights  splunk      vyos
cidrblock commented 2 years ago

@watsonb Do me a favor? Try again w/o overriding the defautl collection_cache_db location. There's a duplicate volumne mount and I'm wondering if it is becasue the collection_cache is in the CWD.... I snipped out some of the log info that is relevant:

Running with collection_doc_cache_path as '/home/ben/workspace/kiewit/ansible/cache.db' (str/user provided configuration file)

container_volume_mounts:[
    '/home/ben/venv_ansible_navigator/share/ansible_navigator/utils:/home/ben/venv_ansible_navigator/share/ansible_navigator/utils', 
    '/home/ben/workspace/kiewit/ansible/collections:/home/ben/workspace/kiewit/ansible/collections:z', 
    '/home/ben/workspace/kiewit/ansible/cache.db:/home/ben/workspace/kiewit/ansible/cache.db:z']
]

podman run --rm --tty --interactive 
    -v /home/ben/workspace/kiewit/ansible/:/home/ben/workspace/kiewit/ansible/ <<<<<<<<<<<
    --workdir /home/ben/workspace/kiewit/ansible 
    -v /run/user/1302/keyring/:/run/user/1302/keyring/ 
    -e SSH_AUTH_SOCK=/run/user/1302/keyring/ssh 
    -v /home/ben/.ssh/:/home/runner/.ssh/ 
    --group-add=root 
    --ipc=host 
    -v /tmp/ansible-navigator__wayqd59/artifacts/:/runner/artifacts/:Z 
    -v /tmp/ansible-navigator__wayqd59/:/runner/:Z 
    -v /home/ben/venv_ansible_navigator/share/ansible_navigator/utils/:/home/ben/venv_ansible_navigator/share/ansible_navigator/utils/ 
    -v /home/ben/workspace/kiewit/ansible/collections/:/home/ben/workspace/kiewit/ansible/collections/:z 
    -v /home/ben/workspace/kiewit/ansible/:/home/ben/workspace/kiewit/ansible/:z <<<<<<<<<<<<<<<
    --env-file /tmp/ansible-navigator__wayqd59/artifacts/aa6fad89-a149-45aa-b38a-2c932b34f31e/env.list 
    --quiet --name ansible_runner_aa6fad89-a149-45aa-b38a-2c932b34f31e 
    cregprod01scusdco.azurecr.io/kiewit/kiewit_ee_all:latest 
    python3 /home/ben/venv_ansible_navigator/share/ansible_navigator/utils/catalog_collections.py -a /home/ben/workspace/kiewit/ansible/collections -c /home/ben/workspace/kiewit/ansible/cache.db

Error: /home/ben/workspace/kiewit/ansible/: duplicate mount destination
watsonb commented 2 years ago

well that seems to have worked! curious, my custom collection has an inventory plugin and a bunch of roles. The only thing I can browse is the inventory plugin. I looked at some other collections as well (e.g. awx.awx, and azure.azcollection) and can see their plugins and modules. Will this be able to browse a collection's roles as well in the future?

cidrblock commented 2 years ago

@watsonb Yes! https://github.com/ansible/ansible-navigator/issues/231, anything you want to add there would be great.

Thanks for the confirmation, I'll see if I can recreate here.

Curious, did you have a reason to move the collection cache? (only because I never really expected anyone to do that :) )

watsonb commented 2 years ago

honestly I think I copied/pasted the ansible-navigator.yml file and tuned it. Have no idea why that cache location was specified