diff --git a/connection/ssh.py b/connection/ssh.py index e822cff5..41d36c6a 100644 --- a/connection/ssh.py +++ b/connection/ssh.py @@ -26,7 +26,6 @@ DOCUMENTATION = ''' description: Hostname of a container vars: - name: container_name - - name: inventory_hostname container_tech: description: Container technology used by a container host default: lxc @@ -371,11 +370,9 @@ class Connection(SSH.Connection): super(Connection, self).set_options(task_keys=None, var_options=var_options, direct=direct) self.chroot_path = self.get_option('chroot_path') - if var_options and \ - self.get_option('container_name') == var_options.get('inventory_hostname'): - self.container_name = self.get_option('container_name') - self.physical_host = self.get_option('physical_host') + self.container_name = self.get_option('container_name') self.container_tech = self.get_option('container_tech') + self.physical_host = self.get_option('physical_host') # Check to see if container_user is setup first, if so use that value. # If it isn't, then default to 'root' @@ -389,7 +386,10 @@ class Connection(SSH.Connection): if self._container_check() or self._chroot_check(): physical_host_addrs = self.get_option('physical_host_addrs') or {} - self._set_physical_host_addr(physical_host_addrs) + if self.host in physical_host_addrs.values(): + self.container_name = None + else: + self._set_physical_host_addr(physical_host_addrs) def _set_physical_host_addr(self, physical_host_addrs): physical_host_addr = physical_host_addrs.get(self.physical_host, diff --git a/releasenotes/notes/plugins-container-user-remote-tmp-0efec059fd04eae2.yaml b/releasenotes/notes/plugins-container-user-remote-tmp-0efec059fd04eae2.yaml new file mode 100644 index 00000000..cc38495a --- /dev/null +++ b/releasenotes/notes/plugins-container-user-remote-tmp-0efec059fd04eae2.yaml @@ -0,0 +1,6 @@ +--- +issues: + - | + When using the connection plugin's ``container_user`` option, + ``ansible_remote_tmp`` should be set to a system writable path + such as '/var/tmp/'. diff --git a/strategy/linear.py b/strategy/linear.py index f2b6b88f..0da4e285 100644 --- a/strategy/linear.py +++ b/strategy/linear.py @@ -139,6 +139,7 @@ class StrategyModule(LINEAR.StrategyModule): # This checks if we are delegating to a host which does not exist # in the inventory (possibly using its IP address) if delegated_host_info is None: + task_vars['container_name'] = None continue physical_host_vars = delegated_host_info.get_vars() physical_host_templar = LINEAR.Templar(loader=self._loader, diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml index c385c153..968fe485 100644 --- a/tests/group_vars/all_containers.yml +++ b/tests/group_vars/all_containers.yml @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -container_name: "{{ inventory_hostname }}" - container_networks: management_address: address: "{{ ansible_host }}" diff --git a/tests/inventory b/tests/inventory index 5f58281f..ac8ec7e7 100644 --- a/tests/inventory +++ b/tests/inventory @@ -2,14 +2,14 @@ localhost [all_containers] -container1 -container2 +container1 container_name=container1 ansible_remote_tmp=/var/tmp +container2 container_name=container2 # This is used to test I75f9d0f55ecd875caa1bf608a77c92f950b679a1 [hosts] localhost_alt [all_containers] -container3 +container3 container_name=container3 # This is meant to test If594914df53efacc6d5bba148f4f46280f5a117d [fake_hosts] @@ -17,4 +17,4 @@ fakehost ansible_host=1.1.1.1 [hosts:children] fake_hosts [fake_containers] -fakecontainer container_name="{{ inventory_hostname }}" physical_host=fakehost +fakecontainer container_name=fakecontainer physical_host=fakehost