diff options
| author | alex <alex@pdp7.net> | 2023-01-28 16:36:26 +0100 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2023-01-28 16:36:49 +0100 |
| commit | 39b4e1252ed4d2b7ca971eb48038b5deb137ec9d (patch) | |
| tree | 798aecbfd9f4277cf97f393bf9177541ba9b10e6 /personal_infra/playbooks/roles/proxmox_create_lxc/tasks | |
| parent | dadd31dc8e9fe4ebb2a3856f8125896c58c89e6b (diff) | |
Refactor playbooks into roles
Diffstat (limited to 'personal_infra/playbooks/roles/proxmox_create_lxc/tasks')
| -rw-r--r-- | personal_infra/playbooks/roles/proxmox_create_lxc/tasks/main.yml | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/personal_infra/playbooks/roles/proxmox_create_lxc/tasks/main.yml b/personal_infra/playbooks/roles/proxmox_create_lxc/tasks/main.yml new file mode 100644 index 00000000..e0dd86f8 --- /dev/null +++ b/personal_infra/playbooks/roles/proxmox_create_lxc/tasks/main.yml @@ -0,0 +1,42 @@ +--- +- name: download template + command: "pveam download local {{ flavors[proxmox.flavor].template }}_amd64.tar.xz" + 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|trim }} + --nameserver {{ hostvars[proxmox.host].network.self_internal_ip }} + --ostype {{ flavors[proxmox.flavor].pct_ostype }} + args: + creates: "/etc/pve/lxc/{{ proxmox.id }}.conf" + delegate_to: "{{ proxmox.host }}" +# https://bugzilla.proxmox.com/show_bug.cgi?id=4460 +- name: set hostname + copy: + content: "{{ inventory_hostname }}" + dest: /rpool/data/subvol-{{ proxmox.id }}-disk-0/etc/hostname + delegate_to: "{{ proxmox.host }}" +- name: start host + shell: "{ pct status {{ proxmox.id }} | grep running ; } || pct start {{ proxmox.id }}" + delegate_to: "{{ proxmox.host }}" +- name: update packages to prevent automatic updates causing issues later. retry until network available + command: pct exec {{ proxmox.id }} -- dnf update -y + retries: 10 + delay: 1 + until: result.rc == 0 + register: result + delegate_to: "{{ proxmox.host }}" +- name: install ssh + command: pct exec {{ proxmox.id }} -- dnf install -y openssh-server + delegate_to: "{{ proxmox.host }}" +- name: enable ssh + command: pct exec {{ proxmox.id }} -- systemctl enable --now sshd + delegate_to: "{{ proxmox.host }}" |
