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.
This commit is contained in:
@@ -70,6 +70,20 @@
|
||||
register: start_result
|
||||
changed_when: "'started' in start_result.stdout or start_result.rc == 0"
|
||||
|
||||
- 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
|
||||
|
||||
- name: Wait for SSH to become available
|
||||
ansible.builtin.wait_for:
|
||||
host: "{{ lxc_ip.stdout }}"
|
||||
port: 22
|
||||
delay: 5
|
||||
timeout: 60
|
||||
|
||||
- name: Provision dc1 LXC
|
||||
hosts: dc1
|
||||
|
||||
Reference in New Issue
Block a user