refactor(k3s): replace code with what the provisioner role now offers and store opentofu data accordingly

This commit is contained in:
NaeiKinDus 2024-07-10 00:00:00 +00:00
parent 1b3e0c401c
commit 95bb861049
Signed by: WoodSmellParticle
GPG key ID: 8E52ADFF7CA8AE56
4 changed files with 22 additions and 83 deletions

View file

@ -1,9 +1,4 @@
---
- name: gather facts if not already done
ansible.builtin.setup:
gather_subset:
- user_id
- name: group by cluster name
ansible.builtin.group_by:
key: "k3s_clusters_{{ k3s_cluster_name }}_{{ k3s_cluster_role }}"
@ -22,40 +17,6 @@
k3s_nft_operators6: "{{ k3s_operator_ips | ansible.utils.ipv6 }}"
changed_when: false
- name: get local controller account information
connection: local
ansible.builtin.getent:
database: passwd
key: "{{ ansible_facts.user_id }}"
split: ":"
changed_when: false
when: ansible_facts['getent_passwd'] is undefined or ansible_facts['user_id'] not in ansible_facts['getent_passwd']
- name: set controller environment variables
ansible.builtin.set_fact:
controller_user_home: "{{ ansible_facts['getent_passwd'][ansible_facts['user_id']][4] }}"
k3sup_binary: "{{ ansible_facts['getent_passwd'][ansible_facts['user_id']][4] }}/.local/bin/k3sup"
kubeconfig_repository: "{{ ansible_facts['getent_passwd'][ansible_facts['user_id']][4] }}/.kubeconfig_repository"
changed_when: false
- name: retrieve k3sup on Ansible controller
connection: local
nullified.infrastructure.github_artifact:
asset_name: k3sup
asset_type: release
repository: alexellis/k3sup
creates: '{{ k3sup_binary }}'
cmds:
- mkdir -p $HOME/.local/bin
- "install --mode=750 {asset_dirname}/{asset_filename} {{ k3sup_binary }}"
- name: setup kubeconfig repository
connection: local
ansible.builtin.file:
path: "{{ kubeconfig_repository }}"
state: directory
mode: '0700'
- name: setup permissions
become: true
block: