2024-11-27 13:48:08 +10:00
|
|
|
---
|
2024-11-28 17:48:13 +01:00
|
|
|
- name: Validate the job name {{ job_name }}
|
2024-08-06 07:49:53 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2024-11-28 17:48:13 +01:00
|
|
|
- job_name is defined
|
|
|
|
fail_msg: "The 'job_name' variable is not defined"
|
2024-08-06 07:49:53 +02:00
|
|
|
|
2024-11-28 17:48:13 +01:00
|
|
|
- name: Validate the command {{ job_command }}
|
2024-08-06 07:49:53 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2024-11-28 17:48:13 +01:00
|
|
|
- job_command is defined
|
|
|
|
fail_msg: "The 'job_command' variable is not defined"
|
2024-08-06 07:49:53 +02:00
|
|
|
|
|
|
|
- name: Copy job template to a temporary file
|
|
|
|
template:
|
2024-11-28 17:48:13 +01:00
|
|
|
src: "{{roles_path}}/openshift-apps/{{job_app}}/templates/{{job_template}}"
|
|
|
|
dest: "/etc/openshift_apps/{{job_app}}/job-{{job_name}}.yml"
|
2024-08-06 07:49:53 +02:00
|
|
|
|
|
|
|
- name: Delete previous job (if any)
|
2024-12-19 16:42:30 +10:00
|
|
|
ansible.builtin.shell: oc -n {{os_app}} delete --ignore-not-found=true -f /etc/openshift_apps/{{job_app}}/job-{{job_name}}.yml
|
2024-08-06 07:49:53 +02:00
|
|
|
|
|
|
|
- name: Start job
|
2024-12-19 16:42:30 +10:00
|
|
|
ansible.builtin.shell: oc -n {{os_app}} create -f /etc/openshift_apps/{{job_app}}/job-{{job_name}}.yml
|
2024-08-06 07:49:53 +02:00
|
|
|
|
|
|
|
- debug:
|
2024-11-28 17:48:13 +01:00
|
|
|
msg: "Job started. You can watch the logs with: oc -n {{os_app}} logs -f job/job-{{job_name}}"
|
2024-08-06 07:49:53 +02:00
|
|
|
- debug:
|
2024-11-28 17:48:13 +01:00
|
|
|
msg: "You can cancel it with: oc -n {{os_app}} delete job/job-{{job_name}}"
|
2024-08-06 07:49:53 +02:00
|
|
|
|
|
|
|
- name: Wait for job to complete
|
2024-12-19 16:42:30 +10:00
|
|
|
ansible.builtin.shell: oc -n {{os_app}} wait job/job-{{job_name}} --for condition=complete
|