aboutsummaryrefslogtreecommitdiff
path: root/personal_infra/playbooks/proxmox_create_lxc.yml
blob: 2483cacc8a8149794013c6ec18c0f59e7470cf82 (plain)
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
---
- name: create lxc
  hosts: lxc
  gather_facts: false
  collections:
    - ansible.builtin
    - community.general

  vars:
    flavors:
      el9:
        template: rockylinux-9-default_20221109
        
  tasks:
    - name: download template
      command: "pveam download local {{ flavors[proxmox.flavor].template }}"
      args:
        creates: "/var/lib/vz/template/cache/{{ flavors[proxmox.flavor].template }}_amd64.tar.xz"
      delegate_to: "{{ proxmox.host }}"
    - name: create host
      command: >
        pct create {{ proxmox.id }} "/var/lib/vz/template/cache/{{ flavors[proxmox.flavor].template }}_amd64.tar.xz"
          --hostname {{ inventory_hostname }}
          --storage local-zfs
          -net0 name=eth0,bridge=vmbr0,ip=dhcp
          -onboot 1
          --unprivileged
          --password {{ ansible_password }}
          --nameserver {{ hostvars[proxmox.host].network.self_internal_ip }}
      args:
        creates: "/etc/pve/lxc/{{ proxmox.id }}.conf"
      delegate_to: "{{ proxmox.host }}"