-
Notifications
You must be signed in to change notification settings - Fork 1
/
playbook_start_k8s_discoveries.yml
58 lines (57 loc) · 2.05 KB
/
playbook_start_k8s_discoveries.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
# Example Playbok to Add Kubernetes Cluster to PPDM
- name: Discover PPDM K8S Inventory
hosts: localhost
gather_facts: no
connection: local
vars_files:
- ./vars/main.yml
collections:
- kubernetes.core
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: Setting Base URL
ansible.builtin.set_fact:
ppdm_baseurl: "https://{{ ppdm_fqdn | regex_replace('^https://') }}"
- name: Get Cluster information
kubernetes.core.k8s_cluster_info:
register: api_status
- debug:
msg: "Connected to {{ api_status.connection.host }}"
verbosity: 0
- name: Setting Connection Parameters from api api_status
set_fact:
k8s_fqdn: "{{ api_status.connection.host | regex_replace('^https://') | regex_replace('\\:\\d+') }}"
k8s_port: "{{ api_status.connection.host.split(':').2 | default('443')}}"
k8s_name: "{{ api_status.connection.host.split('.').1 }}"
- 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 PPDM inventory-sources for K8S "{{ new_k8s_api }}"
include_role:
name: get_ppdm_inventory-sources
vars:
filter: address eq "{{ k8s_fqdn }}" and type eq "KUBERNETES"
- debug:
msg: "{{ inventorysources }}"
verbosity: 1
- name: Run Discovery for K8S inventory-source "{{ inventorysources[0].id }} "
include_role:
name: run_ppdm_discoveries
vars:
inventorySource: "{{ inventorysources[0].id }}"