-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.yml
53 lines (43 loc) · 1.75 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
- name: Create/Delete a Kubernetes Cluster
hosts: localhost
connection: local
gather_facts: yes
vars_files:
- ./vars/common.yml
roles:
- { role: check_vars }
- { role: install_dependencies, when: dependencies_check }
tasks:
- name: Include cloud variables
ansible.builtin.include_vars: "./vars/{{ cloud_provider }}.yml"
- name: Include SSH Key
ansible.builtin.include_vars: "./vars/ssh.yml"
when: cloud_provider == 'azure'
- name: Include ACM vars
ansible.builtin.include_vars: "./vars/acm.yml"
when: acm_import
- name: Create Kubernetes config folder
ansible.builtin.file:
path: "{{ playbook_dir }}/.kube"
state: directory
when: not delete
- name: Include cloud-specific tasks to create the cluster
ansible.builtin.include_tasks: "./{{ k8s_service[cloud_provider] }}_create.yml"
when: not delete
- name: Get Kubeconfig from {{ cloud_provider }}
block:
- name: Install {{ cloud_provider }} SDK if required
ansible.builtin.include_tasks: "./{{ cloud_provider }}_cli.yml"
when: cloud_provider != 'azure'
environment:
AWS_CONFIG_FILE: "{{ playbook_dir }}/.{{ cloud_provider }}/config"
AWS_SHARED_CREDENTIALS_FILE: "{{ playbook_dir }}/.{{ cloud_provider }}/credentials"
- name: Add/delete EKS worker nodes
ansible.builtin.include_tasks: "./eks_nodes.yml"
when: cloud_provider == 'aws'
- name: Include cloud-specific tasks to add cluster to RHACM
ansible.builtin.include_tasks: "./acm_import.yml"
when: acm_import
- name: Include cloud-specific tasks to delete the cluster
ansible.builtin.include_tasks: "./{{ k8s_service[cloud_provider] }}_delete.yml"
when: delete