--- - name: Generate a random string for test set_fact: test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - name: generate random string for schedule set_fact: org_name: "AWX-Collection-tests-organization-org-{{ test_id }}" sched1: "AWX-Collection-tests-schedule-sched1-{{ test_id }}" cred1: "AWX-Collection-tests-schedule-cred1-{{ test_id }}" proj1: "AWX-Collection-tests-schedule-proj1-{{ test_id }}" proj2: "AWX-Collection-tests-schedule-proj2-{{ test_id }}" jt1: "AWX-Collection-tests-schedule-jt1-{{ test_id }}" jt2: "AWX-Collection-tests-schedule-jt1-{{ test_id }}" - block: - name: Try to create without an rrule schedule: name: "{{ sched1 }}" state: present unified_job_template: "Demo Job Template" enabled: true register: result ignore_errors: true - assert: that: - result is failed - "'Unable to create schedule {{ sched1 }}' in result.msg" - name: Create with options that the JT does not support schedule: name: "{{ sched1 }}" state: present unified_job_template: "Demo Job Template" rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1" description: "This hopefully will not work" extra_data: some: var inventory: Demo Inventory scm_branch: asdf1234 job_type: run job_tags: other_tags skip_tags: some_tags limit: node1 diff_mode: true verbosity: 4 enabled: true register: result ignore_errors: true - assert: that: - result is failed - "'Unable to create schedule {{ sched1 }}' in result.msg" - name: Build a real schedule schedule: name: "{{ sched1 }}" state: present unified_job_template: "Demo Job Template" rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1" register: result - assert: that: - result is changed - name: Rebuild the same schedule schedule: name: "{{ sched1 }}" state: present unified_job_template: "Demo Job Template" rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1" register: result - assert: that: - result is not changed - name: Create a Demo Project project: name: "{{ proj1 }}" organization: Default allow_override: true state: present scm_type: git scm_url: https://github.com/ansible/ansible-tower-samples.git - name: "Create a new organization" organization: name: "{{ org_name }}" - name: Create a Demo Project in another org project: name: "{{ proj2 }}" organization: "{{ org_name }}" allow_override: true state: present scm_type: git scm_url: https://github.com/ansible/ansible-tower-samples.git - name: Create Credential1 credential: name: "{{ cred1 }}" organization: Default credential_type: Red Hat Ansible Automation Platform register: cred1_result - name: Create Job Template with all prompts job_template: name: "{{ jt1 }}" organization: Default project: "{{ proj1 }}" inventory: Demo Inventory playbook: hello_world.yml ask_variables_on_launch: true ask_inventory_on_launch: true ask_scm_branch_on_launch: true ask_credential_on_launch: true ask_job_type_on_launch: true ask_tags_on_launch: true ask_skip_tags_on_launch: true ask_limit_on_launch: true ask_diff_mode_on_launch: true ask_verbosity_on_launch: true job_type: run state: present register: result - assert: that: - "result is changed" - name: Create with options that the JT does support schedule: name: "{{ sched1 }}" state: present unified_job_template: "{{ jt1 }}" rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1" description: "This hopefully will not work" extra_data: some: var inventory: Demo Inventory scm_branch: asdf1234 credentials: - "{{ cred1 }}" job_type: run job_tags: other_tags skip_tags: some_tags limit: node1 diff_mode: true verbosity: 4 enabled: true register: result ignore_errors: true - assert: that: - "result is changed" - name: Disable a schedule schedule: name: "{{ sched1 }}" state: present enabled: "false" register: result - assert: that: - result is changed - name: Create a second Job Template in new org job_template: name: "{{ jt2 }}" project: "{{ proj2 }}" inventory: Demo Inventory playbook: hello_world.yml job_type: run state: present - name: Build a schedule with a job template's name in two orgs schedule: name: "{{ sched1 }}" state: present unified_job_template: "{{ jt2 }}" rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1" register: result always: - name: Delete the schedule schedule: name: "{{ sched1 }}" state: absent - name: Delete the jt job_template: name: "{{ jt1 }}" project: "{{ proj1 }}" playbook: hello_world.yml state: absent - name: Delete the jt job_template: name: "{{ jt2 }}" project: "{{ proj2 }}" playbook: hello_world.yml state: absent - name: Delete the Project project: name: "{{ proj2 }}" organization: "{{ org_name }}" state: absent scm_type: git scm_url: https://github.com/ansible/ansible-tower-samples.git register: result - name: Delete the Project project: name: "{{ proj1 }}" organization: Default state: absent scm_type: git scm_url: https://github.com/ansible/ansible-tower-samples.git register: result - name: Delete Credential1 credential: name: "{{ cred1 }}" organization: Default credential_type: Red Hat Ansible Automation Platform state: absent - name: "Remove the organization" organization: name: "{{ org_name }}" state: absent register: result