|
| 1 | +##### |
| 2 | +# This playbook attempts to setup and install Azimuth on a fresh ubuntu VM |
| 3 | +##### |
| 4 | + |
| 5 | +- name: Setup |
| 6 | + hosts: azimuth_deploy |
| 7 | + tasks: |
| 8 | + # HA mode relies on openstack |
| 9 | + - name: Fail if install_mode is not standalone |
| 10 | + ansible.builtin.fail: |
| 11 | + msg: "Install modes other than 'standalone' are not supported for this playbook" |
| 12 | + when: install_mode != 'standalone' |
| 13 | + |
| 14 | + - name: Setup host groups |
| 15 | + ansible.builtin.add_host: |
| 16 | + name: "{{ item }}" |
| 17 | + groups: |
| 18 | + - k3s |
| 19 | + loop: "{{ ansible_play_hosts }}" |
| 20 | + |
| 21 | +# Configure the k3s cluster and add tools |
| 22 | +- name: Setup Node |
| 23 | + hosts: k3s |
| 24 | + tasks: |
| 25 | + |
| 26 | + - name: System setup |
| 27 | + become: true |
| 28 | + when: configure_system_resources | default (false) |
| 29 | + block: |
| 30 | + - name: Update packages |
| 31 | + ansible.builtin.apt: |
| 32 | + update_cache: true |
| 33 | + upgrade: true |
| 34 | + |
| 35 | + - name: Configure system trust store |
| 36 | + ansible.builtin.include_role: |
| 37 | + name: azimuth_cloud.azimuth_ops.system_trust |
| 38 | + |
| 39 | + - name: Set sysctls |
| 40 | + ansible.builtin.include_role: |
| 41 | + name: azimuth_cloud.azimuth_ops.sysctl_inotify |
| 42 | + |
| 43 | + - name: Install k3s |
| 44 | + when: install_k3s |
| 45 | + become: true |
| 46 | + block: |
| 47 | + - name: Install and configure k3s |
| 48 | + ansible.builtin.include_role: |
| 49 | + name: azimuth_cloud.azimuth_ops.k3s |
| 50 | + |
| 51 | + - name: Install CLI tools |
| 52 | + become: true |
| 53 | + when: install_cli_tools |
| 54 | + block: |
| 55 | + - name: Install and configure k9s |
| 56 | + ansible.builtin.include_role: |
| 57 | + name: azimuth_cloud.azimuth_ops.k9s |
| 58 | + |
| 59 | + - name: Get installed Kubernetes version |
| 60 | + ansible.builtin.command: k3s kubectl version --output json |
| 61 | + changed_when: false |
| 62 | + register: k3s_kubectl_version |
| 63 | + |
| 64 | + - name: Set kubectl version fact |
| 65 | + ansible.builtin.set_fact: |
| 66 | + kubectl_version: "{{ (k3s_kubectl_version.stdout | from_json).serverVersion.gitVersion.split('+') | first }}" |
| 67 | + |
| 68 | + - name: Install Kubectl |
| 69 | + ansible.builtin.include_role: |
| 70 | + name: azimuth_cloud.azimuth_ops.kubectl |
| 71 | + |
| 72 | + - name: Install Helm |
| 73 | + ansible.builtin.include_role: |
| 74 | + name: azimuth_cloud.azimuth_ops.helm |
| 75 | + |
| 76 | + - name: Install Kustomize |
| 77 | + ansible.builtin.include_role: |
| 78 | + name: azimuth_cloud.azimuth_ops.kustomize |
| 79 | + |
| 80 | + - name: Install Flux |
| 81 | + ansible.builtin.include_role: |
| 82 | + name: azimuth_cloud.azimuth_ops.flux |
| 83 | + tasks_from: cli |
| 84 | + when: flux_enabled |
| 85 | + |
| 86 | + - name: Setup Kubeconfig |
| 87 | + when: slurp_k3s_kubeconfig |
| 88 | + become: true |
| 89 | + block: |
| 90 | + - name: Slurp kubeconfig file |
| 91 | + ansible.builtin.slurp: |
| 92 | + src: /etc/rancher/k3s/k3s.yaml |
| 93 | + register: k3s_kubeconfig |
| 94 | + |
| 95 | + - name: Ensure kube config directory exists |
| 96 | + ansible.builtin.file: |
| 97 | + path: "{{ ansible_env.HOME }}/.kube" |
| 98 | + state: directory |
| 99 | + mode: u=rwx,g=rx,o=rx |
| 100 | + |
| 101 | + - name: Write kubeconfig file |
| 102 | + ansible.builtin.copy: |
| 103 | + content: "{{ k3s_kubeconfig.content | b64decode }}" |
| 104 | + dest: "{{ ansible_env.HOME }}/.kube/config" |
| 105 | + mode: u=rwx,g=r,o=r |
| 106 | + |
| 107 | + # For a single node install, we put the monitoring and ingress controller on the K3S cluster |
| 108 | + - name: Install monitoring stack and ingress controller |
| 109 | + |
| 110 | + # Configure the K3S cluster as a Cluster API management cluster when doing a HA installation |
| 111 | + block: |
| 112 | + # Must be done before NGINX ingress so that the ServiceMonitor CRD exists |
| 113 | + - name: Install Kube-Prometheus-Stack |
| 114 | + ansible.builtin.include_role: |
| 115 | + name: azimuth_cloud.azimuth_ops.kube_prometheus_stack |
| 116 | + when: deploy_prometheus_stack | default(false) |
| 117 | + |
| 118 | + - name: Install Nginx ingress controller |
| 119 | + ansible.builtin.include_role: |
| 120 | + name: azimuth_cloud.azimuth_ops.ingress_nginx |
| 121 | + when: "ingress_controller_enabled | default(true)" |
| 122 | + |
| 123 | +# Install Azimuth |
| 124 | +- name: Install and configure Azimuth |
| 125 | + import_playbook: azimuth_cloud.azimuth_ops.deploy |
0 commit comments