Files
infra/ansible/roles/pve_lxc/tasks/main.yml
T
DmitryandClaude Sonnet 5 e0c53a1b1b chore: relocate .env to the repository root and refresh Make targets
.env is now consumed by both Ansible and OpenTofu, so keep a single copy at
the repo root instead of ansible/.env:

- rename ansible/.env.example -> .env.example.
- Makefile: ENV_FILE ?= $(REPO_ROOT)/.env (absolute, works from any cwd);
  REQUIRE_ENV/LOAD_ENV updated; help text.
- bootstrap-pve-api-token.yml / bootstrap-monitoring-pve-token.yml write and
  read ../../.env; bootstrap now keeps backup: true (it rewrites the whole
  file, clobbering MONITORING_*/EMERGENCY_*/PROXMOX_ROOT_PASSWORD).
- roles/pve_lxc, roles/monitoring_server: fail_msg points at the repo-root .env.

The Makefile also picks up the new targets added by later commits
(tofu-*, validate, pbs-storage, ru-vps-base, zerotier-decommission); they are
grouped here so all recipes land together.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012uoq5AVK8mkBgg83Mq6o5V
2026-09-03 07:04:12 +03:00

51 lines
2.1 KiB
YAML

---
- name: Validate Proxmox API environment
ansible.builtin.assert:
that:
- lookup('env', 'PROXMOX_HOST') | length > 0
- lookup('env', 'PROXMOX_USER') | length > 0
- lookup('env', 'PROXMOX_TOKEN_ID') | length > 0
- lookup('env', 'PROXMOX_TOKEN_SECRET') | length > 0
fail_msg: Load the repository-root .env with PROXMOX_HOST, PROXMOX_USER, PROXMOX_TOKEN_ID and PROXMOX_TOKEN_SECRET.
- name: Create or update LXC container
community.proxmox.proxmox:
api_host: "{{ lookup('env', 'PROXMOX_HOST') }}"
api_port: "{{ pve_lxc_api_port }}"
api_user: "{{ lookup('env', 'PROXMOX_USER') }}"
api_token_id: "{{ lookup('env', 'PROXMOX_TOKEN_ID') }}"
api_token_secret: "{{ lookup('env', 'PROXMOX_TOKEN_SECRET') }}"
validate_certs: "{{ lookup('env', 'PROXMOX_VALIDATE_CERTS') | default('false', true) | bool }}"
vmid: "{{ pve_lxc_vmid }}"
node: "{{ pve_lxc_node }}"
hostname: "{{ pve_lxc_hostname }}"
ostemplate: "{{ pve_lxc_ostemplate }}"
disk: "{{ pve_lxc_disk }}"
cores: "{{ pve_lxc_cores }}"
memory: "{{ pve_lxc_memory }}"
swap: "{{ pve_lxc_swap }}"
nameserver: "{{ pve_lxc_nameserver }}"
cmode: "{{ pve_lxc_cmode }}"
netif:
net0: "name=eth0,gw={{ pve_lxc_gateway }},ip={{ pve_lxc_ip }},bridge={{ pve_lxc_bridge }},firewall=1"
pubkey: "{{ lookup('file', pve_lxc_pubkey_file) }}"
features: "{{ pve_lxc_features }}"
unprivileged: "{{ pve_lxc_unprivileged }}"
onboot: "{{ pve_lxc_onboot }}"
startup: "{{ pve_lxc_startup }}"
update: "{{ pve_lxc_update }}"
state: present
no_log: true
- name: Start LXC container
community.proxmox.proxmox:
api_host: "{{ lookup('env', 'PROXMOX_HOST') }}"
api_port: "{{ pve_lxc_api_port }}"
api_user: "{{ lookup('env', 'PROXMOX_USER') }}"
api_token_id: "{{ lookup('env', 'PROXMOX_TOKEN_ID') }}"
api_token_secret: "{{ lookup('env', 'PROXMOX_TOKEN_SECRET') }}"
validate_certs: "{{ lookup('env', 'PROXMOX_VALIDATE_CERTS') | default('false', true) | bool }}"
vmid: "{{ pve_lxc_vmid }}"
state: started
no_log: true