feat: changed lxc to vm in k3s

This commit is contained in:
Lino Silva
2023-01-03 11:59:54 +00:00
parent 1913d6417c
commit c9c9861a82
33 changed files with 413 additions and 164 deletions
@@ -0,0 +1,25 @@
---
- name: Create Piholes
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
node: "{{ hostvars[item]['node'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
password: "{{ lxc_password }}"
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: 1
memory: 2048
unprivileged: no
swap: 512
searchdomain: "home"
onboot: 1
disk: local-lvm:8
force: yes
loop: "{{ groups['pihole'] }}"
@@ -0,0 +1,26 @@
---
- name: Stop containers
community.general.proxmox:
vmid: "{{ vmid }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: stopped
ignore_errors: true
timeout: 90
- name: Remove containers
community.general.proxmox:
vmid: "{{ vmid }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: absent
ignore_errors: true
timeout: 90
- name: Remove .ssh/known_hosts lines
ansible.builtin.lineinfile:
path: /Users/lino.silva/.ssh/known_hosts
state: absent
regexp: "^{{ ansible_host }}"
@@ -0,0 +1,8 @@
---
# Unable to use ansible.builtin.lineinfile, because we need to run this through the proxmox host (because SSH is not enabled duh)
- name: Allow SSH into LXC
ansible.builtin.command: lxc-attach -n "{{ vmid }}" -- sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
- name: Restart SSH Service
ansible.builtin.command: lxc-attach -n "{{ vmid }}" service ssh restart
+12
View File
@@ -0,0 +1,12 @@
---
- name: Allow ipv4 forwarding
ansible.builtin.shell: "sysctl net.ipv4.ip_forward=1"
- name: Allow ipv6 forwarding
ansible.builtin.shell: "sysctl net.ipv6.conf.all.forwarding=1"
- name: Uncomment ipv4 forward line on /etc/sysctl.conf
ansible.builtin.shell: "sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf"
- name: Uncomment ipv6 forward line on /etc/sysctl.conf
ansible.builtin.shell: "sed -i 's/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=1/g' /etc/sysctl.conf"
@@ -0,0 +1,9 @@
---
- name: Start deployments
community.general.proxmox:
vmid: "{{ hostvars[item]['k3s_vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: started
loop: "{{ groups['baremetal'] }}"