From 8bed623571d8bc1695ac22a896e9efac2727f40d Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 20 Apr 2020 15:36:22 +0100 Subject: [PATCH] Fix passwords.yml generation with vault encryption on Python 3 Kayobe generates passwords.yml for Kolla Ansible, and can encrypt it using the vault password. Previously this was failing on Python 3 due to passing a string to file.write() which expects bytes. This change fixes the issue by encoding the password string passed to file.write(). This allows us to run the ansible role tests under Python 3. Change-Id: I33813f79984a46f1967ef3aee455dcfbe7eb93da Story: 2006574 Task: 39481 --- ansible/roles/kolla-ansible/library/kolla_passwords.py | 2 +- tox.ini | 4 ---- zuul.d/jobs.yaml | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/ansible/roles/kolla-ansible/library/kolla_passwords.py b/ansible/roles/kolla-ansible/library/kolla_passwords.py index d7bc6314c..9b3a215b3 100644 --- a/ansible/roles/kolla-ansible/library/kolla_passwords.py +++ b/ansible/roles/kolla-ansible/library/kolla_passwords.py @@ -57,7 +57,7 @@ def kolla_mergepwd(module, old_path, new_path, final_path): def create_vault_password_file(module): """Create a vault password file.""" with tempfile.NamedTemporaryFile(delete=False) as f: - f.write(module.params['vault_password']) + f.write(module.params['vault_password'].encode()) return f.name diff --git a/tox.ini b/tox.ini index 3d7cfb974..a8519acfa 100644 --- a/tox.ini +++ b/tox.ini @@ -49,10 +49,6 @@ deps = commands = {posargs} [testenv:ansible] -# FIXME(mgoddard): Ansible playbooks do not yet support Python 3, so we need to run these -# tests using Python 2 for the time being. -basepython = python2 -usedevelop = True # Create the virtualenv with access to system site packages, as this is # required to use the python and apt modules, which are not available via PyPI. sitepackages = True diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 3a07b58ee..c08103944 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -21,8 +21,6 @@ tox_envlist: ansible required-projects: - name: openstack/requirements - # TODO(mgoddard): Remove when Ansible playbooks support Python 3. - override-checkout: stable/train irrelevant-files: - ^.*\.rst$ - ^doc/.*