Some checks failed
CI / lint-and-test (pull_request) Successful in 1m21s
CI / ansible-validation (pull_request) Successful in 9m3s
CI / secret-scanning (pull_request) Successful in 3m19s
CI / dependency-scan (pull_request) Successful in 7m13s
CI / sast-scan (pull_request) Successful in 6m38s
CI / license-check (pull_request) Successful in 1m16s
CI / vault-check (pull_request) Failing after 6m40s
CI / playbook-test (pull_request) Successful in 9m28s
CI / container-scan (pull_request) Successful in 7m59s
CI / sonar-analysis (pull_request) Failing after 1m11s
CI / workflow-summary (pull_request) Successful in 1m11s
- Add roles/pote: Python/venv deployment role with PostgreSQL, cron jobs - Add playbooks/app/: Proxmox app stack provisioning and configuration - Add roles/app_setup: Generic app deployment role (Node.js/systemd) - Add roles/base_os: Base OS hardening role - Enhance roles/proxmox_vm: Split LXC/KVM tasks, improve error handling - Add IP uniqueness validation: Preflight check for duplicate IPs within projects - Add Proxmox-side IP conflict detection: Check existing LXC net0 configs - Update inventories/production/group_vars/all/main.yml: Add pote project config - Add vault.example.yml: Template for POTE secrets (git key, DB, SMTP) - Update .gitignore: Exclude deploy keys, backup files, and other secrets - Update documentation: README, role docs, execution flow guides Security: - All secrets stored in encrypted vault.yml (never committed in plaintext) - Deploy keys excluded via .gitignore - IP conflict guardrails prevent accidental duplicate IP assignments
83 lines
3.2 KiB
YAML
83 lines
3.2 KiB
YAML
---
|
|
# Proxmox LXC container provisioning via API.
|
|
#
|
|
# This uses `community.proxmox.proxmox` because it is widely available and
|
|
# supports idempotent updates via `update: true`.
|
|
|
|
- name: Build LXC netif configuration
|
|
ansible.builtin.set_fact:
|
|
lxc_netif_config:
|
|
# IMPORTANT: Proxmox requires net0 to be a single comma-delimited string.
|
|
# Avoid folded YAML blocks here (they can introduce newlines/spaces).
|
|
net0: >-
|
|
{{
|
|
(
|
|
['name=eth0', 'bridge=' ~ lxc_network_bridge, 'firewall=1']
|
|
+ (['ip=' ~ lxc_ip] if (lxc_ip is defined and (lxc_ip | string | length) > 0) else [])
|
|
+ (['gw=' ~ lxc_gateway] if (lxc_gateway is defined and (lxc_gateway | string | length) > 0) else [])
|
|
) | join(',')
|
|
}}
|
|
|
|
- name: Ensure LXC container is present (create or update)
|
|
community.proxmox.proxmox:
|
|
api_host: "{{ proxmox_host }}"
|
|
api_port: "{{ proxmox_api_port | default(8006) }}"
|
|
validate_certs: "{{ proxmox_validate_certs | default(false) }}"
|
|
api_user: "{{ proxmox_user }}"
|
|
api_password: "{{ vault_proxmox_password | default(omit) }}"
|
|
# Only pass token params when they are set (avoid empty-string triggering required-together errors)
|
|
api_token_id: "{{ proxmox_token_id | default(omit, true) }}"
|
|
api_token_secret: "{{ vault_proxmox_token | default(omit, true) }}"
|
|
|
|
node: "{{ proxmox_node }}"
|
|
vmid: "{{ lxc_vmid | default(omit) }}"
|
|
hostname: "{{ lxc_hostname }}"
|
|
|
|
ostemplate: "{{ lxc_ostemplate }}"
|
|
unprivileged: "{{ lxc_unprivileged | bool }}"
|
|
features: "{{ lxc_features_list | default(omit) }}"
|
|
|
|
cores: "{{ lxc_cores }}"
|
|
memory: "{{ lxc_memory_mb }}"
|
|
swap: "{{ lxc_swap_mb }}"
|
|
|
|
# rootfs sizing (GiB). disk_volume is less version-sensitive than string `disk`.
|
|
disk_volume:
|
|
storage: "{{ lxc_storage }}"
|
|
size: "{{ lxc_rootfs_size_gb }}"
|
|
|
|
netif: "{{ lxc_netif_config }}"
|
|
nameserver: "{{ lxc_nameserver | default(omit) }}"
|
|
|
|
# Bootstrap root SSH access (used by Ansible until appuser exists).
|
|
pubkey: "{{ lxc_pubkey | default(omit) }}"
|
|
password: "{{ vault_lxc_root_password | default(omit) }}"
|
|
|
|
update: true
|
|
state: present
|
|
register: lxc_present
|
|
|
|
- name: Ensure LXC container is started
|
|
community.proxmox.proxmox:
|
|
api_host: "{{ proxmox_host }}"
|
|
api_port: "{{ proxmox_api_port | default(8006) }}"
|
|
validate_certs: "{{ proxmox_validate_certs | default(false) }}"
|
|
api_user: "{{ proxmox_user }}"
|
|
api_password: "{{ vault_proxmox_password | default(omit) }}"
|
|
api_token_id: "{{ proxmox_token_id | default(omit, true) }}"
|
|
api_token_secret: "{{ vault_proxmox_token | default(omit, true) }}"
|
|
node: "{{ proxmox_node }}"
|
|
vmid: "{{ lxc_vmid | default(omit) }}"
|
|
state: started
|
|
when: lxc_start_after_create | bool
|
|
|
|
- name: Display LXC provisioning results
|
|
ansible.builtin.debug:
|
|
msg: |
|
|
LXC Present: {{ lxc_hostname }} (VMID: {{ lxc_vmid }})
|
|
Cores: {{ lxc_cores }}
|
|
Memory: {{ lxc_memory_mb }}MB (swap {{ lxc_swap_mb }}MB)
|
|
RootFS: {{ lxc_storage }}:{{ lxc_rootfs_size_gb }}
|
|
Net: {{ lxc_network_bridge }} / {{ lxc_ip | default('dhcp/unspecified') }}
|
|
Changed: {{ lxc_present.changed | default(false) }}
|