aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2023-01-08 10:40:38 +0100
committeralex <alex@pdp7.net>2023-01-08 10:40:38 +0100
commita99b34d101b6d334cebcd3281c8be1d164ee6fc3 (patch)
tree7232cec566125938bc70d845d641b4b93699dad0
parent32255a6ca690a50326cd67f536b141703f8debd8 (diff)
Add basic proxmox_create_lxc
-rw-r--r--personal_infra/playbooks/proxmox_create_lxc.yml32
1 files changed, 32 insertions, 0 deletions
diff --git a/personal_infra/playbooks/proxmox_create_lxc.yml b/personal_infra/playbooks/proxmox_create_lxc.yml
new file mode 100644
index 00000000..2483cacc
--- /dev/null
+++ b/personal_infra/playbooks/proxmox_create_lxc.yml
@@ -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 }}"