redhat-cop / ee_utilities

This ansible collection includes a number of roles and tools which can be useful for managing Ansible Execution Environments.
https://galaxy.ansible.com/infra/ee_utilities
GNU General Public License v3.0
57 stars 34 forks source link

'Create EE temp list' task fails #104

Open ansiblejunky opened 1 year ago

ansiblejunky commented 1 year ago

Summary

'Create EE temp list' task fails when running a playbook using this collection/role to extract info about current venvs on an existing Tower node. The regex_replace filter function used here causes the following error. I'm assuming this is a problem with using Ansible 2.9.x but this syntax should work in 2.9 because we typically run the playbook on Tower node, which has Ansible 2.9.

TASK [infra.ee_utilities.virtualenv_migrate : Create EE list] ******************************************************************
fatal: [localhost]: FAILED! => {"reason": "We were unable to read either as JSON nor YAML, these are the errors we got from each:\nJSON: Expecting value: line 1 column 1 (char 0)\n\nSyntax Error while loading YAML.\n  found unknown escape character\n\nThe error appears to be in '/app/collections/ansible_collections/infra/ee_utilities/roles/virtualenv_migrate/tasks/02_ee_list_create.yml': line 9, column 69, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n    ee_list_temp:\n      - name: \"{{ __venv_migrate_python_item.item | regex_replace('^\\/|\\/$', '') | regex_replace('\\/|\\/', '_') }}\"\n 

Issue Type

Ansible, Collection, Docker/Podman details

ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Oct 20 2022, 09:31:56) [GCC 8.5.0 20210514 (Red Hat 8.5.0-15)]

ansible-galaxy collection list
(not supported in this version)

podman --version
Client:       Podman Engine
Version:      4.2.0
API Version:  4.2.0
Go Version:   go1.18.4
Built:        Mon Dec 12 06:41:56 2022
OS/Arch:      linux/amd64

OS / ENVIRONMENT

Desired Behavior

It should work, but fails. So the workaround was simply to remove the regex_replace filter functions from that line and that seems to work enough to get the results. Not sure the intent for those regex functions.

Actual Behavior

see above

STEPS TO REPRODUCE

- name: Playbook to create custom EE
  hosts: localhost
  gather_facts: false
  collections:
    - infra.ee_utilities
  vars:
    # venv_migrate_default_ee_url: registry.redhat.io/ansible-automation-platform-23/ee-minimal-rhel8:latest
    venv_migrate_default_ee_url: registry.redhat.io/ansible-automation-platform-23/ee-29-rhel8:latest
    venv_migrate_show_diff_with_default: true
  tasks:
    - name: Include venv_migrate role
      include_role:
        name: infra.ee_utilities.virtualenv_migrate

    - name: Display ee_list
      debug:
        var: ee_list

    - name: Export python virtual enviroment list to file
      copy:
        content: "{{ ee_list | to_nice_yaml(width=50, explicit_start=True, explicit_end=True) }}"
        dest: venv_migrate_ee_python.yaml
...