Files
k3s-ansible/roles/lxc-create/main.yml
T
2022-11-07 21:18:02 +00:00

59 lines
1.7 KiB
YAML

---
- name: Create LXC for k3s
hosts: localhost
gather_facts: no
tasks:
- name: Stop containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
state: stopped
loop: "{{ groups['all'] }}"
ignore_errors: yes
- name: Remove containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
state: absent
loop: "{{ groups['all'] }}"
ignore_errors: yes
- name: Create containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
node: "{{ hostvars[item]['node'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
password: bemjogado
hostname: "{{ item }}"
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]['ansible_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:8
force: yes
loop: "{{ groups['all'] }}"
- name: Start deployments
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
state: started
loop: "{{ groups['all'] }}"