-
Notifications
You must be signed in to change notification settings - Fork 1
/
playbook_add_k8s.yml
89 lines (86 loc) · 2.69 KB
/
playbook_add_k8s.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
# Example Playbok to Add Kubernetes Cluster to PPDM
- name: Add K8S to PPDM
hosts: localhost
gather_facts: no
connection: local
vars_files:
- ./vars/main.yml
tasks:
- name: Checking Required Variable ppdm_fqdn
fail:
msg: "We do not have ppdm_fqdn set !"
when: (ppdm_fqdn is not defined) or (ppdm_fqdn|length <= 8)
- name: Checking Required Variables
fail:
msg: "We do not have ppdm_new_password set !"
when: (ppdm_new_password is not defined) or (ppdm_new_password|length == 0)
- name: Checking Required Variables
fail:
msg: "We do not have K8S fqdn set !"
when: (k8s_fqdn is not defined) or (k8s_fqdn|length <= 8)
- name: Checking Required Variables
fail:
msg: "We do not have k8s_token set !"
when: (k8s_token is not defined) or (k8s_token|length == 0)
- name: Checking Required Variables
fail:
msg: "We do not have k8s_port set !"
when: (k8s_port is not defined) or (k8s_token|length <= 2)
- name: Setting Base URL
set_fact:
ppdm_baseurl: "https://{{ ppdm_fqdn | regex_replace('^https://') }}"
- name: Get PPDM Token for https://{{ ppdm_fqdn | regex_replace('^https://') }}
include_role:
name: get_ppdm_token
vars:
ppdm_password: "{{ ppdm_new_password }}"
- debug:
msg: "{{ access_token }}"
verbosity: 1
name: do we have a token ?
- name: Get Kubernetes Host Certificate for {{ k8s_fqdn }}
include_role:
name: get_ppdm_host_certificate
vars:
host: "{{ k8s_fqdn }}"
port: "{{ k8s_port }}"
- name: Accept K8S Host Certificate
include_role:
name: accept_ppdm_host_certificate
vars:
old_certificate: "{{ certificate }}"
- name: Create K8S Credentials
vars:
data:
method: "TOKEN"
name: "ppdm-discovery-{{ k8s_fqdn }}"
type: "KUBERNETES"
password: "{{ k8s_token }}"
username: "ppdm-discovery-{{ k8s_fqdn }}"
include_role:
name: create_ppdm_credentials
- name: Get PPDM Token for https://{{ ppdm_fqdn | regex_replace('^https://') }}
include_role:
name: get_ppdm_token
vars:
ppdm_password: "{{ ppdm_new_password }}"
- debug:
msg: "{{ access_token }}"
verbosity: 1
name: do we have a token ?
- name: Add K8S Cluster to Inventory
vars:
data:
name: "{{ k8s_name }}"
type: "KUBERNETES"
address: "{{ k8s_fqdn }}"
port: "{{ k8s_port }}"
retries: 10
delay: 30
credentials:
id: "{{ credentials.id }}"
include_role:
name: add_ppdm_inventory
- debug:
msg: "{{ inventory }}"
verbosity: 0