forked from techno-tim/k3s-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.yml
106 lines (97 loc) · 2.81 KB
/
site.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
- name: Pre tasks
hosts: all
pre_tasks:
- name: Verify Ansible is version 2.11 or above. (If this fails you may need to update Ansible)
ansible.builtin.assert:
that: ansible_version.full is version_compare('2.11', '>=')
msg: >
"Ansible is out of date. See here for more info: https://docs.technotim.live/posts/ansible-automation/"
- name: Set architecture and OS variables
ansible.builtin.set_fact:
cli_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
cli_os: "{{ 'linux' if ansible_facts['os_family'] in ['Debian', 'RedHat'] else ansible_system | lower }}"
run_once: true
- name: Prepare Proxmox cluster
hosts: proxmox
gather_facts: true
become: true
environment: "{{ proxy_env | default({}) }}"
roles:
- role: proxmox_lxc
when: proxmox_lxc_configure
- name: Prepare k3s nodes
hosts: k3s_cluster
gather_facts: true
environment: "{{ proxy_env | default({}) }}"
roles:
- role: lxc
become: true
when: proxmox_lxc_configure
- role: prereq
become: true
- role: download
become: true
- role: raspberrypi
become: true
- role: k3s_custom_registries
become: true
when: custom_registries
- name: Setup k3s servers
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server
become: true
- name: Setup k3s agents
hosts: node
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_agent
become: true
- name: Configure k3s cluster
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server_post
become: true
- name: Install Helm
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: helm
become: true
- name: Install Argo CD
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: argo-cd
become: true
- name: Install cert-manager
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: cert-manager
become: true
- name: Configure CoreDNS
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: coredns
become: true
- name: Configure External DNS
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: external-dns
become: true
- name: Storing kubeconfig in the playbook directory
hosts: localhost
environment: "{{ proxy_env | default({}) }}"
tasks:
- name: Copying kubeconfig from {{ hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname'] }}
ansible.builtin.fetch:
src: "{{ ansible_user_dir }}/.kube/config"
dest: ./kubeconfig
flat: true
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']