diff --git a/infra/amnezia/0000_proxmox_playbook.yaml b/infra/amnezia/0000_proxmox_playbook.yaml new file mode 100644 index 0000000..f1c6875 --- /dev/null +++ b/infra/amnezia/0000_proxmox_playbook.yaml @@ -0,0 +1,115 @@ +- name: Provision amnezia Proxmox VM + hosts: amnezia + connection: ansible.builtin.local + gather_facts: false + vars: + api_user: "{{ lookup('ansible.builtin.env', 'PROXMOX_USER') }}" + api_host: "{{ lookup('ansible.builtin.env', 'PROXMOX_HOST' ) }}" + api_token_id: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') }}" + api_token_secret: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_SECRET') }}" + ssh_public: "{{ lookup('ansible.builtin.env', 'SSH_PUBLIC') }}" + amnezia_ssh_public: "{{ lookup('ansible.builtin.env', 'AMNEZIA_SSH_PUBLIC') }}" + vmname: "{{ inventory_hostname | regex_replace('^([^\\.]+)\\..+$', '\\1') }}" + node: pve2 + module_defaults: + community.general.proxmox_kvm: + api_user: "{{ api_user }}" + api_host: "{{ api_host }}" + api_token_id: "{{ api_token_id }}" + api_token_secret: "{{ api_token_secret }}" + name: "{{ vmname }}" + node: "{{ node }}" + community.general.proxmox_nic: + api_user: "{{ api_user }}" + api_host: "{{ api_host }}" + api_token_id: "{{ api_token_id }}" + api_token_secret: "{{ api_token_secret }}" + name: "{{ vmname }}" + community.general.proxmox_disk: + api_user: "{{ api_user }}" + api_host: "{{ api_host }}" + api_token_id: "{{ api_token_id }}" + api_token_secret: "{{ api_token_secret }}" + name: "{{ vmname }}" + tasks: + # Initial setup + - name: Create VM + community.general.proxmox_kvm: + clone: "{{ node }}-debian-13" + storage: nvme + notify: + - Start VM + - Wait + - name: Wait for status + community.general.proxmox_kvm: + state: current + register: vm + retries: 30 + delay: 10 + until: vm.status is defined + + # Networking and initial config + - name: Add PUB NIC + community.general.proxmox_nic: + interface: net0 + firewall: false + bridge: PUB + - name: Add SRV NIC + community.general.proxmox_nic: + interface: net1 + firewall: false + bridge: SRV + - name: Configure cloud-init + community.general.proxmox_kvm: + update: true + ciuser: debian + sshkeys: | + {{ ssh_public }} + {{ amenezia_ssh_public }} + ipconfig: + ipconfig0: ip=dhcp,ip6=auto + ipconfig1: ip=dhcp + - name: Force all notified handlers to run + ansible.builtin.meta: flush_handlers + + # VM Configuration + - name: Resize root disk + community.general.proxmox_disk: + disk: scsi0 + size: 32G + state: resized + - name: Create data disk + community.general.proxmox_disk: + disk: scsi1 + backup: true + storage: nvme + size: 16G + - name: Update VM + community.general.proxmox_kvm: + update: true + agent: enabled=1 + tags: + - debian-13 + - managed + onboot: true + cores: 16 + memory: 4096 + + - name: Retart VM + community.general.proxmox_kvm: + state: restarted + timeout: 60 + + handlers: + # Initial boot + # For some reason debian cloud images don't use + # cloud-init for networking on first boot (cloud-init files + # are regenerated AFTER networking starts). But we need the + # hostname to be registered with DHCP later on so ¯\_(ツ)_/¯ + - name: Start VM + community.general.proxmox_kvm: + state: started + register: start + - name: Wait # Initial apt update, apt upgrade, cloud-init + ansible.builtin.wait_for: + timeout: 90 diff --git a/infra/amnezia/0001_initialise_playbook.yaml b/infra/amnezia/0001_initialise_playbook.yaml new file mode 100644 index 0000000..e8caaf9 --- /dev/null +++ b/infra/amnezia/0001_initialise_playbook.yaml @@ -0,0 +1,43 @@ +- name: Initialise VM + hosts: amnezia + gather_facts: false + tasks: + - name: Wait for connection + ansible.builtin.wait_for_connection: + timeout: 300 + + - name: Install system packages + ansible.builtin.apt: + update_cache: true + pkg: + - qemu-guest-agent + - parted + become: true + - name: Enable qemu-guest-agent + ansible.builtin.systemd: + name: qemu-guest-agent + state: started + enabled: true + become: true + + - name: Create data partition + community.general.parted: + device: /dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:1 + label: gpt + name: data + number: 1 + state: present + become: true + - name: Create data filesystem + community.general.filesystem: + dev: /dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:1-part1 + fstype: ext4 + become: true + - name: Mount data partition + ansible.posix.mount: + src: /dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:1-part1 + path: /opt/amnezia + fstype: ext4 + opts: rw,errors=remount-ro,x-systemd.growfs + state: mounted + become: true diff --git a/infra/amnezia/actual/docker-compose.yml b/infra/amnezia/actual/docker-compose.yml new file mode 100644 index 0000000..9d5ef16 --- /dev/null +++ b/infra/amnezia/actual/docker-compose.yml @@ -0,0 +1,22 @@ +services: + actual_server: + image: docker.io/actualbudget/actual-server:latest + ports: + - 80:5006 + environment: + # See all options and more details at https://actualbudget.org/docs/config/ + - ACTUAL_UPLOAD_FILE_SYNC_SIZE_LIMIT_MB=100 + - ACTUAL_UPLOAD_SYNC_ENCRYPTED_FILE_SYNC_SIZE_LIMIT_MB=200 + - ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB=100 + volumes: + - actual-data:/data + healthcheck: + test: ["CMD-SHELL", "node src/scripts/health-check.js"] + interval: 60s + timeout: 10s + retries: 3 + start_period: 20s + restart: unless-stopped + +volumes: + actual-data: diff --git a/inventory/proxmox.yaml b/inventory/proxmox.yaml index bdf4666..d2f8fca 100644 --- a/inventory/proxmox.yaml +++ b/inventory/proxmox.yaml @@ -35,6 +35,9 @@ proxmox: homeassistant: hosts: homeassistant.srv.home.local.koval.net: + amnezia: + hosts: + amnezia.srv.home.local.koval.net: vars: ansible_user: debian ansible_ssh_private_key_file: ~/.ssh/id_rsa