Added a new setup for creating a Proxmox LXC container using pct command, including hostname, MAC address, IP address and network settings. This setup is designed to work with the existing Ansible playbook.
73 lines
2.7 KiB
YAML
73 lines
2.7 KiB
YAML
- hosts: node0
|
|
gather_facts: no
|
|
|
|
vars:
|
|
addc_hostname: "DC1"
|
|
mac_address: "8E:90:31:DE:31:36"
|
|
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
|
|
|
|
tasks:
|
|
|
|
- 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 \
|
|
-hostname {{ addc_hostname }} \
|
|
-password 123456 \
|
|
-cores 2 \
|
|
-memory 2048 \
|
|
-net0 name=eth0,bridge=vmbr0,ip={{ container_ip }}/24,gw={{ addc_ansible_host }} \
|
|
-rootfs local:1G
|
|
become: yes
|
|
become_user: root
|
|
|
|
|
|
- hosts: localhost
|
|
gather_facts: no
|
|
|
|
vars:
|
|
addc_hostname: "DC1"
|
|
mac_address: "8E:90:31:DE:31:36"
|
|
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
|
|
|
|
tasks:
|
|
|
|
- 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: 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"
|