Compare commits

...

27 Commits

Author SHA1 Message Date
cb5342d0b9 style 💎: Update command to shell instead of command
Switched from `command` to `shell` in the `pct exec` task for better readability and flexibility.
2025-11-02 17:06:49 +01:00
98bf9f3c25 chore 📦: Update setupacdc.yml to improve container provisioning and cleanup processes
Updated the setupacdc.yml configuration to include additional checks for container IP address availability, improved package management, and enhanced timezone handling. These changes aim to streamline the provisioning process while maintaining a clean and efficient environment.
2025-11-02 16:59:48 +01:00
a71d196cc0 chore 📦: Update LXC container management in setupacdc.yml
Updated the Ansible playbook to check if a LXC container is running before starting it, and added a conditional statement to start the container only when it's stopped. This change improves the reliability of the setup process.
2025-11-02 12:36:17 +01:00
fa263a4b27 chore 📦: Update setupacdc.yml to include rootfs size
Updated the rootfs size in the setupacdc.yml file to match the new disk size, ensuring consistency with the latest container storage configuration.
2025-11-02 12:26:02 +01:00
d706c92a2f chore 📦: Update rootfs path in setupacdc.yml
Updated the rootfs path to use a more efficient storage format, reducing disk space requirements.
2025-11-02 12:22:14 +01:00
ed30cb748b style 💎: Update rootfs size to use a single value
Simplified the rootfs configuration by removing the size parameter and using a single value of 7G, making it consistent with other configurations.
2025-11-02 12:14:49 +01:00
fa5ee9d085 style 💎: Update rootfs size in setupacdc.yml
Updated the rootfs size from a local LVM to a fixed size of 7G, simplifying the configuration process.
2025-11-02 12:13:18 +01:00
e1ea5b53d1 style 💎: Update rootfs configuration for LXC containers
Updated the rootfs configuration in setupacdc.yml to include the local-lvm partition, ensuring consistency with PVE's requirements.
2025-11-02 12:11:03 +01:00
c2736624d8 chore 📦: Update setupacdc.yml to include rootfs configuration
Added a new parameter to the setupacdc.yml file to specify the root filesystem for containers, allowing for more flexible and efficient container setup. This change enables the use of local LVM as the root filesystem for containers, improving overall system performance and security.
2025-11-02 12:10:41 +01:00
95fe09aa72 chore 📦: Update package manager and cleanup
Updated the package manager to use apt, added commands to update all packages to their latest version, remove useless packages from the cache, and remove dependencies that are no longer required. This should improve the overall efficiency of the setup process.
2025-11-02 11:59:14 +01:00
428516978c chore 📦: Improve setup process for container creation
Added checks to ensure container has an IP address and SSH is available before proceeding with the setup. This improves the reliability of the setup process.
2025-11-02 11:11:01 +01:00
bff09c8fab style 💎: Update timezone variable formatting
Updated the timezone variable in setupacdc.yml from `{{ localization_timezone }}` to `{{ localization_timezone }}`, ensuring consistent formatting and readability.
2025-11-02 11:05:54 +01:00
af9a1417d4 chore 📦: Update setupacdc.yml with new container configuration and timezone settings
Updated the setupacdc.yml file to include a new provision for dc1 LXC, added a task to set the timezone using community.general.timezone, and updated package installation. This change enables more flexible container configurations and timezone management.
2025-11-02 11:04:30 +01:00
52b4abee8c chore 📦: Update package dependencies in setupacdc.yml
Updated the list of packages to be installed during setup, removing unnecessary dependencies.
2025-11-02 10:48:51 +01:00
13d07f31b6 chore 📦: Update timezone in setupacdc.yml
Updated the timezone parameter in the setupacdc.yml file to include localization_timezone, allowing for more flexible container configuration. This change enables the use of a custom timezone for containers, improving overall flexibility and customization options.
2025-11-02 10:47:57 +01:00
2eedffd23c chore 📦: Update setupacdc.yml to remove unnecessary package
Removed the 'openssh-server' package from the setup script as it's no longer required. This change simplifies the setup process and reduces unnecessary dependencies.
2025-11-02 10:42:14 +01:00
f880f5b8d5 chore 📦: Update setupacdc.yml to combine SSH public keys into one file
Updated the setupacdc.yml configuration to combine SSH public keys into a single file, improving security and organization. This change simplifies the process of managing SSH keys for LXC containers.
2025-11-02 10:21:23 +01:00
fa68e6b6a8 style 💎: Update setupacdc.yml to use double quotes for ssh-public-keys
Fixed formatting issue in setupacdc.yml file by updating the ssh-public-keys parameter to use double quotes instead of single quotes. This change ensures consistent and correct parsing of the configuration file.
2025-11-02 10:11:41 +01:00
da956e8ddd style 💎: Update container pubkey to use first key from list
Changed the way the container public key is set in setupacdc.yml, now it uses the first key from the ssh_public_keys list instead of all keys. This change improves consistency and reduces potential security risks.
2025-11-02 10:10:17 +01:00
8fb2503018 chore 📦: Update setupacdc.yml to use default public key
Updated the `container_pubkey` setting in `tasks/setupacdc.yml` to utilize the default public key provided by Ansible, eliminating the need for manual configuration of the SSH public key.
2025-11-02 10:07:05 +01:00
82b4bd3e9c chore 📦: Update setupacdc.yml to use container_pubkey
Updated the setupacdc.yml file to include the container's SSH public key for authorized key management, ensuring secure access to the container. This change improves security and reduces manual configuration steps.
2025-11-02 10:04:28 +01:00
4537dcd27a chore 📦: Update setupacdc.yml with new LXC provision and package management tasks
Updated the LXC provision task to include SSH authorized keys and updated package management to install useful packages like nano, tzdata, and openssh-server. This change improves the overall setup process for the DC1 LXC.
2025-11-02 09:53:07 +01:00
deb7676cce chore 📦: Update setupacdc.yml to use correct hostname
Updated the hosts variable in the setupacdc.yml file to match the actual hostname 'dc1' instead of 'addc_hostname'. This change ensures that the provisioning task targets the correct host.
2025-11-02 09:33:36 +01:00
05ab960852 style 💎: Fix typo in hostname variable
Corrected the typo in the `addc_hostname` variable to ensure correct host selection for LXC provisioning.
2025-11-02 09:31:25 +01:00
9f1ee6b80e style 💎: Improve host variable formatting in setupacdc.yml
Updated the `hosts` variable to use double quotes for better readability and consistency with other Ansible variables.
2025-11-02 09:22:09 +01:00
27d447338d chore 📦: Update setupacdc.yml to enable container provisioning
Updated the setupacdc.yml configuration to enable container provisioning for the addc_hostname. This change allows for more flexible and dynamic deployment of containers within the LXC environment.
2025-11-02 09:20:37 +01:00
5262fff75c chore 📦: Update setupacdc.yml to include hostname and id in LXC container creation
Updated the pct command to include hostname and id for more accurate container creation. This change ensures consistency in container naming across different environments.
2025-11-02 09:06:44 +01:00

