Use ansible-runtime python for internal scripts

The ansible runtime python needs to be used when running local scripts
so that our libs cared for. Presently when the pw-token-gen script is
run it stacktraces on a new 16.04 host when py3.5 and py2.7 are present
on the same host. The traceback indicates that the Crypto lib is missing
which is true for py2.7 as we now prefer py3.5.

Additionally the pw-token-gen script needs two updates to be py3.5
compatible.

Change-Id: I5535c2076ebb3fa5b2a5d5fc42bdc5095871c7d5
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2017-08-01 11:35:09 -05:00
parent c4b73e5395
commit b3cd95f219
No known key found for this signature in database
GPG Key ID: 69FEFFC5E2D9273F
3 changed files with 4 additions and 4 deletions

View File

@ -166,7 +166,7 @@ def main():
changed = False
generator = CredentialGenerator()
for entry, value in user_vars.iteritems():
for entry, value in user_vars.items():
if value is None or all_args['regen'] is True:
if entry.endswith('password') or entry.endswith('secret'):
changed = True
@ -198,7 +198,7 @@ def main():
backup_name = '%s-%s' % (basename, utctime)
tar.add(user_vars_file, arcname=backup_name)
with open(user_vars_file, 'wb') as f:
with open(user_vars_file, 'w') as f:
os.chmod(user_vars_file, 0o600)
f.write(
yaml.safe_dump(

View File

@ -40,7 +40,7 @@
with_items: "{{ secrets.stdout_lines }}"
when: user_secrets.stdout.find("{{ item }}") == -1
- name: Generate new secrets
shell: "{{ playbook_dir }}/../../../scripts/pw-token-gen.py --file /etc/openstack_deploy/{{ _osa_secrets_file_name }}"
shell: "/opt/ansible-runtime/bin/python {{ playbook_dir }}/../../../scripts/pw-token-gen.py --file /etc/openstack_deploy/{{ _osa_secrets_file_name }}"
vars:
_osa_secrets_file_name: "{{ osa_secrets_file_name | default('user_secrets.yml') }}"
ansible_python_interpreter: "/usr/bin/python"

View File

@ -53,7 +53,7 @@
- deploy-user-secrets
- name: Generate any missing values in user_secrets
command: "{{ bootstrap_host_aio_script_path }}/pw-token-gen.py --file /etc/openstack_deploy/{{ bootstrap_host_user_secrets_filename }}"
command: "/opt/ansible-runtime/bin/python {{ bootstrap_host_aio_script_path }}/pw-token-gen.py --file /etc/openstack_deploy/{{ bootstrap_host_user_secrets_filename }}"
changed_when: false
tags:
- generate_secrets