Files
ansible_samba_tasks/tasks/testing.yml
Jose d1c6c2bc99 fix 🐛: Update Ubuntu storage template
The Ubuntu template's default storage has been changed from 'hdd8t' to 'local' to align with current best practices and simplify deployment. This change ensures the template utilizes local storage, reducing potential configuration complexities. This update improves the overall usability and consistency of the template.
2025-12-10 17:33:01 +01:00

127 lines
5.2 KiB
YAML

- name: Deploy VM templates
hosts: node0
tasks:
# - name: Import variables from Ansible vault
# ansible.builtin.include_vars: secrets.yml
- name: Install proxmoxer from APT
apt:
name: python3-proxmoxer
state: present
update_cache: yes
- name: "[PREFLIGHT] Check if 'snippets' is already enabled for {{ proxmox_snippets_storage }}"
ansible.builtin.command: "grep -E 'dir:\\s*{{ proxmox_snippets_storage }}' -A5 /etc/pve/storage.cfg"
register: snippets_check
failed_when: false
changed_when: false
vars:
proxmox_snippets_storage: local
- name: "[PREFLIGHT] Determine whether 'snippets' is already configured"
ansible.builtin.set_fact:
snippets_already_present: "{{ 'snippets' in snippets_check.stdout }}"
- name: "[PREFLIGHT] Ensure 'snippets' is enabled for {{ proxmox_snippets_storage }}"
ansible.builtin.replace:
path: /etc/pve/storage.cfg
regexp: '(dir:\s*{{ proxmox_snippets_storage }}[\s\S]*?content\s+)(.*)(?<!snippets)'
replace: '\1\2,snippets'
when: not snippets_already_present
vars:
proxmox_snippets_storage: local
- name: "[PREFLIGHT] Ensure snippets storage directory exists"
ansible.builtin.file:
path: "{{ proxmox_snippets_storage_path }}/snippets"
state: directory
mode: "0755"
vars:
proxmox_snippets_storage_path: /var/lib/vz
- name: Deploy templates with proxmox_template_vm
ansible.builtin.include_role:
name: joshrnoll.homelab.proxmox_template_vm
vars:
# Required to provide at least one
proxmox_template_vm_distros:
- fedora
- ubuntu
# Required proxmox credentials
proxmox_template_vm_proxmox_username: "{{ proxmox_username }}" # From Ansible vault
proxmox_template_vm_proxmox_api_token_id: "{{ proxmox_api_token_id }}" # From Ansible vault
proxmox_template_vm_proxmox_api_token_secret: "{{ proxmox_api_token_secret }}" # From Ansible vault
# Optional customizations for ubuntu
proxmox_template_vm_ubuntu_storage: "local"
proxmox_template_vm_ubuntu_name: ubuntu-2204-template
proxmox_template_vm_ubuntu_memory: 4096
proxmox_template_vm_ubuntu_cores: 1
proxmox_template_vm_ubuntu_ciuser: "{{ ciuser }}" # From Ansible vault
proxmox_template_vm_ubuntu_cipassword: "{{ cipassword }}" # From Ansible vault
# proxmox_template_vm_ubuntu_sshkeys: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/id_rsa.pub') }}" # gets your ssh key from /home/user/.ssh/id_rsa.pub -- customize this to your needs
proxmox_template_vm_ubuntu_sshkeys: "{{ ssh_public_keys | join('\n') }}" # gets your ssh key from /home/user/.ssh/id_rsa.pub -- customize this to your needs
proxmox_template_vm_ubuntu_vlan: 50
# Optional customizations for fedora
proxmox_template_vm_fedora_storage: "local"
proxmox_template_vm_fedora_name: fedora-40-template
proxmox_template_vm_fedora_memory: 4096
proxmox_template_vm_fedora_cores: 1
proxmox_template_vm_fedora_ciuser: "{{ ciuser }}" # From Ansible vault
proxmox_template_vm_fedora_cipassword: "{{ cipassword }}" # From Ansible vault
proxmox_template_vm_fedora_sshkeys: "{{ ssh_public_keys | join('\n') }}" # gets your ssh key from /home/user/.ssh/id_rsa.pub -- customize this to your needs
proxmox_template_vm_fedora_vlan: 50
# Set to true if you have slow storage to avoid file locks
proxmox_template_vm_slow_storage: true
- name: Deploy VMs
ansible.builtin.include_role:
name: joshrnoll.homelab.create_proxmox_vms
vars:
# Proxmox credentials
create_proxmox_vms_proxmox_username: "{{ proxmox_username }}"
create_proxmox_vms_proxmox_api_token_id: "{{ proxmox_api_token_id }}"
create_proxmox_vms_proxmox_api_token_secret: "{{ proxmox_api_token_secret }}"
# VMs to be created
create_proxmox_vms_list:
- name: vm-01
template: 9412
vmid: 1000
memory: 8192
cores: 2
node: node0 # The hostname of the node that the VM will be created on
ciuser: "{{ ciuser }}"
cipassword: "{{ cipassword }}"
# sshkeys: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
storage: local-lvm
disk_size: 32G
vlan: 50
ip_address: 192.168.2.98/24
gateway: 192.168.2.1
nameservers:
- 192.168.2.100
- 192.168.2.26
- name: vm-02
vmid: 1001
template: 9413
memory: 4096
cores: 1
node: node0 # The hostname of the node that the VM will be created on
ciuser: "{{ ciuser }}"
cipassword: "{{ cipassword }}"
# sshkeys: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
storage: local-lvm
disk_size: 64G
vlan: 50
ip_address: 192.168.2.99/24
gateway: 192.168.2.1
nameservers:
- 192.168.2.100
- 192.168.0.26