View File

@@ -7,7 +7,6 @@
vars:
node_ip: "{{ hostvars['node0']['ansible_host'] }}"
addc_hostname: "DC1"
mac_address: "8E:90:31:DE:31:36"
container_id: 200
@@ -26,19 +25,29 @@
container_onboot: 1
container_protection: 0
container_unprivileged: 1
# container_tags: "ansible_managed,test"
container_pubkey: "{{ ssh_public_keys[0] }}"
container_tags:
- ansible_managed
- test
tasks:
- name: Create LXC container using pct command on shell
- name: Combine SSH public keys into one file
ansible.builtin.copy:
dest: "{{ ssh_keys_file }}"
content: |
{% for key in ssh_public_keys %}
{{ key }}
{% endfor %}
mode: '0644'
- name: Create LXC container {{ container_hostname }} with id {{ container_id }} using pct command on shell
ansible.builtin.shell: |
pct create {{ container_id }} {{ container_template }} \
-ostype {{ container_ostype }} \
-hostname {{ container_hostname }} \
-password {{ container_password }} \
-ssh-public-keys {{ ssh_keys_file }} \
-cores {{ container_cores }} \
-memory {{ container_memory }} \
-swap {{ container_swap }} \
@@ -52,5 +61,88 @@
-features {{ container_features }}
args:
creates: "/etc/pve/lxc/{{ container_id }}.conf"
no_log: true
# -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \
# -timezone: {{ localization_timezone }} \
- name: Check if LXC container {{ container_hostname }} is running
ansible.builtin.command:
cmd: pct status {{ container_id }}
register: pct_status
changed_when: false
- name: Start the LXC container {{ container_hostname }} if stopped
ansible.builtin.command:
cmd: pct start {{ container_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}'"
register: lxc_ip
until: lxc_ip.stdout != ""
retries: 10
delay: 5
changed_when: false
failed_when: lxc_ip.stdout == ""
- name: Wait for SSH to become available
ansible.builtin.wait_for:
host: "{{ lxc_ip.stdout }}"
port: 22
delay: 5
timeout: 60
retries: 10
delay: 5
changed_when: false
# --- DC1 Provisioning Play --------------------------------------------
- name: Provision dc1 LXC
hosts: dc1
gather_facts: false
become: true
tasks:
# - name: Ensure SSH authorized keys are present
# ansible.posix.authorized_key:
# user: root
# key: "{{ item }}"
# state: present
# loop: "{{ ssh_public_keys }}"
- name: Install useful packages
ansible.builtin.package:
name:
- nano
- tzdata
# - openssh-server
state: present
- name: Update all packages, autoclean, and autoremove
ansible.builtin.apt:
name: "*"
state: latest
autoclean: yes
autoremove: yes
purge: true
- name: Set timezone to {{ localization_timezone }}
community.general.timezone:
name: "{{ localization_timezone }}"
notify: Restart sshd
tags: [timezone]
# --- Global Handlers ----------------------------------------------
handlers:
- name: Restart sshd
ansible.builtin.service:
name: ssh
state: restarted
when: localization_timezone | bool