-
Notifications
You must be signed in to change notification settings - Fork 20
/
adhoc-ocp-deploy-jenkins.yml
107 lines (92 loc) · 2.8 KB
/
adhoc-ocp-deploy-jenkins.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
# This playbook is to create a persistent volume for openshift CI namespace
# The node on which we'll run this should have the exported NFS volume mounted locally
# using variables from inventory:
# ocp_nfs_server: (like node.domain)
# ocp_nfs_export: ocp-staging
- hosts: ocp-admin-nodes
become: true
become_user: "{{ ocp_service_account }}"
vars_prompt:
- name: "ocp_project"
prompt: "Existing project/namespace in ocp we'll deploy jenkins to/for (has to exist before !) "
private: no
- name: "pv_size"
prompt: "Persistent Volume size (example 10Gi) "
private: no
vars:
pv_claimref: jenkins
pv_name: jenkins
tasks:
- name: Generate a UUID
set_fact:
pv_uuid: "{{ (ocp_project + '-' + pv_claimref|default('noclaimref', true)) + '-' + pv_name | to_uuid }}"
tags:
- pv
- nfs
- name: UUID Generated
debug:
var: pv_uuid
tags:
- pv
- nfs
- name: Make a pv name
set_fact:
pv_name: "pv-{{ pv_size | lower }}-{{ pv_uuid }}"
tags:
- pv
- nfs
- name: UUID Generated
debug:
var: pv_name
tags:
- pv
- nfs
- block:
- name: Ensuring we have local mount point
file:
path: /mnt/ocp_store
state: directory
- name: Ensuring nfs export is mounted on mgmt station
mount:
fstype: nfs
src: "{{ ocp_nfs_server }}:{{ ocp_nfs_export }}"
path: /mnt/ocp_store
state: mounted
- name: make directories for each PV
file:
path: "/mnt/ocp_store/{{ pv_name }}"
owner: nobody
group: nobody
mode: 0777
state: directory
become_user: root
tags:
- pv
- nfs
- name: create json files for PV
template:
src: "templates/openshift-pv-storage/pv.yml.j2"
dest: "/home/{{ ocp_service_account }}/pv_configs/{{ pv_name }}.yml"
register: pv_init
tags:
- pv
- name: apply the transformation
command:
cmd: "bin/oc create -f pv_configs/{{ pv_name }}.yml"
chdir: "/home/{{ ocp_service_account }}"
when: pv_init is changed
tags:
- pv
- name: Importing basic jenkins-ci-workspace template
template:
src: openshift/jenkins-workspace.yml
dest: "/home/{{ ocp_service_account }}/ocp_configs/{{ ocp_project }}-jenkins.yml"
tags:
- template
- name: "Deploy jenkins under namespace {{ ocp_project }}"
shell:
cmd: "bin/oc process -f ocp_configs/{{ ocp_project }}-jenkins.yml | bin/oc create -n {{ ocp_project }} -f -"
chdir: "/home/{{ ocp_service_account }}"
tags:
- deploy