blob: c7c2962e62b5675a841213fe7f9fe8460b0619ac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
---
- name: "Download LXC template"
community.proxmox.proxmox_template:
api_host: "{{ ansible_facts['hostname'] }}"
api_user: "{{ pve_admin_user }}@pve"
api_password: "{{ pve_admin_password }}"
validate_certs: false
node: "{{ ansible_facts['hostname'] }}"
storage: "local"
content_type: "vztmpl"
template: "{{ pve_lxc_template }}"
state: present
tags:
# PVE API not available in containers — requires proxmox-ve package
- "molecule-notest"
- name: "Provision LXC container"
community.proxmox.proxmox:
api_host: "{{ ansible_facts['hostname'] }}"
api_user: "{{ pve_admin_user }}@pve"
api_password: "{{ pve_admin_password }}"
validate_certs: false
node: "{{ ansible_facts['hostname'] }}"
vmid: "{{ pve_lxc_id }}"
hostname: "{{ pve_lxc_hostname }}"
ostemplate: "local:vztmpl/{{ pve_lxc_template }}"
disk: "{{ pve_lxc_disk }}"
cores: "{{ pve_lxc_cores }}"
memory: "{{ pve_lxc_memory }}"
pubkey: "{{ user_public_keys | join('\n') }}"
netif:
net0: "name=eth0,ip={{ pve_lxc_ip }},gw={{ pve_lxc_gateway }},bridge=vmbr0"
nameserver: "{{ pve_lxc_dns }}"
onboot: true
unprivileged: true
cmode: "shell"
state: present
tags:
# PVE API not available in containers — requires proxmox-ve package
- "molecule-notest"
- name: "Start LXC container"
community.proxmox.proxmox:
api_host: "{{ ansible_facts['hostname'] }}"
api_user: "{{ pve_admin_user }}@pve"
api_password: "{{ pve_admin_password }}"
validate_certs: false
node: "{{ ansible_facts['hostname'] }}"
vmid: "{{ pve_lxc_id }}"
hostname: "{{ pve_lxc_hostname }}"
state: started
tags:
# PVE API not available in containers — requires proxmox-ve package
- "molecule-notest"
- name: "Bootstrap python3 for ansible"
become: true
ansible.builtin.command:
cmd: >
pct exec {{ pve_lxc_id }} -- sh -c
'which python3 > /dev/null 2>&1 && exit 0;
. /etc/os-release;
case $ID in
alpine) apk add --no-cache python3 ;;
debian|ubuntu) apt-get install -y python3 ;;
*) echo "Unsupported distro: $ID" && exit 1 ;;
esac;
echo "installed"'
register: pve_lxc_bootstrap
changed_when: "'installed' in pve_lxc_bootstrap.stdout"
tags:
# PVE API not available in containers — requires proxmox-ve package
- "molecule-notest"
|