| 1 | --- |
| 2 | - hosts: localhost |
| 3 | collections: |
| 4 | - theforeman.foreman |
| 5 | gather_facts: false |
| 6 | vars_files: |
| 7 | - vars/server.yml |
| 8 | tasks: |
| 9 | - include_tasks: tasks/organization.yml |
| 10 | vars: |
| 11 | organization_state: present |
| 12 | - include_tasks: tasks/location.yml |
| 13 | vars: |
| 14 | location_state: present |
| 15 | - include_tasks: tasks/job_template.yml |
| 16 | vars: |
| 17 | job_template_state: absent |
| 18 | - include_tasks: tasks/job_template.yml |
| 19 | vars: |
| 20 | job_template_name: "{{ item }}" |
| 21 | job_template_state: absent |
| 22 | loop: |
| 23 | - "configure flux compensator" |
| 24 | - "Ansible Roles - Hello World" |
| 25 | - "delete file" |
| 26 | |
| 27 | - hosts: tests |
| 28 | collections: |
| 29 | - theforeman.foreman |
| 30 | gather_facts: false |
| 31 | vars_files: |
| 32 | - vars/server.yml |
| 33 | tasks: |
| 34 | - include_tasks: tasks/job_template.yml |
| 35 | vars: |
| 36 | job_template_state: present |
| 37 | job_template_audit_comment: "create job template" |
| 38 | expected_change: true |
| 39 | - include_tasks: tasks/job_template.yml |
| 40 | vars: |
| 41 | job_template_state: present |
| 42 | job_template_audit_comment: "don't update job template" |
| 43 | expected_change: false |
| 44 | - include_tasks: tasks/job_template.yml |
| 45 | vars: |
| 46 | template_inputs: |
| 47 | - name: "newer input" |
| 48 | input_type: "user" |
| 49 | job_template_state: present |
| 50 | expected_change: true |
| 51 | - include_tasks: tasks/job_template.yml |
| 52 | vars: |
| 53 | job_template_template: 'A job template with an template' |
| 54 | job_template_state: present |
| 55 | expected_change: true |
| 56 | - include_tasks: tasks/job_template.yml |
| 57 | vars: |
| 58 | job_template_state: absent |
| 59 | expected_change: true |
| 60 | - include_tasks: tasks/job_template.yml |
| 61 | vars: |
| 62 | job_template_state: absent |
| 63 | expected_change: false |
| 64 | |
| 65 | - include_tasks: tasks/job_template_from_file.yml |
| 66 | vars: |
| 67 | job_template_state: present |
| 68 | job_template_file_name: "data/delete_file.erb" |
| 69 | job_template_locations: |
| 70 | - "Test Location" |
| 71 | job_template_organizations: |
| 72 | - "Test Organization" |
| 73 | expected_change: true |
| 74 | |
| 75 | - name: Add the same template input via direct input |
| 76 | include_tasks: tasks/job_template.yml |
| 77 | vars: |
| 78 | job_template_name: delete file |
| 79 | job_template_job_category: Commands |
| 80 | job_template_description_format: "delete %{file}" |
| 81 | job_template_provider_type: SSH |
| 82 | template_inputs: |
| 83 | - name: file |
| 84 | description: file to delete |
| 85 | input_type: user |
| 86 | required: true |
| 87 | job_template_template: | |
| 88 | <%# |
| 89 | kind: job_template |
| 90 | name: delete file |
| 91 | job_category: Commands |
| 92 | description_format: "delete %{file}" |
| 93 | provider_type: SSH |
| 94 | template_inputs: |
| 95 | - name: file |
| 96 | description: file to delete |
| 97 | input_type: user |
| 98 | required: true |
| 99 | %> |
| 100 | rm -rf --no-preserve-root <%= input("file") %> |
| 101 | job_template_state: present |
| 102 | expected_change: false |
| 103 | |
| 104 | - include_tasks: tasks/job_template.yml |
| 105 | vars: |
| 106 | job_template_name: delete file |
| 107 | job_template_state: absent |
| 108 | expected_change: true |
| 109 | |
| 110 | - name: Add Ansible template with implicit provider_type |
| 111 | include_tasks: tasks/job_template_from_file.yml |
| 112 | vars: |
| 113 | job_template_state: present |
| 114 | job_template_file_name: "data/ansible_hello.erb" |
| 115 | job_template_locations: |
| 116 | - "Test Location" |
| 117 | expected_change: true |
| 118 | |
| 119 | - name: Add the same template input via direct input with explicit provider_type |
| 120 | include_tasks: tasks/job_template.yml |
| 121 | vars: |
| 122 | job_template_name: Ansible Roles - Hello World |
| 123 | job_template_job_category: Ansible Playbook |
| 124 | job_template_description_format: "Test Ansible Roles" |
| 125 | job_template_provider_type: Ansible |
| 126 | job_template_organizations: "{{ omit }}" |
| 127 | template_inputs: |
| 128 | job_template_template: | |
| 129 | <%# |
| 130 | name: Ansible Roles - Hello World |
| 131 | job_category: Ansible Playbook |
| 132 | description_format: Test Ansible Roles |
| 133 | feature: ansible_run_host |
| 134 | snippet: false |
| 135 | provider_type: Ansible |
| 136 | kind: job_template |
| 137 | model: JobTemplate |
| 138 | %> |
| 139 | |
| 140 | --- |
| 141 | - hosts: all |
| 142 | tasks: |
| 143 | - name: Hello |
| 144 | debug: |
| 145 | msg: Hello World |
| 146 | ... |
| 147 | job_template_state: present |
| 148 | expected_change: false |
| 149 | - name: assign all job templates the same organization |
| 150 | include_tasks: tasks/job_template.yml |
| 151 | vars: |
| 152 | job_template_name: '*' |
| 153 | job_template_locations: "{{ omit }}" |
| 154 | job_template_provider_type: "{{ omit }}" |
| 155 | job_template_template: "{{ omit }}" |
| 156 | template_inputs: "{{ omit }}" |
| 157 | job_template_state: present |
| 158 | expected_change: true |
| 159 | - name: assign all job templates the same organization |
| 160 | include_tasks: tasks/job_template.yml |
| 161 | vars: |
| 162 | job_template_name: '*' |
| 163 | job_template_locations: "{{ omit }}" |
| 164 | job_template_provider_type: "{{ omit }}" |
| 165 | job_template_template: "{{ omit }}" |
| 166 | template_inputs: "{{ omit }}" |
| 167 | job_template_state: present |
| 168 | expected_change: false |
| 169 | |
| 170 | - include_tasks: tasks/job_template.yml |
| 171 | vars: |
| 172 | job_template_name: Ansible Roles - Hello World |
| 173 | job_template_state: absent |
| 174 | expected_change: true |
| 175 | |
| 176 | - hosts: localhost |
| 177 | collections: |
| 178 | - theforeman.foreman |
| 179 | gather_facts: false |
| 180 | vars_files: |
| 181 | - vars/server.yml |
| 182 | tasks: |
| 183 | - include_tasks: tasks/location.yml |
| 184 | vars: |
| 185 | location_state: absent |
| 186 | - include_tasks: tasks/organization.yml |
| 187 | vars: |
| 188 | organization_state: absent |
| 189 | ... |