diff --git a/tasks/create_proxmox_debian_template.yml b/tasks/create_proxmox_debian_template.yml index c1b5111..42f8060 100644 --- a/tasks/create_proxmox_debian_template.yml +++ b/tasks/create_proxmox_debian_template.yml @@ -20,7 +20,6 @@ lxc_net: "name=eth0,bridge=vmbr0,ip=dhcp" lxc_rootfs_size: "8G" lxc_password: "password" - container_id: "{{ lxc_id }}" tasks: - block: diff --git a/tasks/setupacdc.yml b/tasks/setupacdc.yml index 81a74fb..7f9d42d 100644 --- a/tasks/setupacdc.yml +++ b/tasks/setupacdc.yml @@ -30,27 +30,27 @@ node_ip: "{{ hostvars['node0']['ansible_host'] }}" mac_address: '8E:90:31:DE:31:36' - container_id: 200 - # container_template: '/var/lib/vz/template/cache/ubuntu-25.04-standard_25.04-1.1_amd64.tar.zst' - container_template: '/var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst' - # container_template: '/var/lib/vz/template/cache/debian-12-standard_12.12-1_amd64.tar.zst' - # container_ostype: ubuntu - container_ostype: debian - container_hostname: '{{ addc_hostname }}' - container_password: '{{ addc_admin_password }}' - container_storage: local-lvm - container_rootfs_size: 8G - container_memory: 1024 - container_swap: 256 - container_cores: 2 - container_net: name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }} - container_features: 'keyctl=1,nesting=1,mount=cifs' - container_description: default lxc - container_onboot: 1 - container_protection: 0 - container_unprivileged: 0 - container_pubkey: '{{ ssh_public_keys[0] }}' - container_tags: + lxc_id: 200 + # lxc_template: '/var/lib/vz/template/cache/ubuntu-25.04-standard_25.04-1.1_amd64.tar.zst' + lxc_template: '/var/lib/vz/template/cache/debian-13-standard_13.1-1_amd64.tar.zst' + # lxc_template: '/var/lib/vz/template/cache/debian-12-standard_12.12-1_amd64.tar.zst' + # lxc_ostype: ubuntu + lxc_ostype: debian + lxc_hostname: '{{ addc_hostname }}' + lxc_password: '{{ addc_admin_password }}' + lxc_storage: local-lvm + lxc_rootfs_size: 8G + lxc_memory: 1024 + lxc_swap: 256 + lxc_cores: 2 + lxc_net: name=eth0,bridge=vmbr0,ip={{ addc_ansible_host }}/24,gw={{ location_gateway }},hwaddr={{ mac_address }} + lxc_features: 'keyctl=1,nesting=1,mount=cifs' + lxc_description: default lxc + lxc_onboot: 1 + lxc_protection: 0 + lxc_unprivileged: 0 + lxc_pubkey: '{{ ssh_public_keys[0] }}' + lxc_tags: - ansible_managed - test @@ -68,52 +68,52 @@ - name: debug # Comment ansible.builtin.debug: - msg: 'Hello world! {{ container_password }}' + msg: 'Hello world! {{ lxc_password }}' verbosity: 0 - - name: Create LXC container {{ container_hostname }} with id {{ container_id }} using pct command on shell + - name: Create LXC container {{ lxc_hostname }} with id {{ lxc_id }} using pct command on shell ansible.builtin.shell: | set -e - pct create {{ container_id }} {{ container_template }} \ - -ostype {{ container_ostype }} \ - -hostname {{ container_hostname }} \ - -password '{{ container_password }}' \ + pct create {{ lxc_id }} {{ lxc_template }} \ + -ostype {{ lxc_ostype }} \ + -hostname {{ lxc_hostname }} \ + -password '{{ lxc_password }}' \ -ssh-public-keys '{{ ssh_keys_file }}' \ - -cores {{ container_cores }} \ - -memory {{ container_memory }} \ - -swap {{ container_swap }} \ - -net0 '{{container_net}}' \ - -storage {{ container_storage }} \ - -description '{{ container_description }}' \ - -onboot {{ container_onboot }} \ - -protection {{ container_protection }} \ - -unprivileged {{ container_unprivileged }} \ - -tags '{{ container_tags | join(',') }}' \ - -features '{{ container_features }}' + -cores {{ lxc_cores }} \ + -memory {{ lxc_memory }} \ + -swap {{ lxc_swap }} \ + -net0 '{{lxc_net}}' \ + -storage {{ lxc_storage }} \ + -description '{{ lxc_description }}' \ + -onboot {{ lxc_onboot }} \ + -protection {{ lxc_protection }} \ + -unprivileged {{ lxc_unprivileged }} \ + -tags '{{ lxc_tags | join(',') }}' \ + -features '{{ lxc_features }}' args: - creates: '/etc/pve/lxc/{{ container_id }}.conf' + creates: '/etc/pve/lxc/{{ lxc_id }}.conf' no_log: false -# -password {{ container_password }} \ -# -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \ +# -password {{ lxc_password }} \ +# -rootfs {{ lxc_storage }}:{{ lxc_id }}/vm-{{ lxc_id }}-disk-0.raw,size=7G \ # -timezone: {{ localization_timezone }} \ - - name: Check if LXC container {{ container_hostname }} is running + - name: Check if LXC container {{ lxc_hostname }} is running ansible.builtin.command: - cmd: pct status {{ container_id }} + cmd: pct status {{ lxc_id }} register: pct_status changed_when: false - - name: Start the LXC container {{ container_hostname }} if stopped + - name: Start the LXC container {{ lxc_hostname }} if stopped ansible.builtin.command: - cmd: pct start {{ container_id }} + cmd: pct start {{ lxc_id }} when: "'status: stopped' in pct_status.stdout" register: start_result changed_when: "'status: stopped' in pct_status.stdout" - name: Wait until container has an IP address - ansible.builtin.shell: "pct exec {{ container_id }} -- hostname -I | awk '{print $1}'" + ansible.builtin.shell: "pct exec {{ lxc_id }} -- hostname -I | awk '{print $1}'" register: lxc_ip until: lxc_ip.stdout != '' retries: 10