-
Notifications
You must be signed in to change notification settings - Fork 1
/
scratch_k8s_info.yml
36 lines (36 loc) · 1.27 KB
/
scratch_k8s_info.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
# This example Playbook adds a Kubernetes Cluster to PPDM
# Kubernetes Information will be read from k8s core cluster_info module
# it is expected that Environment Variables are set for core K8S Modules
# e.g. export K8S_AUTH_KUBECONFIG=
- name: Add K8S to PPDM
hosts: localhost
gather_facts: no
connection: local
vars_files:
- ./vars/main.yml
collections:
- kubernetes.core
tasks:
# - name: install pre-requisites
# pip:
# name:
# - openshift
# - pyyaml
# - kubernetes
- 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 Kubernetes nodes
set_fact:
nodes: "{{ lookup('k8s', api_version='v1', kind='node', label_selector='node-role.kubernetes.io/master=' ) }}"
- name: Add host to inventory
debug:
msg: "{{ nodes | json_query('[*].status.addresses[0].address') }}"