]> xn--ix-yja.es Git - alex.git/commitdiff
Add basic proxmox_create_lxc
authoralex <alex@pdp7.net>
Sun, 8 Jan 2023 09:40:38 +0000 (10:40 +0100)
committeralex <alex@pdp7.net>
Sun, 8 Jan 2023 09:40:38 +0000 (10:40 +0100)
personal_infra/playbooks/proxmox_create_lxc.yml [new file with mode: 0644]

diff --git a/personal_infra/playbooks/proxmox_create_lxc.yml b/personal_infra/playbooks/proxmox_create_lxc.yml
new file mode 100644 (file)
index 0000000..2483cac
--- /dev/null
@@ -0,0 +1,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 }}"