diff --git a/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml b/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml index 3d9c147487..0d70c30bb7 100644 --- a/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml +++ b/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml @@ -14,764 +14,785 @@ approval_node_name: "AWX-Collection-tests-workflow_approval_node-{{ test_id }}" lab1: "AWX-Collection-tests-job_template-lab1-{{ test_id }}" wfjt_name: "AWX-Collection-tests-workflow_job_template-wfjt-{{ test_id }}" + webhook_wfjt_name: "AWX-Collection-tests-workflow_job_template-webhook-wfjt-{{ test_id }}" email_not: "AWX-Collection-tests-job_template-email-not-{{ test_id }}" - webhook_not: "AWX-Collection-tests-notification_template-wehbook-not-{{ test_id }}" + webhook_notification: "AWX-Collection-tests-notification_template-wehbook-not-{{ test_id }}" project_inv: "AWX-Collection-tests-inventory_source-inv-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" project_inv_source: "AWX-Collection-tests-inventory_source-inv-source-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - -- name: "Create a new organization" - organization: - name: "{{ org_name }}" - galaxy_credentials: - - Ansible Galaxy - register: result - -- name: Create an SCM Credential - credential: - name: "{{ scm_cred_name }}" - organization: Default - credential_type: Source Control - register: result - -- assert: - that: - - "result is changed" - -- name: Add email notification - notification_template: - name: "{{ email_not }}" - organization: Default - notification_type: email - notification_configuration: - username: user - password: s3cr3t - sender: tower@example.com - recipients: - - user1@example.com - host: smtp.example.com - port: 25 - use_tls: false - use_ssl: false - state: present - -- name: Add webhook notification - notification_template: - name: "{{ webhook_not }}" - organization: Default - notification_type: webhook - notification_configuration: - url: http://www.example.com/hook - headers: - X-Custom-Header: value123 - state: present - register: result - -- name: Create Labels - label: - name: "{{ lab1 }}" - organization: "{{ item }}" - loop: - - Default - - "{{ org_name }}" - -- name: Create a Demo Project - project: - name: "{{ demo_project_name }}" - organization: Default - state: present - scm_type: git - scm_url: https://github.com/ansible/ansible-tower-samples.git - scm_credential: "{{ scm_cred_name }}" - register: result - -- assert: - that: - - "result is changed" - -- name: Create a 2nd Demo Project in another org - project: - name: "{{ demo_project_name_2 }}" - organization: "{{ org_name }}" - state: present - scm_type: git - scm_url: https://github.com/ansible/ansible-tower-samples.git - scm_credential: "{{ scm_cred_name }}" - register: result - -- assert: - that: - - "result is changed" - -- name: Add an inventory - inventory: - description: Test inventory - organization: Default - name: "{{ project_inv }}" - -- name: Create a source inventory - inventory_source: - name: "{{ project_inv_source }}" - description: Source for Test inventory - inventory: "{{ project_inv }}" - source_project: "{{ demo_project_name }}" - source_path: "/inventories/inventory.ini" - overwrite: true - source: scm - register: project_inv_source_result - -- assert: - that: - - "project_inv_source_result is changed" - -- name: Create a Job Template - job_template: - name: "{{ jt1_name }}" - project: "{{ demo_project_name }}" - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: present - register: result - -- assert: - that: - - "result is changed" - -- name: Create a second Job Template - job_template: - name: "{{ jt2_name }}" - project: "{{ demo_project_name }}" - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: present - register: result - -- assert: - that: - - "result is changed" - -- name: Create a second Job Template in new org - job_template: - name: "{{ jt2_name }}" - project: "{{ demo_project_name_2 }}" - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: present - register: jt2_name_result - -- assert: - that: - - "jt2_name_result is changed" - -- name: Add a Survey to second Job Template - job_template: - name: "{{ jt2_name }}" - organization: Default - project: "{{ demo_project_name }}" - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: present - survey_enabled: true - survey_spec: '{"spec": [{"index": 0, "question_name": "my question?", "default": "mydef", "variable": "myvar", "type": "text", "required": false}], "description": "test", "name": "test"}' - register: result - -- assert: - that: - - "result is changed" - -- name: Create a workflow job template - workflow_job_template: - name: "{{ wfjt_name }}" - organization: Default - inventory: Demo Inventory - extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} - labels: - - "{{ lab1 }}" - ask_inventory_on_launch: true - ask_scm_branch_on_launch: true - ask_limit_on_launch: true - ask_variables_on_launch: true - register: result - -- assert: - that: - - "result is changed" - -- name: Create a workflow job template with bad label - workflow_job_template: - name: "{{ wfjt_name }}" - organization: Default - inventory: Demo Inventory - extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} - labels: - - label_bad - ask_inventory_on_launch: true - ask_scm_branch_on_launch: true - ask_limit_on_launch: true - ask_variables_on_launch: true - register: bad_label_results - ignore_errors: true - -- assert: - that: - - "bad_label_results.msg == 'Could not find label entry with name label_bad'" - -# Turn off ask_ * settings to test that the issue/10057 has been fixed -- name: Turn ask_* settings OFF - tower_workflow_job_template: - name: "{{ wfjt_name }}" - ask_inventory_on_launch: false - ask_scm_branch_on_launch: false - ask_limit_on_launch: false - ask_variables_on_launch: false - state: present - -- assert: - that: - - "result is changed" - -# Node actions do what the schema command used to do -- name: Create leaf node - workflow_job_template_node: - identifier: leaf - unified_job_template: "{{ jt2_name }}" - lookup_organization: "{{ org_name }}" - workflow: "{{ wfjt_name }}" - -- name: Create root node - workflow_job_template_node: - identifier: root - unified_job_template: "{{ jt1_name }}" - workflow: "{{ wfjt_name }}" - -- name: Fail if no name is set for approval - workflow_job_template_node: - identifier: approval_test - approval_node: - description: "{{ approval_node_name }}" - workflow: "{{ wfjt_name }}" - register: no_name_results - ignore_errors: true - -- assert: - that: - - "no_name_results.msg == 'Approval node name is required to create approval node.'" - -- name: Fail if absent and no identifier set - workflow_job_template_node: - approval_node: - description: "{{ approval_node_name }}" - workflow: "{{ wfjt_name }}" - state: absent - register: no_identifier_results - ignore_errors: true - -- assert: - that: - - "no_identifier_results.msg == 'missing required arguments: identifier'" - -- name: Fail if present and no unified job template set - workflow_job_template_node: - identifier: approval_test - workflow: "{{ wfjt_name }}" - register: no_unified_results - ignore_errors: true - -- assert: - that: - - "no_unified_results.msg == 'state is present but any of the following are missing: unified_job_template, approval_node, success_nodes, always_nodes, failure_nodes'" - -- name: Create approval node - workflow_job_template_node: - identifier: approval_test - approval_node: - name: "{{ approval_node_name }}" - timeout: 900 - workflow: "{{ wfjt_name }}" - -- name: Create link for root node - workflow_job_template_node: - identifier: root - workflow: "{{ wfjt_name }}" - success_nodes: - - approval_test - always_nodes: - - leaf - -- name: Delete approval node - workflow_job_template_node: - identifier: approval_test - approval_node: - name: "{{ approval_node_name }}" - state: absent - workflow: "{{ wfjt_name }}" - -- name: Add started notifications to workflow job template - workflow_job_template: - name: "{{ wfjt_name }}" - notification_templates_started: - - "{{ email_not }}" - - "{{ webhook_not }}" - register: result - -- assert: - that: - - "result is changed" - -- name: Re Add started notifications to workflow job template - workflow_job_template: - name: "{{ wfjt_name }}" - notification_templates_started: - - "{{ email_not }}" - - "{{ webhook_not }}" - register: result - -- assert: - that: - - "result is not changed" - -- name: Add success notifications to workflow job template - workflow_job_template: - name: "{{ wfjt_name }}" - notification_templates_success: - - "{{ email_not }}" - - "{{ webhook_not }}" - register: result - -- assert: - that: - - "result is changed" - -- name: Copy a workflow job template - workflow_job_template: - name: "copy_{{ wfjt_name }}" - copy_from: "{{ wfjt_name }}" - organization: Default - register: result - -- assert: - that: - - result.copied - -- name: Fail Remove "on start" webhook notification from copied workflow job template - workflow_job_template: - name: "copy_{{ wfjt_name }}" - notification_templates_started: - - "{{ email_not }}123" - register: remove_copied_workflow_node - ignore_errors: true - -- assert: - that: - - "remove_copied_workflow_node is failed" - - "remove_copied_workflow_node is not changed" - - "'returned 0 items' in remove_copied_workflow_node.msg" - -- name: Remove "on start" webhook notification from copied workflow job template - workflow_job_template: - name: "copy_{{ wfjt_name }}" - notification_templates_started: - - "{{ email_not }}" - register: result - -- assert: - that: - - "result is changed" - -- name: Add Survey to Copied workflow job template - workflow_job_template: - name: "copy_{{ wfjt_name }}" - organization: Default - survey_spec: - name: Basic Survey - description: Basic Survey - spec: - - question_description: Name - min: 0 - default: '' - max: 128 - required: true - choices: '' - new_question: true - variable: basic_name - question_name: Basic Name - type: text - - question_description: Choosing yes or no. - min: 0 - default: 'yes' - max: 0 - required: true - choices: |- - yes - no - new_question: true - variable: option_true_false - question_name: Choose yes or no? - type: multiplechoice - - question_description: '' - min: 0 - default: '' - max: 0 - required: true - choices: |- - group1 - group2 - group3 - new_question: true - variable: target_groups - question_name: 'Select Group:' - type: multiselect - - question_name: password - question_description: '' - required: true - type: password - variable: password - min: 0 - max: 1024 - default: '' - choices: '' - new_question: true - register: result - -- assert: - that: - - "result is changed" - -- name: Re add survey to workflow job template expected not changed. - workflow_job_template: - name: "copy_{{ wfjt_name }}" - organization: Default - survey_spec: - name: Basic Survey - description: Basic Survey - spec: - - question_description: Name - min: 0 - default: '' - max: 128 - required: true - choices: '' - new_question: true - variable: basic_name - question_name: Basic Name - type: text - - question_description: Choosing yes or no. - min: 0 - default: 'yes' - max: 0 - required: true - choices: |- - yes - no - new_question: true - variable: option_true_false - question_name: Choose yes or no? - type: multiplechoice - - question_description: '' - min: 0 - default: '' - max: 0 - required: true - choices: |- - group1 - group2 - group3 - new_question: true - variable: target_groups - question_name: 'Select Group:' - type: multiselect - - question_name: password - question_description: '' - required: true - type: password - variable: password - min: 0 - max: 1024 - default: '' - choices: '' - new_question: true - register: result - -- assert: - that: - - "result is not changed" - -- name: Delete copied workflow job template - workflow_job_template: - name: "copy_{{ wfjt_name }}" - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Remove "on start" webhook notification from workflow job template - workflow_job_template: - name: "{{ wfjt_name }}" - notification_templates_started: - - "{{ email_not }}" - register: result - -- assert: - that: - - "result is changed" - -- name: Delete a workflow job template with an invalid inventory and webook_credential - workflow_job_template: - name: "{{ wfjt_name }}" - inventory: "Does Not Exist" - webhook_credential: "Does Not Exist" - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Check module fails with correct msg - workflow_job_template: - name: "{{ wfjt_name }}" - organization: Non_Existing_Organization - register: result - ignore_errors: true - -- assert: - that: - - "result is failed" - - "result is not changed" - - "'Non_Existing_Organization' in result.msg" - - "result.total_results == 0" - -- name: Create a workflow job template with workflow nodes in template - awx.awx.workflow_job_template: - name: "{{ wfjt_name }}" - inventory: Demo Inventory - extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} - schema: - - identifier: node101 - unified_job_template: - name: "{{ project_inv_source_result.id }}" - inventory: - organization: - name: Default - type: inventory_source - related: - failure_nodes: - - identifier: node201 - - identifier: node201 - unified_job_template: - organization: - name: Default - name: "{{ jt1_name }}" - type: job_template - credentials: [] - related: - success_nodes: - - identifier: node301 - - identifier: node202 - unified_job_template: - organization: - name: Default - name: "{{ demo_project_name }}" - type: project - - all_parents_must_converge: false - identifier: node301 - unified_job_template: - organization: - name: Default - name: "{{ jt2_name }}" - type: job_template - - identifier: Cleanup Job - unified_job_template: - name: Cleanup Activity Stream - type: system_job - register: result - -- assert: - that: - - "result is changed" - -- name: Kick off a workflow and wait for it - workflow_launch: - workflow_template: "{{ wfjt_name }}" - ignore_errors: true - register: result - -- assert: - that: - - result is not failed - - "'id' in result['job_info']" - -- name: Destroy previous workflow nodes for one that fails - awx.awx.workflow_job_template: - name: "{{ wfjt_name }}" - destroy_current_nodes: true - workflow_nodes: - - identifier: node101 - unified_job_template: - organization: - name: Default - name: "{{ jt1_name }}" - type: job_template - credentials: [] - related: - success_nodes: - - identifier: node201 - - identifier: node201 - unified_job_template: - name: "{{ project_inv_source }}" - inventory: - organization: - name: Default - type: inventory_source - - identifier: Workflow inception - unified_job_template: - name: "{{ wfjt_name }}" - organization: - name: Default - type: workflow_job_template - register: result - -- name: Kick off a workflow and wait for it - workflow_launch: - workflow_template: "{{ wfjt_name }}" - ignore_errors: true - register: result - -- assert: - that: - - result is failed - -- name: Delete a workflow job template - awx.awx.workflow_job_template: - name: "{{ wfjt_name }}" - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Delete the Job Template - job_template: - name: "{{ jt1_name }}" - project: "{{ demo_project_name }}" - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Delete the second Job Template - job_template: - name: "{{ jt2_name }}" - project: "{{ demo_project_name }}" - organization: Default - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Delete the second Job Template - job_template: - name: "{{ jt2_name }}" - project: "{{ demo_project_name_2 }}" - organization: "{{ org_name }}" - inventory: Demo Inventory - playbook: hello_world.yml - job_type: run - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Delete the inventory source - inventory_source: - name: "{{ project_inv_source }}" - inventory: "{{ project_inv }}" - source: scm - state: absent - -- assert: - that: - - "result is changed" - -- name: Delete the inventory - inventory: - description: Test inventory - organization: Default - name: "{{ project_inv }}" - state: absent - -- assert: - that: - - "result is changed" - -- name: Delete the Demo Project - project: - name: "{{ demo_project_name }}" - organization: Default - scm_type: git - scm_url: https://github.com/ansible/ansible-tower-samples.git - scm_credential: "{{ scm_cred_name }}" - state: absent - register: result - -- name: Delete the 2nd Demo Project - project: - name: "{{ demo_project_name_2 }}" - organization: "{{ org_name }}" - scm_type: git - scm_url: https://github.com/ansible/ansible-tower-samples.git - scm_credential: "{{ scm_cred_name }}" - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Delete the SCM Credential - credential: - name: "{{ scm_cred_name }}" - organization: Default - credential_type: Source Control - state: absent - register: result - -- assert: - that: - - "result is changed" - -- name: Delete email notification - notification_template: - name: "{{ email_not }}" - organization: Default - state: absent - -- name: Delete webhook notification - notification_template: - name: "{{ webhook_not }}" - organization: Default - state: absent - -- name: "Remove the organization" - organization: - name: "{{ org_name }}" - state: absent - register: result + github_webhook_credential_name: "AWX-Collection-tests-credential-webhook-{{ test_id }}_github" + +- block: + - name: "Create a new organization" + organization: + name: "{{ org_name }}" + galaxy_credentials: + - Ansible Galaxy + register: result + + - name: Create Credentials + credential: + name: "{{ item.name }}" + organization: Default + credential_type: "{{ item.type }}" + register: result + loop: + - name: "{{ scm_cred_name }}" + type: Source Control + - name: "{{ github_webhook_credential_name }}" + type: GitHub Personal Access Token + + - assert: + that: + - "result is changed" + + - name: Add email notification + notification_template: + name: "{{ email_not }}" + organization: Default + notification_type: email + notification_configuration: + username: user + password: s3cr3t + sender: tower@example.com + recipients: + - user1@example.com + host: smtp.example.com + port: 25 + use_tls: false + use_ssl: false + state: present + + - name: Add webhook notification + notification_template: + name: "{{ webhook_notification }}" + organization: Default + notification_type: webhook + notification_configuration: + url: http://www.example.com/hook + headers: + X-Custom-Header: value123 + state: present + register: result + + - name: Create Labels + label: + name: "{{ lab1 }}" + organization: "{{ item }}" + loop: + - Default + - "{{ org_name }}" + + - name: Create a Demo Project + project: + name: "{{ demo_project_name }}" + organization: Default + state: present + scm_type: git + scm_url: https://github.com/ansible/ansible-tower-samples.git + scm_credential: "{{ scm_cred_name }}" + register: result + + - assert: + that: + - "result is changed" + + - name: Create a 2nd Demo Project in another org + project: + name: "{{ demo_project_name_2 }}" + organization: "{{ org_name }}" + state: present + scm_type: git + scm_url: https://github.com/ansible/ansible-tower-samples.git + scm_credential: "{{ scm_cred_name }}" + register: result + + - assert: + that: + - "result is changed" + + - name: Add an inventory + inventory: + description: Test inventory + organization: Default + name: "{{ project_inv }}" + + - name: Create a source inventory + inventory_source: + name: "{{ project_inv_source }}" + description: Source for Test inventory + inventory: "{{ project_inv }}" + source_project: "{{ demo_project_name }}" + source_path: "/inventories/inventory.ini" + overwrite: true + source: scm + register: project_inv_source_result + + - assert: + that: + - "project_inv_source_result is changed" + + - name: Create a Job Template + job_template: + name: "{{ jt1_name }}" + project: "{{ demo_project_name }}" + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: present + register: result + + - assert: + that: + - "result is changed" + + - name: Create a second Job Template + job_template: + name: "{{ jt2_name }}" + project: "{{ demo_project_name }}" + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: present + register: result + + - assert: + that: + - "result is changed" + + - name: Create a second Job Template in new org + job_template: + name: "{{ jt2_name }}" + project: "{{ demo_project_name_2 }}" + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: present + register: jt2_name_result + + - assert: + that: + - "jt2_name_result is changed" + + - name: Add a Survey to second Job Template + job_template: + name: "{{ jt2_name }}" + organization: Default + project: "{{ demo_project_name }}" + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: present + survey_enabled: true + survey_spec: '{"spec": [{"index": 0, "question_name": "my question?", "default": "mydef", "variable": "myvar", "type": "text", "required": false}], "description": "test", "name": "test"}' + register: result + + - assert: + that: + - "result is changed" + + - name: Create a workflow job template + workflow_job_template: + name: "{{ wfjt_name }}" + organization: Default + inventory: Demo Inventory + extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} + labels: + - "{{ lab1 }}" + ask_inventory_on_launch: true + ask_scm_branch_on_launch: true + ask_limit_on_launch: true + ask_variables_on_launch: true + register: result + + - assert: + that: + - "result is changed" + + - name: Create a workflow job template with bad label + workflow_job_template: + name: "{{ wfjt_name }}" + organization: Default + inventory: Demo Inventory + extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} + labels: + - label_bad + ask_inventory_on_launch: true + ask_scm_branch_on_launch: true + ask_limit_on_launch: true + ask_variables_on_launch: true + register: bad_label_results + ignore_errors: true + + - assert: + that: + - "bad_label_results.msg == 'Could not find label entry with name label_bad'" + + # Turn off ask_ * settings to test that the issue/10057 has been fixed + - name: Turn ask_* settings OFF + tower_workflow_job_template: + name: "{{ wfjt_name }}" + ask_inventory_on_launch: false + ask_scm_branch_on_launch: false + ask_limit_on_launch: false + ask_variables_on_launch: false + state: present + + - assert: + that: + - "result is changed" + + # Node actions do what the schema command used to do + - name: Create leaf node + workflow_job_template_node: + identifier: leaf + unified_job_template: "{{ jt2_name }}" + lookup_organization: "{{ org_name }}" + workflow: "{{ wfjt_name }}" + + - name: Create root node + workflow_job_template_node: + identifier: root + unified_job_template: "{{ jt1_name }}" + workflow: "{{ wfjt_name }}" + + - name: Fail if no name is set for approval + workflow_job_template_node: + identifier: approval_test + approval_node: + description: "{{ approval_node_name }}" + workflow: "{{ wfjt_name }}" + register: no_name_results + ignore_errors: true + + - assert: + that: + - "no_name_results.msg == 'Approval node name is required to create approval node.'" + + - name: Fail if absent and no identifier set + workflow_job_template_node: + approval_node: + description: "{{ approval_node_name }}" + workflow: "{{ wfjt_name }}" + state: absent + register: no_identifier_results + ignore_errors: true + + - assert: + that: + - "no_identifier_results.msg == 'missing required arguments: identifier'" + + - name: Fail if present and no unified job template set + workflow_job_template_node: + identifier: approval_test + workflow: "{{ wfjt_name }}" + register: no_unified_results + ignore_errors: true + + - assert: + that: + - "no_unified_results.msg == 'state is present but any of the following are missing: unified_job_template, approval_node, success_nodes, always_nodes, failure_nodes'" + + - name: Create approval node + workflow_job_template_node: + identifier: approval_test + approval_node: + name: "{{ approval_node_name }}" + timeout: 900 + workflow: "{{ wfjt_name }}" + + - name: Create link for root node + workflow_job_template_node: + identifier: root + workflow: "{{ wfjt_name }}" + success_nodes: + - approval_test + always_nodes: + - leaf + + - name: Delete approval node + workflow_job_template_node: + identifier: approval_test + approval_node: + name: "{{ approval_node_name }}" + state: absent + workflow: "{{ wfjt_name }}" + + - name: Add started notifications to workflow job template + workflow_job_template: + name: "{{ wfjt_name }}" + notification_templates_started: + - "{{ email_not }}" + - "{{ webhook_notification }}" + register: result + + - assert: + that: + - "result is changed" + + - name: Re Add started notifications to workflow job template + workflow_job_template: + name: "{{ wfjt_name }}" + notification_templates_started: + - "{{ email_not }}" + - "{{ webhook_notification }}" + register: result + + - assert: + that: + - "result is not changed" + + - name: Add success notifications to workflow job template + workflow_job_template: + name: "{{ wfjt_name }}" + notification_templates_success: + - "{{ email_not }}" + - "{{ webhook_notification }}" + register: result + + - assert: + that: + - "result is changed" + + - name: Copy a workflow job template + workflow_job_template: + name: "copy_{{ wfjt_name }}" + copy_from: "{{ wfjt_name }}" + organization: Default + register: result + + - assert: + that: + - result.copied + + - name: Fail Remove "on start" webhook notification from copied workflow job template + workflow_job_template: + name: "copy_{{ wfjt_name }}" + notification_templates_started: + - "{{ email_not }}123" + register: remove_copied_workflow_node + ignore_errors: true + + - assert: + that: + - "remove_copied_workflow_node is failed" + - "remove_copied_workflow_node is not changed" + - "'returned 0 items' in remove_copied_workflow_node.msg" + + - name: Remove "on start" webhook notification from copied workflow job template + workflow_job_template: + name: "copy_{{ wfjt_name }}" + notification_templates_started: + - "{{ email_not }}" + register: result + + - assert: + that: + - "result is changed" + + - name: Add Survey to Copied workflow job template + workflow_job_template: + name: "copy_{{ wfjt_name }}" + organization: Default + survey_spec: + name: Basic Survey + description: Basic Survey + spec: + - question_description: Name + min: 0 + default: '' + max: 128 + required: true + choices: '' + new_question: true + variable: basic_name + question_name: Basic Name + type: text + - question_description: Choosing yes or no. + min: 0 + default: 'yes' + max: 0 + required: true + choices: |- + yes + no + new_question: true + variable: option_true_false + question_name: Choose yes or no? + type: multiplechoice + - question_description: '' + min: 0 + default: '' + max: 0 + required: true + choices: |- + group1 + group2 + group3 + new_question: true + variable: target_groups + question_name: 'Select Group:' + type: multiselect + - question_name: password + question_description: '' + required: true + type: password + variable: password + min: 0 + max: 1024 + default: '' + choices: '' + new_question: true + register: result + + - assert: + that: + - "result is changed" + + - name: Re add survey to workflow job template expected not changed. + workflow_job_template: + name: "copy_{{ wfjt_name }}" + organization: Default + survey_spec: + name: Basic Survey + description: Basic Survey + spec: + - question_description: Name + min: 0 + default: '' + max: 128 + required: true + choices: '' + new_question: true + variable: basic_name + question_name: Basic Name + type: text + - question_description: Choosing yes or no. + min: 0 + default: 'yes' + max: 0 + required: true + choices: |- + yes + no + new_question: true + variable: option_true_false + question_name: Choose yes or no? + type: multiplechoice + - question_description: '' + min: 0 + default: '' + max: 0 + required: true + choices: |- + group1 + group2 + group3 + new_question: true + variable: target_groups + question_name: 'Select Group:' + type: multiselect + - question_name: password + question_description: '' + required: true + type: password + variable: password + min: 0 + max: 1024 + default: '' + choices: '' + new_question: true + register: result + + - assert: + that: + - "result is not changed" + + - name: Remove "on start" webhook notification from workflow job template + workflow_job_template: + name: "{{ wfjt_name }}" + notification_templates_started: + - "{{ email_not }}" + register: result + + - assert: + that: + - "result is changed" + + - name: Delete a workflow job template with an invalid inventory and webook_credential + workflow_job_template: + name: "{{ wfjt_name }}" + inventory: "Does Not Exist" + webhook_credential: "Does Not Exist" + state: absent + register: result + + - assert: + that: + - "result is changed" + + - name: Check module fails with correct msg + workflow_job_template: + name: "{{ wfjt_name }}" + organization: Non_Existing_Organization + register: result + ignore_errors: true + + - assert: + that: + - "result is failed" + - "result is not changed" + - "'Non_Existing_Organization' in result.msg" + - "result.total_results == 0" + + - name: Create a workflow job template with workflow nodes in template + awx.awx.workflow_job_template: + name: "{{ wfjt_name }}" + inventory: Demo Inventory + extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} + schema: + - identifier: node101 + unified_job_template: + name: "{{ project_inv_source_result.id }}" + inventory: + organization: + name: Default + type: inventory_source + related: + failure_nodes: + - identifier: node201 + - identifier: node201 + unified_job_template: + organization: + name: Default + name: "{{ jt1_name }}" + type: job_template + credentials: [] + related: + success_nodes: + - identifier: node301 + - identifier: node202 + unified_job_template: + organization: + name: Default + name: "{{ demo_project_name }}" + type: project + - all_parents_must_converge: false + identifier: node301 + unified_job_template: + organization: + name: Default + name: "{{ jt2_name }}" + type: job_template + - identifier: Cleanup Job + unified_job_template: + name: Cleanup Activity Stream + type: system_job + register: result + + - assert: + that: + - "result is changed" + + - name: Kick off a workflow and wait for it + workflow_launch: + workflow_template: "{{ wfjt_name }}" + ignore_errors: true + register: result + + - assert: + that: + - result is not failed + - "'id' in result['job_info']" + + - name: Destroy previous workflow nodes for one that fails + awx.awx.workflow_job_template: + name: "{{ wfjt_name }}" + destroy_current_nodes: true + workflow_nodes: + - identifier: node101 + unified_job_template: + organization: + name: Default + name: "{{ jt1_name }}" + type: job_template + credentials: [] + related: + success_nodes: + - identifier: node201 + - identifier: node201 + unified_job_template: + name: "{{ project_inv_source }}" + inventory: + organization: + name: Default + type: inventory_source + - identifier: Workflow inception + unified_job_template: + name: "copy_{{ wfjt_name }}" + organization: + name: Default + type: workflow_job_template + register: result + + - name: Delete copied workflow job template + workflow_job_template: + name: "copy_{{ wfjt_name }}" + state: absent + register: result + + - assert: + that: + - "result is changed" + + - name: Kick off a workflow and wait for it + workflow_launch: + workflow_template: "{{ wfjt_name }}" + ignore_errors: true + register: result + + - assert: + that: + - result is failed + + - name: Create a workflow job template with a GitLab webhook but a GitHub credential + workflow_job_template: + name: "{{ webhook_wfjt_name }}" + organization: Default + inventory: Demo Inventory + webhook_service: gitlab + webhook_credential: "{{ github_webhook_credential_name }}" + ignore_errors: true + register: result + + - assert: + that: + - result is failed + - "'Must match the selected webhook service' in result['msg']" + + - name: Create a workflow job template with a GitHub webhook and a GitHub credential + workflow_job_template: + name: "{{ webhook_wfjt_name }}" + organization: Default + inventory: Demo Inventory + webhook_service: github + webhook_credential: "{{ github_webhook_credential_name }}" + register: result + + - assert: + that: + - result is not failed + + always: + - name: Delete the workflow job template + awx.awx.workflow_job_template: + name: "{{ item }}" + state: absent + ignore_errors: True + loop: + - "copy_{{ wfjt_name }}" + - "{{ wfjt_name }}" + - "{{ webhook_wfjt_name }}" + + - name: Delete the Job Template + job_template: + name: "{{ jt1_name }}" + project: "{{ demo_project_name }}" + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: absent + ignore_errors: True + + - name: Delete the second Job Template + job_template: + name: "{{ jt2_name }}" + project: "{{ demo_project_name }}" + organization: Default + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: absent + ignore_errors: True + + - name: Delete the second Job Template + job_template: + name: "{{ jt2_name }}" + project: "{{ demo_project_name_2 }}" + organization: "{{ org_name }}" + inventory: Demo Inventory + playbook: hello_world.yml + job_type: run + state: absent + ignore_errors: True + + - name: Delete the inventory source + inventory_source: + name: "{{ project_inv_source }}" + inventory: "{{ project_inv }}" + source: scm + state: absent + ignore_errors: True + + - name: Delete the inventory + inventory: + description: Test inventory + organization: Default + name: "{{ project_inv }}" + state: absent + ignore_errors: True + + - name: Delete the Demo Project + project: + name: "{{ demo_project_name }}" + organization: Default + scm_type: git + scm_url: https://github.com/ansible/ansible-tower-samples.git + scm_credential: "{{ scm_cred_name }}" + state: absent + ignore_errors: True + + - name: Delete the 2nd Demo Project + project: + name: "{{ demo_project_name_2 }}" + organization: "{{ org_name }}" + scm_type: git + scm_url: https://github.com/ansible/ansible-tower-samples.git + scm_credential: "{{ scm_cred_name }}" + state: absent + ignore_errors: True + + - name: Delete the SCM Credential + credential: + name: "{{ scm_cred_name }}" + organization: Default + credential_type: Source Control + state: absent + ignore_errors: True + + - name: Delete the GitHub Webhook Credential + credential: + name: "{{ github_webhook_credential_name }}" + organization: Default + credential_type: GitHub Personal Access Token + state: absent + ignore_errors: True + + - name: Delete email notification + notification_template: + name: "{{ email_not }}" + organization: Default + state: absent + ignore_errors: True + + - name: Delete webhook notification + notification_template: + name: "{{ webhook_notification }}" + organization: Default + state: absent + ignore_errors: True + + - name: "Remove the organization" + organization: + name: "{{ org_name }}" + state: absent + ignore_errors: True