-
Notifications
You must be signed in to change notification settings - Fork 41
/
main.yml
81 lines (68 loc) · 2.06 KB
/
main.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
---
- name: Project Bootstrap
hosts: all
tasks:
- name: Locate oc client
find:
paths: "{{ ansible_env['PATH'].split(':') }}"
patterns: 'oc'
register: oc_cmd
- set_fact:
oc_path: "{{ oc_cmd.files[0]['path'] }}"
when: oc_cmd.matched != 0
- set_fact:
enable_dockercfg_workaround: True
when: oc_cmd.matched == 0
- name: Bugzilla 1531511, 1476330, Github 18062 Workaround
block:
- name: Download Origin v3.6.1 client
get_url:
url: "{{ oc_url }}"
dest: "{{ oc_extract_dest }}/oc-client.tar"
- name: Extract oc
unarchive:
src: "{{ oc_extract_dest }}/oc-client.tar"
dest: "{{ oc_extract_dest }}"
extra_opts:
- "--strip-components=1"
delegate_to: localhost
when: enable_dockercfg_workaround
run_once: True
- set_fact:
oc_path: "{{ oc_extract_dest }}/oc"
when: enable_dockercfg_workaround
- name: Get User Token
uri:
url: "https://{{ clusterhost }}/oauth/authorize?response_type=token&client_id=openshift-challenging-client"
user: "{{ openshift_username }}"
password: "{{ openshift_password }}"
validate_certs: "{{ validate_certs }}"
force_basic_auth: True
register: login
when: token is undefined
- name: user token
set_fact:
token: "{{ (login.url | regex_search('access_token=([\\d\\w\\-_]*)')).split('=')[1] }}"
when: token is undefined
- name: Create Project
command: >-
{{ oc }} --config=/dev/null new-project {{ project_name }}
--display-name='{{ project_display_name }}'
--description='{{ project_description }}'
ignore_errors: True
no_log: "{{ oc_no_log }}"
- name: Configure project authorization
hosts: all
roles:
- role: auth
- name: Setup Jenkins and registry push credentials
hosts: dev
roles:
- role: jenkins
- role: pusher
- name: Setup registry tokens
hosts:
- stage
- prod
roles:
- role: puller