-
Notifications
You must be signed in to change notification settings - Fork 15
/
flux_install.yaml
74 lines (65 loc) · 2 KB
/
flux_install.yaml
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
- name: "Prepare nodes"
hosts: nodes
tasks:
- name: Create flux NS
shell: |
{{ KUBECTL_BIN }} create ns {{ FLUX_NAMESPACE }}
run_once: True
register: result
failed_when:
- "'already exists' not in result.stderr"
- result.rc != 0
changed_when:
- "result.stderr is not search('already exists')"
- name: Download flux2 installer
get_url:
url: https://toolkit.fluxcd.io/install.sh
dest: /tmp/flux2-installer.sh
mode: u+rwx
register: flux2_download
- name: Execute the flux2-installer.sh
shell: /tmp/flux2-installer.sh
when: flux2_download.changed
- name: "Check flux prerequisites"
shell: flux check --pre
changed_when: false
when: inventory_hostname in groups["masters"]
- name: Install SOPS
apt:
deb: https://github.com/mozilla/sops/releases/download/v{{ SOPS_VERSION }}/sops_{{ SOPS_VERSION }}_amd64.deb
when: ansible_architecture == "x86_64"
- name: Install SOPS GPG key
shell: >
echo "{{ SOPS_GPG }}"| gpg --batch
--pinentry-mode loopback
--import /dev/stdin
register: result
changed_when:
- "result.stderr is not search('not changed')"
- name: Create secret with SOPS GPG key
shell: >
{{ KUBECTL_BIN }} create -n {{ FLUX_NAMESPACE }} secret generic sops-gpg
--save-config --dry-run=client
--from-literal=sops.asc="{{ SOPS_GPG }}"
-o yaml
| {{ KUBECTL_BIN }} apply -f -
run_once: True
register: result
changed_when:
- "result.stdout is search('created')"
- name: "Install (if needed) flux"
hosts: nodes[0]
gather_facts: false #Already queried
tasks:
- name: "Deploy flux to cluster if crd fluxcd.io missing"
shell: >
{{ KUBECTL_BIN }} apply -k ../{{ FLUX_GIT_PATH }}
environment:
KUBECONFIG: "{{ KUBECTL_CONFIG }}"
delegate_to: localhost
register: result
changed_when:
- "result.stdout is search('created')"
until: result is succeeded
retries: 60
delay: 5 #due to CRDs