diff --git a/playbook.yml b/playbook.yml index b58690e..e385f0d 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,4 +1,5 @@ -- hosts: localhost +- name: Provision VM's + hosts: localhost gather_facts: false vars_files: - hypervisor.vcenter.yml @@ -19,7 +20,7 @@ datacenter: "{{ hv.datacenter }}" folder: "{{ hv.folder }}" cluster: "{{ hv.cluster }}" - name: "{{ kubernetes.clustername | upper }}-{{ (item.ip | checksum)[-5:] | upper }}" + name: "{{ cluster.name | upper }}-{{ (item.ip | checksum)[-5:] | upper }}" datastore: "{{ hv.datastore }}" disk_provisioning: thin networks: @@ -28,7 +29,7 @@ ovf: /scratch/image.ova deployment_option: "{{ image.deployment_option }}" properties: - guestinfo.hostname: "{{ kubernetes.clustername | upper }}-{{ (item.ip | checksum)[-5:] | upper }}" + guestinfo.hostname: "{{ cluster.name | upper }}-{{ (item.ip | checksum)[-5:] | upper }}" guestinfo.rootpw: "{{ root_password }}" guestinfo.rootsshkey: "foo" guestinfo.ntpserver: "{{ network.ntpserver }}" @@ -63,3 +64,21 @@ ansible_host: "{{ item.ip }}" groups: k3s_ha with_items: "{{ nodes }}" + +- name: Provision Kubernetes + hosts: k3s_ha + gather_facts: false + # vars_files: + # - hypervisor.vcenter.yml + # - cluster.k3s.yml + tasks: + + - name: Iterate over hosts + block: + - name: Install K3s binary + ansible.builtin.command: + cmd: "curl -sfL https://get.k3s.io | sh -s - server --cluster-init --disable local-storage,traefik --tls-san {{ cluster.virtualip | ansible.utils.ipaddr('address') }}" + environment: + K3S_TOKEN: env.k3s_token | default('', true) + K3S_URL: env.k3s_url | default('', true) + throttle: 1 diff --git a/vars/cluster.k3s.yml b/vars/cluster.k3s.yml index cafaa6c..c640f55 100644 --- a/vars/cluster.k3s.yml +++ b/vars/cluster.k3s.yml @@ -1,6 +1,7 @@ --- -kubernetes: - clustername: k3s-dev +cluster: + name: k3s-dev + virtualip: 192.168.11.120/24 image: deployment_option: large ova_url: sn.itch.fyi/Repository/rel/Ubuntu-Server-20.04.ova