diff --git a/tasks/setupacdc.yml b/tasks/setupacdc.yml index a3c05c8..1c2d9e4 100644 --- a/tasks/setupacdc.yml +++ b/tasks/setupacdc.yml @@ -6,8 +6,7 @@ become_user: root vars: - node_ip: "{{ hostvars['node0']['ansible_host'] }}" - addc_hostname: "DC1" + node_ip: "{{ hostvars['node0']['ansible_host'] }}" mac_address: "8E:90:31:DE:31:36" container_id: 200 @@ -54,3 +53,32 @@ creates: "/etc/pve/lxc/{{ container_id }}.conf" # -timezone: {{ localization_timezone }} \ + + - name: Start the LXC container {{ container_hostname }} + ansible.builtin.command: + cmd: pct start {{ container_id }} + register: start_result + changed_when: "'started' in start_result.stdout or start_result.rc == 0" + + # - name: Wait for the container to get an IP address + # ansible.builtin.shell: "pct exec {{ container_id }} -- hostname -I" + # register: container_ip + # until: container_ip.stdout != "" + # retries: 10 + # delay: 5 + + # - name: Get container IP + # ansible.builtin.shell: "pct exec {{ container_id }} -- hostname -I | awk '{print $1}'" + # register: lxc_ip + # changed_when: false + + # - name: Add container to in-memory inventory + # ansible.builtin.add_host: + # name: "{{ container_hostname }}" + # ansible_host: "{{ lxc_ip.stdout }}" + # ansible_user: root + +- name: Provision inside {{ addc_hostname }} LXC + hosts: {{ addc_hostname }} + gather_facts: false + become: true \ No newline at end of file