diff --git a/playbooks/containers-lxc-create.yml b/playbooks/containers-lxc-create.yml index c9b0b5ca4a..8ebb152984 100644 --- a/playbooks/containers-lxc-create.yml +++ b/playbooks/containers-lxc-create.yml @@ -40,10 +40,18 @@ delay: "{{ lxc_container_wait_params.delay | default(omit) }}" sleep: "{{ lxc_container_wait_params.sleep | default(omit) }}" timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}" - - name: Set local facts for new container(s) + + # When using gather_facts with smart gathering, + # the facts aren't fully updated unless they + # are old. Using the setup module in a task + # does a more thorough collection. + # Given we've just created the container, it is + # best that we do a full collection of facts - + # otherwise we end up with a stale set which + # has stuff like the hostname = localhost. + - name: Gather facts for new container(s) setup: - filter: ansible_local - gather_subset: "!all" + gather_subset: "network,hardware,virtual" environment: "{{ deployment_environment_variables | default({}) }}" tags: - lxc-containers-create diff --git a/playbooks/containers-nspawn-create.yml b/playbooks/containers-nspawn-create.yml index 0e263dc231..3162727e96 100644 --- a/playbooks/containers-nspawn-create.yml +++ b/playbooks/containers-nspawn-create.yml @@ -37,6 +37,25 @@ user: root roles: - role: "nspawn_container_create" + post_tasks: + - name: Wait for container connectivity + wait_for_connection: + connect_timeout: "{{ lxc_container_wait_params.connect_timeout | default(omit) }}" + delay: "{{ lxc_container_wait_params.delay | default(omit) }}" + sleep: "{{ lxc_container_wait_params.sleep | default(omit) }}" + timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}" + + # When using gather_facts with smart gathering, + # the facts aren't fully updated unless they + # are old. Using the setup module in a task + # does a more thorough collection. + # Given we've just created the container, it is + # best that we do a full collection of facts - + # otherwise we end up with a stale set which + # has stuff like the hostname = localhost. + - name: Gather facts for new container(s) + setup: + gather_subset: "network,hardware,virtual" environment: "{{ deployment_environment_variables | default({}) }}" tags: - nspawn-containers-create