Compare commits
3 Commits
fa263a4b27
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| cb5342d0b9 | |||
| 98bf9f3c25 | |||
| a71d196cc0 |
@@ -61,16 +61,24 @@
|
|||||||
-features {{ container_features }}
|
-features {{ container_features }}
|
||||||
args:
|
args:
|
||||||
creates: "/etc/pve/lxc/{{ container_id }}.conf"
|
creates: "/etc/pve/lxc/{{ container_id }}.conf"
|
||||||
|
no_log: true
|
||||||
|
|
||||||
# -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \
|
# -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \
|
||||||
|
|
||||||
# -timezone: {{ localization_timezone }} \
|
# -timezone: {{ localization_timezone }} \
|
||||||
|
|
||||||
- name: Start the LXC container {{ container_hostname }}
|
- 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:
|
ansible.builtin.command:
|
||||||
cmd: pct start {{ container_id }}
|
cmd: pct start {{ container_id }}
|
||||||
|
when: "'status: stopped' in pct_status.stdout"
|
||||||
register: start_result
|
register: start_result
|
||||||
changed_when: "'started' in start_result.stdout or start_result.rc == 0"
|
changed_when: "'status: stopped' in pct_status.stdout"
|
||||||
|
|
||||||
- name: Wait until container has an IP address
|
- 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 {{ container_id }} -- hostname -I | awk '{print $1}'"
|
||||||
@@ -79,6 +87,7 @@
|
|||||||
retries: 10
|
retries: 10
|
||||||
delay: 5
|
delay: 5
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
failed_when: lxc_ip.stdout == ""
|
||||||
|
|
||||||
- name: Wait for SSH to become available
|
- name: Wait for SSH to become available
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
@@ -86,6 +95,11 @@
|
|||||||
port: 22
|
port: 22
|
||||||
delay: 5
|
delay: 5
|
||||||
timeout: 60
|
timeout: 60
|
||||||
|
retries: 10
|
||||||
|
delay: 5
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
# --- DC‑1 Provisioning Play --------------------------------------------
|
||||||
|
|
||||||
- name: Provision dc1 LXC
|
- name: Provision dc1 LXC
|
||||||
hosts: dc1
|
hosts: dc1
|
||||||
@@ -110,20 +124,25 @@
|
|||||||
# - openssh-server
|
# - openssh-server
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Update all packages to their latest version
|
- name: Update all packages, autoclean, and autoremove
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "*"
|
name: "*"
|
||||||
state: latest
|
state: latest
|
||||||
|
|
||||||
- name: Remove useless packages from the cache
|
|
||||||
ansible.builtin.apt:
|
|
||||||
autoclean: yes
|
autoclean: yes
|
||||||
|
|
||||||
- name: Remove dependencies that are no longer required and purge their configuration files
|
|
||||||
ansible.builtin.apt:
|
|
||||||
autoremove: yes
|
autoremove: yes
|
||||||
purge: true
|
purge: true
|
||||||
|
|
||||||
- name: Set timezone to {{ localization_timezone }}
|
- name: Set timezone to {{ localization_timezone }}
|
||||||
community.general.timezone:
|
community.general.timezone:
|
||||||
name: "{{ localization_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
|
||||||
Reference in New Issue
Block a user