feat: Enhance LXC creation playbook with SSH key injection and new parameters, introduce Ansible configuration, and adjust script paths and secret variable names.

This commit is contained in:
2026-01-04 12:49:48 +01:00
parent 5e7073e414
commit deefc70056
5 changed files with 12 additions and 8 deletions

View File

@@ -6,12 +6,13 @@ This directory contains automation playbooks for managing the homelab infrastruc
### `create_lxc.yml`
**Creates and bootstraps a new LXC container on Proxmox.**
- **Input**: Prompts for Container Name and IP Address.
- **Input**: Prompts for Container Name, IP Address, VMID, CPU Cores, and Memory.
- **Actions**:
1. Connects to Proxmox API to create a new unprivileged LXC container (Ubuntu 24.04).
2. Starts the container and waits for connectivity.
3. Temporarily adds the host to the inventory.
4. Automatically triggers `lxc_setup_ubuntu.yml` to secure the new container.
1. Connects to Proxmox API to create a new unprivileged LXC container.
2. **Injects SSH Keys**: Uses `vars.yml` to inject public keys directly into `/root/.ssh/authorized_keys` (bypassing password auth).
3. Starts the container and waits for connectivity.
4. Automatically secures the container (creates `mbuz` user, secures SSH, disables root) effectively running the logic of `lxc_setup_ubuntu.yml`.
5. Adds the new host to `inventory/hosts.ini` in the `[lxc]` group.
### `lxc_setup_ubuntu.yml`
**Secures a fresh Ubuntu installation.**

View File

@@ -40,7 +40,7 @@
ostemplate: '{{ proxmox_storage }}:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst'
vmid: "{{ container_id }}"
hostname: "{{ container_name }}"
password: "{{ ansible_password }}"
password: "{{ lxc_root_password }}"
pubkey: "{{ my_public_keys | join('\n') }}"
netif:
net0: "name=eth0,gw=10.0.0.1,ip={{ container_ip_cidr }},bridge=vmbr0"