-
Notifications
You must be signed in to change notification settings - Fork 8
/
create_object.yml
54 lines (44 loc) · 1.55 KB
/
create_object.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
# This playbook pushes a k8s definition file for a project.
#
# A definition file is generated and pushed for a template given the
# `object_template` path.
#
# Usage:
#
# $ bin/ansible-playbook create_object.yml \
# -e "object_template=apps/edxapp/job/import_demo_course.yml.j2"
# -e "deployment_stamp=d-180611-08h46m30s"
#
- name: Create object
hosts: local
gather_facts: false
vars:
object_template: ""
pre_tasks:
- name: Check configuration
ansible.builtin.import_tasks: tasks/check_configuration.yml
tasks:
- name: Display playbook name
ansible.builtin.debug: msg="==== Starting create_object playbook ===="
tags: deploy
- name: Set vars
ansible.builtin.import_tasks: tasks/set_vars.yml
- name: Print OpenShift object template path
ansible.builtin.debug: msg="Object template {{ object_template }}"
- name: Print deployment stamp
ansible.builtin.debug: msg="Deployment stamp {{ deployment_stamp }}"
# Set the job stamp for this object (only used for jobs)
- name: Set job stamp
ansible.builtin.set_fact: job_stamp="j-{{ lookup('pipe', 'date +%y%m%d-%Hh%Mm%Ss') }}"
- name: Print job stamp
ansible.builtin.debug: msg="Job stamp {{ job_stamp }}"
- name: Print compiled template
ansible.builtin.debug:
msg: "{{ lookup('template', object_template) }}"
verbosity: 2
- name: Create object
kubernetes.core.k8s:
definition: "{{ lookup('template', object_template) | from_yaml_all }}"
state: present
force: true