mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-03-20 03:57:02 +08:00
Create a role to run jobs in OpenShift
Inspired by Koschei's `koschei/job` role. Adapt the MirrorManager move-to-archive job to it. Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
This commit is contained in:
2
roles/openshift/job/defaults/main.yml
Normal file
2
roles/openshift/job/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
os_app: "{{app}}"
|
||||
template: job.yml
|
||||
30
roles/openshift/job/tasks/main.yml
Normal file
30
roles/openshift/job/tasks/main.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
- name: Validate the job name {{ name }}
|
||||
assert:
|
||||
that:
|
||||
- name is defined
|
||||
fail_msg: "The 'name' variable is not defined"
|
||||
|
||||
- name: Validate the command {{ command }}
|
||||
assert:
|
||||
that:
|
||||
- command is defined
|
||||
fail_msg: "The 'command' variable is not defined"
|
||||
|
||||
- name: Copy job template to a temporary file
|
||||
template:
|
||||
src: "{{roles_path}}/openshift-apps/{{app}}/templates/{{template}}"
|
||||
dest: "/etc/openshift_apps/{{app}}/job-{{name}}.yml"
|
||||
|
||||
- name: Delete previous job (if any)
|
||||
shell: oc -n {{os_app}} delete --ignore-not-found=true -f /etc/openshift_apps/{{app}}/job-{{name}}.yml
|
||||
|
||||
- name: Start job
|
||||
shell: oc -n {{os_app}} create -f /etc/openshift_apps/{{app}}/job-{{name}}.yml
|
||||
|
||||
- debug:
|
||||
msg: "Job started. You can watch the logs with: oc -n {{os_app}} logs -f job/job-{{name}}"
|
||||
- debug:
|
||||
msg: "You can cancel it with: oc -n {{os_app}} delete job/job-{{name}}"
|
||||
|
||||
- name: Wait for job to complete
|
||||
shell: oc -n {{os_app}} wait job/job-{{name}} --for condition=complete
|
||||
Reference in New Issue
Block a user