Files
k3s-ansible/roles/k3s/pre/tasks/main.yml
T

58 lines
1.7 KiB
YAML

---
- name: Get uptime information
ansible.builtin.shell: /usr/bin/uptime
- name: Stop containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: stopped
loop: "{{ groups['k3s_cluster'] }}"
ignore_errors: true
- name: Remove containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: "{{ hostvars[item]['ip_addr'] }}"
state: absent
loop: "{{ groups['k3s_cluster'] }}"
ignore_errors: true
- name: Create containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
node: "{{ item }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
password: "{{ lxc_password }}"
hostname: "{{ hostvars[item]['hostname'] }}"
ostemplate: "hyrule-8tb-nfs:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\
ip={{ hostvars[item]['lxc_host'] }}/21,\
hwaddr={{ hostvars[item]['mac_addr'] }},\
bridge=vmbr0'}"
cores: "{{ hostvars[item]['cores'] }}"
memory: "{{ hostvars[item]['memory'] }}"
unprivileged: no
swap: 0
searchdomain: "home"
onboot: 1
disk: local-lvm:{{ hostvars[item]['disk'] }}
force: yes
loop: "{{ groups['k3s_cluster'] }}"
- name: Start deployments
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: started
loop: "{{ groups['k3s_cluster'] }}"