You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/roles/awx/tasks/awx-create-job-template.yml

85 lines
2.4 KiB
YAML

---
- set_fact:
awx_job_template_id: ""
tags:
- awx_communication
- name: "Get {{jobinfo.name}} job_templates id from awx server"
include_tasks: awx-get-typ-id.yml
vars:
awx_rest_api_type: job_templates
awx_search_key: name
awx_search_name: "{{jobinfo.name}}"
awx_type_id: ""
tags:
- awx_communication
- name: "Update awx_create_database_job_template_id"
set_fact:
awx_job_template_id: "{{ awx_type_id }}"
awx_type_id: ""
when: (awx_type_id is defined) and (awx_type_id | length > 0)
no_log: true
tags:
- awx_communication
- name: "Add {{jobinfo.name}} job_template to awx server"
vars:
name: "{{jobinfo.name}}"
description: "{{jobinfo.desc}}"
inventory_id: "{{ awx_localhost_inventory_id }}"
project_id: "{{ awx_hetzner_ansible_project_id }}"
execution_environment_id: "{{ awx_ee_hetzner_ansible_id }}"
playbook: "{{jobinfo.playbook_file}}"
ask_variables_on_launch: true
uri:
url: "{{ awx_base_url }}/api/v2/job_templates/"
method: POST
user: "{{ awx_rest_api_access_user }}"
password: "{{ awx_rest_api_access_pw }}"
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: "json"
body: "{{ lookup('template','awx-add-job-template-config.json.j2') }}"
force_basic_auth: true
validate_certs: false
status_code: 200, 201
no_log: true
tags:
- awx_communication
when: >
(awx_job_template_id | default("") | length == 0) and
(awx_localhost_inventory_id is defined) and
(awx_hetzner_ansible_project_id is defined) and
(awx_ee_hetzner_ansible_id is defined)
- name: "Get {{jobinfo.name}} job_templates id from awx server"
include_tasks: awx-get-typ-id.yml
vars:
awx_rest_api_type: job_templates
awx_search_key: name
awx_search_name: "{{jobinfo.name}}"
awx_type_id: ""
tags:
- awx_communication
- name: "Update awx_job_template_id for {{jobinfo.name}}"
set_fact:
awx_job_template_id: "{{ awx_type_id }}"
awx_type_id: ""
when: >
(awx_type_id is defined) and
(awx_type_id | length > 0)
no_log: true
tags:
- awx_communication
- include_tasks: awx-add-credential-to-job-template.yml
loop: "{{ jobinfo.credentials }}"
loop_control:
loop_var: awx_credential_id
when: (jobinfo is defined) and (jobinfo.credentials is defined )
tags:
- awx_communication