Merge "Add option to set python interpreter for ansible"
This commit is contained in:
commit
02df7f7288
@ -1279,6 +1279,9 @@ function configure_ironic_conductor {
|
|||||||
# we definitely know the default username to use for TinyIPA image
|
# we definitely know the default username to use for TinyIPA image
|
||||||
IRONIC_ANSIBLE_SSH_USER='tc'
|
IRONIC_ANSIBLE_SSH_USER='tc'
|
||||||
fi
|
fi
|
||||||
|
# (rpittau) most recent tinyipa uses python3 natively so we need to change
|
||||||
|
# the default ansible python interpreter.
|
||||||
|
iniset $IRONIC_CONF_FILE ansible default_python_interpreter /usr/bin/python3
|
||||||
fi
|
fi
|
||||||
iniset $IRONIC_CONF_FILE ansible default_key_file $IRONIC_ANSIBLE_SSH_KEY
|
iniset $IRONIC_CONF_FILE ansible default_key_file $IRONIC_ANSIBLE_SSH_KEY
|
||||||
if [[ -n $IRONIC_ANSIBLE_SSH_USER ]]; then
|
if [[ -n $IRONIC_ANSIBLE_SSH_USER ]]; then
|
||||||
|
@ -134,6 +134,10 @@ opts = [
|
|||||||
"It may be overridden by per-node "
|
"It may be overridden by per-node "
|
||||||
"'ansible_clean_steps_config' option in node's "
|
"'ansible_clean_steps_config' option in node's "
|
||||||
"'driver_info' field.")),
|
"'driver_info' field.")),
|
||||||
|
cfg.StrOpt('default_python_interpreter',
|
||||||
|
help=_("Absolute path to the python interpreter on the "
|
||||||
|
"managed machines. By default, ansible uses "
|
||||||
|
"/usr/bin/python")),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,6 +126,9 @@ def _run_playbook(node, name, extra_vars, key, tags=None, notags=None):
|
|||||||
playbook = os.path.join(root, name)
|
playbook = os.path.join(root, name)
|
||||||
inventory = os.path.join(root, 'inventory')
|
inventory = os.path.join(root, 'inventory')
|
||||||
ironic_vars = {'ironic': extra_vars}
|
ironic_vars = {'ironic': extra_vars}
|
||||||
|
if CONF.ansible.default_python_interpreter:
|
||||||
|
ironic_vars['ansible_python_interpreter'] = (
|
||||||
|
CONF.ansible.default_python_interpreter)
|
||||||
args = [CONF.ansible.ansible_playbook_script, playbook,
|
args = [CONF.ansible.ansible_playbook_script, playbook,
|
||||||
'-i', inventory,
|
'-i', inventory,
|
||||||
'-e', json.dumps(ironic_vars),
|
'-e', json.dumps(ironic_vars),
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from ironic_lib import utils as irlib_utils
|
from ironic_lib import utils as irlib_utils
|
||||||
import mock
|
import mock
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
@ -162,6 +164,33 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
|
|||||||
'/path/to/playbooks/inventory', '-e', '{"ironic": {"foo": "bar"}}',
|
'/path/to/playbooks/inventory', '-e', '{"ironic": {"foo": "bar"}}',
|
||||||
'--private-key=/path/to/key', '-vvvv')
|
'--private-key=/path/to/key', '-vvvv')
|
||||||
|
|
||||||
|
@mock.patch.object(com_utils, 'execute', return_value=('out', 'err'),
|
||||||
|
autospec=True)
|
||||||
|
def test__run_playbook_ansible_interpreter_python3(self, execute_mock):
|
||||||
|
self.config(group='ansible', playbooks_path='/path/to/playbooks')
|
||||||
|
self.config(group='ansible', config_file_path='/path/to/config')
|
||||||
|
self.config(group='ansible', verbosity=3)
|
||||||
|
self.config(group='ansible',
|
||||||
|
default_python_interpreter='/usr/bin/python3')
|
||||||
|
self.config(group='ansible', ansible_extra_args='--timeout=100')
|
||||||
|
extra_vars = {'foo': 'bar'}
|
||||||
|
|
||||||
|
ansible_deploy._run_playbook(self.node, 'deploy',
|
||||||
|
extra_vars, '/path/to/key',
|
||||||
|
tags=['spam'], notags=['ham'])
|
||||||
|
|
||||||
|
execute_mock.assert_called_once_with(
|
||||||
|
'env', 'ANSIBLE_CONFIG=/path/to/config',
|
||||||
|
'ansible-playbook', '/path/to/playbooks/deploy', '-i',
|
||||||
|
'/path/to/playbooks/inventory', '-e',
|
||||||
|
mock.ANY, '--tags=spam', '--skip-tags=ham',
|
||||||
|
'--private-key=/path/to/key', '-vvv', '--timeout=100')
|
||||||
|
|
||||||
|
all_vars = execute_mock.call_args[0][7]
|
||||||
|
self.assertEqual({"ansible_python_interpreter": "/usr/bin/python3",
|
||||||
|
"ironic": {"foo": "bar"}},
|
||||||
|
json.loads(all_vars))
|
||||||
|
|
||||||
@mock.patch.object(com_utils, 'execute',
|
@mock.patch.object(com_utils, 'execute',
|
||||||
side_effect=processutils.ProcessExecutionError(
|
side_effect=processutils.ProcessExecutionError(
|
||||||
description='VIKINGS!'),
|
description='VIKINGS!'),
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Adds option ``[ansible]default_python_interpreter`` to choose
|
||||||
|
the python interpreter that ansible uses on managed machines.
|
||||||
|
By default, ansible uses ``/usr/bin/python`` as interpreter, making the
|
||||||
|
assumption that that path is always present on remote managed systems.
|
||||||
|
This might not be always the case, for example in custom build
|
||||||
|
images or Python 3 native distributions.
|
||||||
|
With this option the operator has the ability to set the absolute
|
||||||
|
path of the python interpreter on the remote machines, for example
|
||||||
|
``/usr/bin/python3``.
|
||||||
|
The same interpreter will be used in all operations that use the
|
||||||
|
ansible deploy interface.
|
@ -11,10 +11,7 @@
|
|||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- ironic-tox-unit-with-driver-libs
|
- ironic-tox-unit-with-driver-libs
|
||||||
# making ironic-standalone non voting until we can run ansible
|
- ironic-standalone
|
||||||
# with python3 interpreter on remote machines
|
|
||||||
- ironic-standalone:
|
|
||||||
voting: false
|
|
||||||
- ironic-tempest-functional-python2
|
- ironic-tempest-functional-python2
|
||||||
- ironic-tempest-functional-python3
|
- ironic-tempest-functional-python3
|
||||||
- ironic-grenade-dsvm
|
- ironic-grenade-dsvm
|
||||||
@ -40,9 +37,7 @@
|
|||||||
queue: ironic
|
queue: ironic
|
||||||
jobs:
|
jobs:
|
||||||
- ironic-tox-unit-with-driver-libs
|
- ironic-tox-unit-with-driver-libs
|
||||||
# removing ironic-standalone from gate until we can run ansible
|
- ironic-standalone
|
||||||
# with python3 interpreter on remote machines
|
|
||||||
# - ironic-standalone
|
|
||||||
- ironic-tempest-functional-python2
|
- ironic-tempest-functional-python2
|
||||||
- ironic-tempest-functional-python3
|
- ironic-tempest-functional-python3
|
||||||
- ironic-grenade-dsvm
|
- ironic-grenade-dsvm
|
||||||
|
Loading…
Reference in New Issue
Block a user