diff --git a/tripleo_common/actions/ansible.py b/tripleo_common/actions/ansible.py index 47aa93224..53540f0ff 100644 --- a/tripleo_common/actions/ansible.py +++ b/tripleo_common/actions/ansible.py @@ -601,6 +601,8 @@ class AnsibleGenerateInventoryAction(base.TripleOAction): self._kwargs_for_run = kwargs self.ansible_ssh_user = self._kwargs_for_run.pop( 'ansible_ssh_user', 'tripleo-admin') + self.ansible_python_interpreter = self._kwargs_for_run.pop( + 'ansible_python_interpreter', None) self._work_dir = self._kwargs_for_run.pop( 'work_dir', None) self.plan_name = self._kwargs_for_run.pop( @@ -628,6 +630,7 @@ class AnsibleGenerateInventoryAction(base.TripleOAction): project_name=context.security.project_name, username=context.security.user_name, ansible_ssh_user=self.ansible_ssh_user, + ansible_python_interpreter=self.ansible_python_interpreter, plan_name=self.plan_name, host_network=self.ssh_network) diff --git a/tripleo_common/inventory.py b/tripleo_common/inventory.py index c92fa1d68..b97762937 100644 --- a/tripleo_common/inventory.py +++ b/tripleo_common/inventory.py @@ -86,7 +86,7 @@ class TripleoInventory(object): def __init__(self, configs=None, session=None, hclient=None, plan_name=None, auth_url=None, project_name=None, cacert=None, username=None, ansible_ssh_user=None, - host_network=None): + host_network=None, ansible_python_interpreter=None): self.session = session self.hclient = hclient self.hosts_format_dict = False @@ -100,6 +100,8 @@ class TripleoInventory(object): self.username = configs.username self.ansible_ssh_user = configs.ansible_ssh_user self.plan_name = configs.plan + self.ansible_python_interpreter = \ + configs.ansible_python_interpreter else: self.auth_url = auth_url self.cacert = cacert @@ -107,6 +109,7 @@ class TripleoInventory(object): self.username = username self.ansible_ssh_user = ansible_ssh_user self.plan_name = plan_name + self.ansible_python_interpreter = ansible_python_interpreter self.stack_outputs = StackOutputs(self.plan_name, self.hclient) self.hostvars = {} @@ -248,6 +251,10 @@ class TripleoInventory(object): } + if self.ansible_python_interpreter: + ret[role]['vars']['ansible_python_interpreter'] = \ + self.ansible_python_interpreter + self.hostvars.update(hosts) if children: @@ -273,6 +280,9 @@ class TripleoInventory(object): 'ansible_ssh_user': self.ansible_ssh_user } } + if self.ansible_python_interpreter: + ret[role]['vars']['ansible_python_interpreter'] = \ + self.ansible_python_interpreter if not self.hosts_format_dict: # Prevent Ansible from repeatedly calling us to get empty host diff --git a/tripleo_common/tests/test_inventory.py b/tripleo_common/tests/test_inventory.py index c673ad018..2faa80de2 100644 --- a/tripleo_common/tests/test_inventory.py +++ b/tripleo_common/tests/test_inventory.py @@ -181,6 +181,7 @@ class TestInventory(base.TestCase): configs.project_name = 'admin' configs.username = 'admin' configs.ansible_ssh_user = 'heat-admin' + configs.ansible_python_interpreter = None inventory = TripleoInventory( configs, self.session, self.hclient) self._inventory_list(inventory) @@ -253,24 +254,28 @@ class TestInventory(base.TestCase): project_name='admin', username='admin', cacert='acacert', - ansible_ssh_user=ansible_ssh_user) + ansible_ssh_user=ansible_ssh_user, + ansible_python_interpreter='foo') self.inventory.stack_outputs = self.outputs expected = { 'Compute': { 'hosts': ['cp-0'], - 'vars': {'ansible_ssh_user': ansible_ssh_user, + 'vars': {'ansible_python_interpreter': 'foo', + 'ansible_ssh_user': ansible_ssh_user, 'bootstrap_server_id': 'a', 'tripleo_role_name': 'Compute'}}, 'Controller': { 'hosts': ['c-0', 'c-1', 'c-2'], - 'vars': {'ansible_ssh_user': ansible_ssh_user, + 'vars': {'ansible_python_interpreter': 'foo', + 'ansible_ssh_user': ansible_ssh_user, 'bootstrap_server_id': 'a', 'tripleo_role_name': 'Controller'}}, 'CustomRole': { 'hosts': ['cs-0'], - 'vars': {'ansible_ssh_user': ansible_ssh_user, + 'vars': {'ansible_python_interpreter': 'foo', + 'ansible_ssh_user': ansible_ssh_user, 'bootstrap_server_id': 'a', 'tripleo_role_name': 'CustomRole'}}, 'overcloud': { diff --git a/workbooks/deployment.yaml b/workbooks/deployment.yaml index 2902cf0be..1ce2bedea 100644 --- a/workbooks/deployment.yaml +++ b/workbooks/deployment.yaml @@ -126,6 +126,7 @@ workflows: - queue_name: tripleo - config_download: False - ssh_network: ctlplane + - deployment_options: {} tags: - tripleo-common-managed @@ -457,6 +458,7 @@ workflows: action: tripleo.ansible-generate-inventory input: ansible_ssh_user: tripleo-admin + ansible_python_interpreter: <% $.get('deployment_options', {}).get('ansible_python_interpreter', null) %> work_dir: <% $.get('work_dir') %>/<% $.get('plan_name') %> plan_name: <% $.get('plan_name') %> ssh_network: <% $.get('ssh_network') %>