From 2a90bea311387ccdc542283c600cfd649e83edf4 Mon Sep 17 00:00:00 2001 From: Pavel Eremeev Date: Thu, 12 Jul 2018 00:06:26 +0100 Subject: [PATCH] Several kubectl fixes (#40882) * Fixed typo * Fixed namespace parameter and tmp dir --- lib/ansible/module_utils/k8s/inventory.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/k8s/inventory.py b/lib/ansible/module_utils/k8s/inventory.py index d8cf8b6654..8cd954d020 100644 --- a/lib/ansible/module_utils/k8s/inventory.py +++ b/lib/ansible/module_utils/k8s/inventory.py @@ -70,7 +70,7 @@ class K8sInventoryHelper(K8sAnsibleMixin): client = self.get_api_client(**connection) name = connection.get('name', self.get_default_host_name(client.configuration.host)) if connection.get('namespaces'): - namespaces = connections['namespaces'] + namespaces = connection['namespaces'] else: namespaces = self.get_available_namespaces(client) for namespace in namespaces: @@ -157,11 +157,14 @@ class K8sInventoryHelper(K8sAnsibleMixin): if container.state.waiting: self.inventory.set_variable(container_name, 'container_state', 'Waiting') self.inventory.set_variable(container_name, 'container_ready', container.ready) + self.inventory.set_variable(container_name, 'ansible_remote_tmp', '/tmp/') self.inventory.set_variable(container_name, 'ansible_connection', self.transport) self.inventory.set_variable(container_name, 'ansible_{0}_pod'.format(self.transport), pod_name) self.inventory.set_variable(container_name, 'ansible_{0}_container'.format(self.transport), container.name) + self.inventory.set_variable(container_name, 'ansible_{0}_namespace'.format(self.transport), + namespace) def get_services_for_namespace(self, client, name, namespace): v1_service = client.resources.get(api_version='v1', kind='Service')