From e033652d3ec6dd69cf2890e988ef781774861ae0 Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Tue, 7 Jul 2026 11:40:00 +0000 Subject: [PATCH] FEATURE: automatic LXC creation added --- playbooks/deploy.yaml | 24 ++++++++++++++-------- roles/00_basic_proxmox_lxc/tasks/main.yaml | 24 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 roles/00_basic_proxmox_lxc/tasks/main.yaml diff --git a/playbooks/deploy.yaml b/playbooks/deploy.yaml index 16d5029..1a29210 100644 --- a/playbooks/deploy.yaml +++ b/playbooks/deploy.yaml @@ -1,14 +1,20 @@ --- -- name: Basic Proxmox guest deployment - hosts: all - remote_user: root +- name: Deplot simple test LXC on Proxmox VE + hosts: localhost + gather_facts: false roles: - - ../roles/0_basic_postinstall - vars_files: - ../inventory/group_vars/all/secrets.yaml - vars: - ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}" - user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}" + - ../roles/00_basic_proxmox_lxc + +#- name: Basic Proxmox guest deployment +# hosts: all +# remote_user: root +# roles: +# - ../roles/01_basic_postinstall +# vars_files: +# ../inventory/group_vars/all/secrets.yaml +# vars: +# ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}" +# user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}" handlers: - name: restart sshd diff --git a/roles/00_basic_proxmox_lxc/tasks/main.yaml b/roles/00_basic_proxmox_lxc/tasks/main.yaml new file mode 100644 index 0000000..9f808d2 --- /dev/null +++ b/roles/00_basic_proxmox_lxc/tasks/main.yaml @@ -0,0 +1,24 @@ +--- + +- name: Create new container with minimal options defining network interface with static ip + become: no + community.proxmox.proxmox: + node: proxmox-server + api_user: root@pam + api_host: 192.168.0.2 + api_token_id: ansible + api_token_secret: "{{ proxmox_token_secret }}" + + vmid: 1040 + password: ansible-test + hostname: "ansible-test" + ostemplate: 'main:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst' + memory: 2048 + cores: 5 + state: started + disk_volume: + size: 2 # 2GB rootfs + storage: local + pubkey: "{{ lookup('file', lookup('env','HOME') + '/.ssh/ansible_key.pub') }}" + netif: + net0: "name=eth0,gw=192.168.0.1,ip=192.168.0.40/24,bridge=vmbr0" \ No newline at end of file