From be4b183bfd5b9a1052e50a2be1d169289d63c208 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 28 Mar 2024 14:49:14 -0400 Subject: [PATCH 1/7] Fix openapi client generation in the playbooks. No-Issue Signed-off-by: James Tanner --- .../tools/roles/pulp_client/tasks/main.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml index deb5e2b533..4c37d386ff 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml @@ -15,8 +15,16 @@ command: > cd ../../../pulp-openapi-generator; export USE_LOCAL_API_JSON=true; + export PULP_URL='https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/'; + curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/'; curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; - bash -x generate.sh {{ item }} python + if [[ "{{ item }}" == "galaxy_ng" ]]; then + export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') + export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" + else + export VERSION="" + fi; + bash -x generate.sh {{ item }} python $VERSION connection: local loop: - galaxy_ng @@ -25,7 +33,8 @@ - pulpcore - name: install the generated client inside the pulp container - shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e . + #shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e . + shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install . loop: - galaxy_ng - pulp_ansible From e3665f07b2aa76fe823c617df7491b18db902086 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 28 Mar 2024 15:23:03 -0400 Subject: [PATCH 2/7] Debug. No-Issue Signed-off-by: James Tanner --- .../galaxy_ng/tools/roles/pulp_client/tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml index 4c37d386ff..2694715501 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml @@ -19,8 +19,11 @@ curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/'; curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; if [[ "{{ item }}" == "galaxy_ng" ]]; then + cat status.json | head export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') + echo "REPORTED_VERSION: ${REPORTED_VERSION}" export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" + echo "FINAL_VERSION: ${FINAL_VERSION}" else export VERSION="" fi; @@ -33,8 +36,7 @@ - pulpcore - name: install the generated client inside the pulp container - #shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e . - shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install . + shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e . loop: - galaxy_ng - pulp_ansible From e26861f8f6a49b5eca084a4088c9568fc7ffc030 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 28 Mar 2024 15:43:27 -0400 Subject: [PATCH 3/7] Try sh brackets? No-Issue Signed-off-by: James Tanner --- .../galaxy_ng/tools/roles/pulp_client/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml index 2694715501..6ff69f1cfb 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml @@ -18,7 +18,7 @@ export PULP_URL='https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/'; curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/'; curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; - if [[ "{{ item }}" == "galaxy_ng" ]]; then + if [ "{{ item }}" == "galaxy_ng" ]; then cat status.json | head export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') echo "REPORTED_VERSION: ${REPORTED_VERSION}" From 22e6a59342b6a6ad49b3df6c96b3359c66b35edc Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 29 Mar 2024 10:11:10 -0400 Subject: [PATCH 4/7] Try a script. No-Issue Signed-off-by: James Tanner --- .../tools/roles/pulp_client/files/generate.sh | 30 ++++++++++++ .../tools/roles/pulp_client/tasks/main.yml | 49 +++++++++++++------ 2 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh new file mode 100644 index 0000000000..32ee40f1d9 --- /dev/null +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh @@ -0,0 +1,30 @@ +#!/bin/bash -x + +set -e + +PULP_IP=$1 +PLUGIN=$2 + +cd ../../.. +if [[ ! -d pulp-openapi-generator ]]; then + git clone https://github.com/pulp/pulp-openapi-generator +fi +cd pulp-openapi-generator; + +export USE_LOCAL_API_JSON=true; +export PULP_URL='https://${PULP_IP}/api/galaxy/pulp/api/v3/'; + +curl -L -k -u admin:password -o status.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/status/"; +curl -L -k -u admin:password -o api.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin=${PLUGIN}"; + +if [ "${PLUGIN}" == "galaxy_ng" ]; then + cat status.json | head + export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') + echo "REPORTED_VERSION: ${REPORTED_VERSION}" + export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" + echo "FINAL_VERSION: ${FINAL_VERSION}" +else + export VERSION="" +fi; + +bash -x generate.sh ${PLUGIN} python ${VERSION} diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml index 6ff69f1cfb..58b1b976e0 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml @@ -10,24 +10,41 @@ connection: local register: pulp_ip +#- name: run the generate script +# galaxy_ng.tools.local_run: +# command: > +# cd ../../../pulp-openapi-generator; +# export USE_LOCAL_API_JSON=true; +# export PULP_URL='https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/'; +# curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/'; +# curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; +# if [ "{{ item }}" == "galaxy_ng" ]; then +# cat status.json | head +# export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') +# echo "REPORTED_VERSION: ${REPORTED_VERSION}" +# export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" +# echo "FINAL_VERSION: ${FINAL_VERSION}" +# else +# export VERSION="" +# fi; +# bash -x generate.sh {{ item }} python $VERSION +# connection: local +# loop: +# - galaxy_ng +# - pulp_ansible +# - pulp_container +# - pulpcore + +- name: copy the generate script to a tmp location + copy: + src: generate.sh + dest: /tmp/generate.sh + mode: '0777' + connection: local + - name: run the generate script galaxy_ng.tools.local_run: - command: > - cd ../../../pulp-openapi-generator; - export USE_LOCAL_API_JSON=true; - export PULP_URL='https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/'; - curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/'; - curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}'; - if [ "{{ item }}" == "galaxy_ng" ]; then - cat status.json | head - export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"') - echo "REPORTED_VERSION: ${REPORTED_VERSION}" - export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" - echo "FINAL_VERSION: ${FINAL_VERSION}" - else - export VERSION="" - fi; - bash -x generate.sh {{ item }} python $VERSION + command: /tmp/generate.sh {{ pulp_ip.stdout }} {{ item }} connection: local loop: - galaxy_ng From d4f3dbfa2ef4401d7e34bc4264fbf1a3338047d0 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 29 Mar 2024 10:23:11 -0400 Subject: [PATCH 5/7] Oops. No-Issue Signed-off-by: James Tanner --- .../galaxy_ng/tools/roles/pulp_client/files/generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh index 32ee40f1d9..b07c5bf09b 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/files/generate.sh @@ -12,7 +12,7 @@ fi cd pulp-openapi-generator; export USE_LOCAL_API_JSON=true; -export PULP_URL='https://${PULP_IP}/api/galaxy/pulp/api/v3/'; +export PULP_URL="https://${PULP_IP}/api/galaxy/pulp/api/v3/"; curl -L -k -u admin:password -o status.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/status/"; curl -L -k -u admin:password -o api.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin=${PLUGIN}"; From f8063e0222775b149fe90fe7432fab19b3f85929 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 29 Mar 2024 10:39:10 -0400 Subject: [PATCH 6/7] Use yaml callback. No-Issue Signed-off-by: James Tanner --- .github/workflows/ci_full.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_full.yml b/.github/workflows/ci_full.yml index 14dc4ec6d1..b34b7c74fa 100644 --- a/.github/workflows/ci_full.yml +++ b/.github/workflows/ci_full.yml @@ -89,13 +89,13 @@ jobs: run: pip3 install ansible - name: run the build container playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v build_container.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v build_container.yaml - name: run the start container playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v start_container.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v start_container.yaml - name: run the unit test playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v run_unit_tests.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v run_unit_tests.yaml - name: run the functional test playbook - run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v run_functional_tests.yaml + run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v run_functional_tests.yaml From e08f164e48315e65a65b80d127c072ce166b8d2b Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 29 Mar 2024 10:41:24 -0400 Subject: [PATCH 7/7] Debug task. No-Issue Signed-off-by: James Tanner --- .../galaxy_ng/tools/roles/pulp_client/tasks/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml index 58b1b976e0..2dd597f3ba 100644 --- a/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml +++ b/dev/playbooks/collections/ansible_collections/galaxy_ng/tools/roles/pulp_client/tasks/main.yml @@ -53,9 +53,12 @@ - pulpcore - name: install the generated client inside the pulp container - shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e . + shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install . loop: - galaxy_ng - pulp_ansible - pulp_container - pulpcore + +- name: show what we eneded up with + shell: pip3 list | grep -e galaxy -e pulp -e ansible