chore 📦: Update setupacdc.yml with new LXC container configuration
Updated the setupacdc.yml file to include a new LXC container configuration, including host and network settings. This change allows for more flexibility in provisioning containers on Proxmox.
This commit is contained in:
@@ -1,31 +1,65 @@
|
|||||||
- hosts: node0
|
---
|
||||||
|
- name: Create and provision LXC container on Proxmox
|
||||||
|
hosts: node0
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
|
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
|
||||||
addc_hostname: "DC1"
|
addc_hostname: "DC1"
|
||||||
mac_address: "8E:90:31:DE:31:36"
|
mac_address: "8E:90:31:DE:31:36"
|
||||||
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
|
|
||||||
|
container_id: 200
|
||||||
|
container_template: /var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst
|
||||||
|
|
||||||
|
container_hostname: "{{ addc_hostname }}"
|
||||||
|
container_storage: local-lvm
|
||||||
|
container_rootfs_size: 8G
|
||||||
|
container_memory: 1024
|
||||||
|
container_cores: 2
|
||||||
|
container_net: name=eth0,bridge=vmbr0,ip=dhcp
|
||||||
|
container_features: keyctl=1,nesting=1,mount=cifs
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Ensure container does not exist
|
||||||
|
|
||||||
- name: Create LXC container using pct command
|
- name: Create LXC container using pct command
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: >
|
||||||
|
pct create 201
|
||||||
|
{{ container_template }}
|
||||||
|
--hostname {{ container_hostname }}2
|
||||||
|
--storage {{ container_storage }}
|
||||||
|
--rootfs {{ container_rootfs_size }}
|
||||||
|
--memory {{ container_memory }}
|
||||||
|
--cores {{ container_cores }}
|
||||||
|
--net0 {{ container_net }}
|
||||||
|
--unprivileged 1
|
||||||
|
--features {{ container_features }}
|
||||||
|
--ssh-public-keys /root/.ssh/id_rsa.pub
|
||||||
|
args:
|
||||||
|
creates: "/etc/pve/lxc/{{ container_id }}.conf"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Create LXC container using pct command on shell
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
pct create 200 '/var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst' \
|
pct create {{ container_id }} {{ container_template }} \
|
||||||
-ostype debian \
|
-ostype debian \
|
||||||
-hostname {{ addc_hostname }} \
|
-hostname {{ container_hostname }} \
|
||||||
-password 123456 \
|
-password 123456 \
|
||||||
-cores 2 \
|
-cores {{ container_cores }} \
|
||||||
-memory 1024 \
|
-memory {{ container_memory }} \
|
||||||
-swap 128 \
|
-swap 128 \
|
||||||
-net0 name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }} \
|
-net0 name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }} \
|
||||||
-storage local-lvm \
|
-storage {{ container_storage }} \
|
||||||
-description "default lxc" \
|
-description "default lxc" \
|
||||||
-onboot 1 \
|
-onboot 1 \
|
||||||
-protection 0 \
|
-protection 0 \
|
||||||
-unprivileged 1 \
|
-unprivileged 1 \
|
||||||
-tags "ansible_managed,test" \
|
-tags "ansible_managed,test" \
|
||||||
-features keyctl=1,nesting=1,mount=cifs
|
-features {{ container_features }}
|
||||||
|
|
||||||
become: yes
|
|
||||||
become_user: root
|
|
||||||
# -timezone: {{ localization_timezone }} \
|
# -timezone: {{ localization_timezone }} \
|
||||||
|
|||||||
Reference in New Issue
Block a user