Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label functionality to workflow_launch - related #15197 #15198

Closed
wants to merge 7 commits into from

Conversation

TheHasHym
Copy link

SUMMARY

The label functionality from job_launch was copied to workflow_launch.

ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • Collection
AWX VERSION
awx: 0.1.dev33974+g37e8e34

Hasse Vestergaard Hymøller added 2 commits May 16, 2024 15:03
@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX community labels May 16, 2024
@TheHasHym
Copy link
Author

related: #15197

@TheRealHaoLiu TheRealHaoLiu self-requested a review May 22, 2024 19:05
@TheRealHaoLiu
Copy link
Member

Hi @hassevgaard thanks for the contribution.

Can you provide a example and some steps that you took to test this PR

@TheRealHaoLiu
Copy link
Member

also it would be nice if you can contribute a test to cover this scenario in awx_collection/tests/integration/targets

@TheHasHym
Copy link
Author

TheHasHym commented May 27, 2024

Hi @TheRealHaoLiu,

I had a look at the GUI to find that labels could be enabled and prompted just like jobs.
When going to /api/v2/workflow_job_templates/ and going to launch a job under JOB_ID/launch/ i can see that labels is defined:
image

I have written a playbook that utilise the changes i have made to the modules to verify that the changes would work:

#!/usr/bin/env ansible-playbook

  • name: Run test workflow
    hosts: localhost
    connection: local
    gather_facts: false
    tasks:
    • name: Create a Label
      awx.awx.label:
      controller_host: "<HOST_URL>"
      controller_username: <HOST_USERNAME>
      controller_password: <HOST_PASSWORD>
      name: "My First Label"
      organization: Default
      state: present
      register: result

    • name: Debug result
      ansible.builtin.debug:
      msg: "{{ result }}"

    • name: Create a Label
      awx.awx.label:
      controller_host: "<HOST_URL>"
      controller_username: <HOST_USERNAME>
      controller_password: <HOST_PASSWORD>
      name: "My Second Label"
      organization: Default
      state: present
      register: result

    • name: Debug result
      ansible.builtin.debug:
      msg: "{{ result }}"

    • name: Demo job
      awx.awx.job_launch:
      controller_host: "<HOST_URL>"
      controller_username: <HOST_USERNAME>
      controller_password: <HOST_PASSWORD>
      job_template: "Demo_template"
      labels:
      - My First Label
      - My Second Label
      ignore_errors: true
      register: result

    • name: Debug result
      ansible.builtin.debug:
      msg: "{{ result }}"

    • name: Demo workflow
      awx.awx.workflow_launch:
      controller_host: "<HOST_URL>"
      controller_username: <HOST_USERNAME>
      controller_password: <HOST_PASSWORD>
      workflow_template: "Demo_workflow"
      labels:
      - My First Label
      - My Second Label
      ignore_errors: true
      register: result

    • name: Debug result
      ansible.builtin.debug:
      msg: "{{ result }}"

This worked as intended and spawned the workflow with the labels defined.

I have tried to write a test, please verify if it lives up to expectations.

I also implemented the test for job_launch as there was no test for labels here either.

@TheHasHym TheHasHym closed this by deleting the head repository Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community component:awx_collection issues related to the collection for controlling AWX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants