awx icon indicating copy to clipboard operation
awx copied to clipboard

update workflow module for schema node creation to look for type when finding unified job template

Open sean-m-sullivan opened this issue 2 years ago • 1 comments

SUMMARY

Fix the workflow job template collection module to account for unified job template type when searching since it is a required field. #12596

Also fixed docs and test as it had the wrong system job type name as an example.

ISSUE TYPE
  • Bug or Docs Fix
COMPONENT NAME
  • Collection
AWX VERSION
21.3.0

sean-m-sullivan avatar Jul 30 '22 05:07 sean-m-sullivan

Wanted to add my full test in case need to run again, or we want to update the tests

---
- name: Using module to create job template
  hosts: localhost
  connection: local
  gather_facts: false
  collections:
    - awx.awx
  environment:
      TOWER_HOST: https://controller
      TOWER_USERNAME: admin
      TOWER_PASSWORD: secret123
      TOWER_VERIFY_SSL: False
  tasks:
  # Can be a job_template, project, inventory_source,  workflow_job_template.
    - name: Add inventory
      awx.awx.inventory:
        name: Azure
        description: Create RHVM-01 Inventory
        organization: Default
        state: present
    - name: Create the Test project
      awx.awx.project:
        name: Azure
        scm_type: git
        scm_url: 'https://github.com/ansible/test-playbooks.git'
        scm_branch: master
        scm_clean: true
        description: Test Project
        organization: Default
        wait: true
    - name: Add inventory source
      awx.awx.inventory_source:
        name: Azure
        source: scm
        source_project: Test Project
        source_path: phillips_hue/hosts
        inventory: Basic Inventory
        organization: Default
        overwrite: true
        update_on_launch: true
        update_cache_timeout: 0
        state: present
    - name: Create Job Template
      awx.awx.job_template:
        name: Azure
        description: created by Ansible Playbook
        project: Azure
        inventory: Azure
        playbook: chatty_payload.yml
        verbosity: 2
        extra_vars:
          target_hosts: infra-ansible-01.example.com
        job_type: run
        state: present
        organization: Default
    - name: Create workflow
      awx.awx.workflow_job_template:
        name: Azure
        organization: Default
        workflow_nodes:
          - identifier: Inventory Update
            related:
              always_nodes: []
              credentials: []
              failure_nodes: []
              success_nodes:
                - identifier: Template 1
            unified_job_template:
              name: Azure
              inventory:
                organization:
                  name: Default
              type: inventory_source
            all_parents_must_converge: false
            extra_data: {}
          - identifier: Project Update
            unified_job_template:
              name: Azure
              type: project
              organization:
                name: Default
            related:
              success_nodes:
                - identifier: Template 1
          - identifier: Template 1
            unified_job_template:
              name: Azure
              type: job_template
              organization:
                name: Default
            related:
              failure_nodes:
                - identifier: Approval Node
          - identifier: Approval Node
            unified_job_template:
              description: Approval node for example
              timeout: 900
              type: workflow_approval
              name: Azure
          - identifier: Workflow demo
            unified_job_template:
              name: Azure
              organization:
                name: Default
              type: workflow_job_template
...

sean-m-sullivan avatar Jul 30 '22 13:07 sean-m-sullivan