Use wait_for_connection instead of wait_for to check container
After configuring networking in the container, we used a task to wait for SSH to respond on the container, using the Ansible wait_for module trying to connect to port 22. When managing containers in Ansible using other connection plugins that use LXC commands on the physical host to execute modules, there may not be an SSH daemon running within the container. In these situations we can accomplish the same check without SSH by using the wait_for_connection module (new in ansible 2.3) to verify that Ansible has a working execution path into the container, but not necessarily via SSH. Change-Id: I81beda2590b5f5505b7de9ae94cef06bcbdf2f93
This commit is contained in:
parent
789aaa4e73
commit
4f4fca7507
|
@ -16,8 +16,14 @@
|
|||
## Verbosity Options
|
||||
debug: False
|
||||
|
||||
## SSH connection wait time
|
||||
lxc_container_ssh_delay: 5
|
||||
## Parameters provided to the wait_for_connection module after a container
|
||||
## reboot is triggered by the role
|
||||
lxc_container_wait_params:
|
||||
# Wait 3 seconds before attempting the first connection
|
||||
delay: 3
|
||||
# Wait 60 seconds for the container to respond
|
||||
timeout: 60
|
||||
|
||||
|
||||
lxc_container_config: /etc/lxc/lxc-openstack.conf
|
||||
lxc_container_default_config_list:
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
upgrade:
|
||||
- The var ``lxc_container_ssh_delay`` along with SSH specific ping checks
|
||||
have been removed in favor of using Ansible's wait_for_connection module,
|
||||
which will not rely on SSH to the container to verify connectivity. A new
|
||||
variable called ``lxc_container_wait_params`` has been added to allow
|
||||
configuration of the parameters passed to the ``wait_for_connection``
|
||||
module.
|
||||
deprecations:
|
||||
- The var ``lxc_container_ssh_delay`` along with SSH specific ping checks
|
||||
have been removed in favor of using Ansible's wait_for_connection module,
|
||||
which will not rely on SSH to the container.
|
|
@ -404,16 +404,12 @@
|
|||
# Flush the handlers to ensure the container and networking is online.
|
||||
- meta: flush_handlers
|
||||
|
||||
- name: Wait for ssh to be available
|
||||
wait_for:
|
||||
port: "{{ ansible_port | default('22') }}"
|
||||
host: "{{ ansible_host | default(inventory_hostname) }}"
|
||||
search_regex: OpenSSH
|
||||
delay: "{{ lxc_container_ssh_delay }}"
|
||||
register: ssh_wait_check
|
||||
until: ssh_wait_check | success
|
||||
retries: 3
|
||||
delegate_to: "{{ physical_host }}"
|
||||
- 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) }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
|
|
Loading…
Reference in New Issue