Add advanced deployment options
In order to be able to specify the ansible python interpreter, we need to be able to pass in some extra options into the deployment workflow. This change adds support for ansible_python_interpreter to the inventory code as well as exposing a deployment_options input to the deployment workflow. Change-Id: Ieed77f5fe886ef38f447bfa647c8e01009f93d89 Related-Blueprint: python3-support
This commit is contained in:
parent
b8bfff895b
commit
d610129d8f
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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': {
|
||||
|
@ -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') %>
|
||||
|
Loading…
Reference in New Issue
Block a user