refactor ♻️: Update LXC container setup with new ostype and netif options

Updated the LXC container setup to include a new ostype and netif options. The ostype has been changed to 'debian' and the netif options have been updated to include the mac address and location gateway. This change improves the consistency of the setup and ensures that the container is properly configured for the environment.
This commit is contained in:
2025-11-01 22:57:14 +01:00
parent f51a07d59d
commit 6751680c59

View File

@@ -11,62 +11,66 @@
- name: Create LXC container using pct command
shell: |
pct create 200 '/var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst' \
--ostype debian \
--hostname {{ addc_hostname }} \
--password 123456 \
--cores 2 \
--memory 2048 \
--net0 name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }} \
--storage local-lvm
--swap 256 \
--net0 name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }} \
--storage local-lvm \
--unprivileged 0 \
--timezone: "Europe/Rome"
become: yes
become_user: root
- hosts: localhost
gather_facts: no
# - hosts: localhost
# gather_facts: no
vars:
addc_hostname: "DC1"
mac_address: "8E:90:31:DE:31:36"
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
# vars:
# addc_hostname: "DC1"
# mac_address: "8E:90:31:DE:31:36"
# node_ip: "{{ hostvars['node0']['ansible_host'] }}"
tasks:
# tasks:
- name: Install 'proxmoxer' and 'requests' Python libraries for the ansible controller
ansible.builtin.pip:
name:
- proxmoxer
- requests
state: present
become: no
# - name: Install 'proxmoxer' and 'requests' Python libraries for the ansible controller
# ansible.builtin.pip:
# name:
# - proxmoxer
# - requests
# state: present
# become: no
- name: Print node IP
debug:
msg: "The IP address of node0 is {{ node_ip }}"
# - name: Print node IP
# debug:
# msg: "The IP address of node0 is {{ node_ip }}"
- name: Create lxc container
community.proxmox.proxmox:
vmid: 200
node: "{{ node_ip }}"
api_user: root@pam
api_password: "{{ proxmox_password }}"
api_host: "{{ node_ip }}"
password: 123456
hostname: "{{ addc_hostname }}"
ostemplate: 'local:vztmpl/debian-13-standard_13.1-1_amd64.tar.zst'
validate_certs: false
# ostype: debian
# description: samba ad dc
# cores: 2
# memory: 2048
# disk: 'local-lvm:10'
# timezone: "Europe/Rome"
# onboot: true
# unprivileged: true
# features:
# - nesting=1
# - keyctl=1
# - mount=cifs
# pubkey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCZgalXzHToHYdyl59O0dyZNffN0BGbILUCJGmJs/VNm7dpeJ6uj9/LDapcCK0dH1P4eaHd9aET4hkK04xSyX6CfVER2Wcz/G0z2wHCv9mQ3EUWPQI1ESxNhqtfGsPUmoDGzBdsOFK2qSS+FMJnZ/KUgXGU8lxdWUMHccQsSPWWp51Js/hfbhX80Q7TlacOBV1spoaMZDITuhWFhWRbL8X0Y+iG6QrnR36M9E4zMBk/LO33GAhqHlAoeQqjL62DpLQ7/+7aIM/IR6JzGTG5aaaPHpYFTXWJO4zSL3QcW+xbqrPozoszSnnw0Hc1WVwKY6bJSM7OoeFys27Ul7fMIuiZtQ2EfFgD1BGrPxU++k5Pdexg+IU+3QTWBH+GFlWrwjI+0siKw9VovljpLIIJk8EaK65gD/yrD4I5Wm2qVbzfYIT5tXIsGpoZDlw3dtcWfeSj3BYhN3PbDY7o2oqVygJTuN43EEuj0QehyRZKN52x1SBtJ/9KBrFhSLsU0F8mkpJyluiULbrFkOmnfig8e10OE1rZX9vIIDV7TnJ6i536pyGyvmY5VwDQ617qJpK5mbZWzWlv+J7KK4rTbmV9I97xSzpB0c+nVgtEAJ5AhsVBjlMHHawFDzucaoYK5rSnwBGlWHoj+/zy6aHkxiFDLfOsNg0yhPN6ATpCvOm849l8TQ== admin@localhost'
# netif:
# net0: "name=eth0,hwaddr={{ mac_address }},gw={{ location_gateway }},ip={{ addc_ansible_host }}/24,bridge=vmbr0"
# - name: Create lxc container
# community.proxmox.proxmox:
# vmid: 200
# node: "{{ node_ip }}"
# api_user: root@pam
# api_password: "{{ proxmox_password }}"
# api_host: "{{ node_ip }}"
# password: 123456
# hostname: "{{ addc_hostname }}"
# ostemplate: 'local:vztmpl/debian-13-standard_13.1-1_amd64.tar.zst'
# validate_certs: false
# # ostype: debian
# # description: samba ad dc
# # cores: 2
# # memory: 2048
# # disk: 'local-lvm:10'
# # timezone: "Europe/Rome"
# # onboot: true
# # unprivileged: true
# # features:
# # - nesting=1
# # - keyctl=1
# # - mount=cifs
# # pubkey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCZgalXzHToHYdyl59O0dyZNffN0BGbILUCJGmJs/VNm7dpeJ6uj9/LDapcCK0dH1P4eaHd9aET4hkK04xSyX6CfVER2Wcz/G0z2wHCv9mQ3EUWPQI1ESxNhqtfGsPUmoDGzBdsOFK2qSS+FMJnZ/KUgXGU8lxdWUMHccQsSPWWp51Js/hfbhX80Q7TlacOBV1spoaMZDITuhWFhWRbL8X0Y+iG6QrnR36M9E4zMBk/LO33GAhqHlAoeQqjL62DpLQ7/+7aIM/IR6JzGTG5aaaPHpYFTXWJO4zSL3QcW+xbqrPozoszSnnw0Hc1WVwKY6bJSM7OoeFys27Ul7fMIuiZtQ2EfFgD1BGrPxU++k5Pdexg+IU+3QTWBH+GFlWrwjI+0siKw9VovljpLIIJk8EaK65gD/yrD4I5Wm2qVbzfYIT5tXIsGpoZDlw3dtcWfeSj3BYhN3PbDY7o2oqVygJTuN43EEuj0QehyRZKN52x1SBtJ/9KBrFhSLsU0F8mkpJyluiULbrFkOmnfig8e10OE1rZX9vIIDV7TnJ6i536pyGyvmY5VwDQ617qJpK5mbZWzWlv+J7KK4rTbmV9I97xSzpB0c+nVgtEAJ5AhsVBjlMHHawFDzucaoYK5rSnwBGlWHoj+/zy6aHkxiFDLfOsNg0yhPN6ATpCvOm849l8TQ== admin@localhost'
# # netif:
# # net0: "name=eth0,hwaddr={{ mac_address }},gw={{ location_gateway }},ip={{ addc_ansible_host }}/24,bridge=vmbr0"