summaryrefslogtreecommitdiffstats
path: root/roles/pve-lxc/tasks/main.yml
blob: 5d035270664942f9e5b3aad39472a79fbccf61a8 (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
---
- name: "Download LXC template"
  community.general.proxmox_template:
    api_host: "{{ ansible_facts['hostname'] }}"
    api_user: "{{ pve_admin_user }}@pve"
    api_password: "{{ pve_admin_password }}"
    node: "{{ ansible_facts['hostname'] }}"
    storage: "local"
    content_type: "vztmpl"
    template: "{{ pve_lxc_template }}"
    state: present
  no_log: true
  tags:
    # PVE API not available in containers — requires proxmox-ve package
    - "molecule-notest"

- name: "Provision LXC container"
  community.general.proxmox:
    api_host: "{{ ansible_facts['hostname'] }}"
    api_user: "{{ pve_admin_user }}@pve"
    api_password: "{{ pve_admin_password }}"
    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
    state: present
  tags:
    # PVE API not available in containers — requires proxmox-ve package
    - "molecule-notest"

- name: "Start LXC container"
  community.general.proxmox:
    api_host: "{{ ansible_facts['hostname'] }}"
    api_user: "{{ pve_admin_user }}@pve"
    api_password: "{{ pve_admin_password }}"
    vmid: "{{ pve_lxc_id }}"
    state: started
  no_log: true
  tags:
    # PVE API not available in containers — requires proxmox-ve package
    - "molecule-notest"