connection: ssh: Clear environment when connecting to LXC containers
We should clear the environment before connecting to an LXC container to avoid inheriting host variables that may break container services like the following failure in rabbitmqctl: TASK [Get status of rabbitmq] ************************************************************************************************************************************************************************************* fatal: [container1]: FAILED! => {"changed": true, "cmd": ["rabbitmqctl", "status"], "delta": "0:00:00.705116", "end": "2017-06-06 20:03:13.771796", "failed": true, "rc": 69, "start": "2017-06-06 20:03:13.066680", "stderr": "Error: unable to connect to node 'rabbit@vagrant-openSUSE-Leap': nodedown\n\nDIAGNOSTICS\n===========\n\nattempted to contact: ['rabbit@vagrant-openSUSE-Leap']\n\nrabbit@vagrant-openSUSE-Leap:\n * unable to connect to epmd (port 4369) on vagrant-openSUSE-Leap: address (cannot connect to host/port)\n\n\ncurrent node details:\n- node name: 'rabbitmq-cli-82@localhost'\n- home dir: /var/lib/rabbitmq\n- cookie hash: NqWRA5RzO5daz4Jb5LJsXg==", "stderr_lines": ["Error: unable to connect to node 'rabbit@vagrant-openSUSE-Leap': nodedown", "", "DIAGNOSTICS", "===========", "", "attempted to contact: ['rabbit@vagrant-openSUSE-Leap']", "", "rabbit@vagrant-openSUSE-Leap:", " * unable to connect to epmd (port 4369) on vagrant-openSUSE-Leap: address (cannot connect to host/port)", "", "", "current node details:", "- node name: 'rabbitmq-cli-82@localhost'", "- home dir: /var/lib/rabbitmq", "- cookie hash: NqWRA5RzO5daz4Jb5LJsXg=="], "stdout": "Status of node 'rabbit@vagrant-openSUSE-Leap' ...", "stdout_lines": ["Status of node 'rabbit@vagrant-openSUSE-Leap' ..."]} to retry, use: --limit @/vagrant/tests/test-rabbitmq-server-functional.retry The reason for this failure is that the HOSTNAME variable is being inherited by the host (vagrant-openSUSE-Leap) and the rabbitmqctl command uses this variable to guess the host it should try to connect to. This is similar to what the upstream lxc connection module is doing. Link: https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/connection/lxc.py#L121 Change-Id: Ic3b8bf9a9aaf8738c49490e22fec2fc0b5140ac0
This commit is contained in:
parent
36ff6fb6da
commit
c2c71bc2b0
|
@ -65,7 +65,7 @@ class Connection(SSH.Connection):
|
|||
"""run a command on the remote host."""
|
||||
|
||||
if self._container_check():
|
||||
lxc_command = 'lxc-attach --name %s' % self.container_name
|
||||
lxc_command = 'lxc-attach --clear-env --name %s' % self.container_name
|
||||
cmd = '%s -- %s' % (lxc_command, cmd)
|
||||
|
||||
if self._chroot_check():
|
||||
|
|
Loading…
Reference in New Issue