From d021c51c48cbdc302e44da9673f14e68812aa26f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Wed, 11 Jul 2018 19:20:28 +0200 Subject: [PATCH] Ensure __pycache__ folder is deleted In some cases when running python3, the cleanup of the virtualenv is incomplete: While the *.pyc files are removed, the python3 __pycache__ folder is not removed. That causes the sed instruction (applying to files) to fail, as the __pycache__ folder is not a regular file, but a folder. With the sed not successfully running, the shebang of the virtualenv is pointing to an incorrect location, causing then a failure in keystone-manage commands. On top of it, a success would happen should the last command return 0. We now make sure the whole script must return success. This should fix the problem. Change-Id: I2999f9253e8bb70854e02768aef13f3b57839987 --- tasks/heat_install_source.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/heat_install_source.yml b/tasks/heat_install_source.yml index ad7a9cf..baac906 100644 --- a/tasks/heat_install_source.yml +++ b/tasks/heat_install_source.yml @@ -93,7 +93,9 @@ # to https://github.com/pypa/virtualenv/issues/565 - name: Update virtualenv path shell: | + set -o errexit find {{ heat_bin }} -name \*.pyc -delete + if test -d {{ heat_bin }}/__pycache__; then rmdir {{ heat_bin }}/__pycache__; fi sed -si '1s/^.*python.*$/#!{{ heat_bin | replace ('/','\/') }}\/python/' {{ heat_bin }}/* virtualenv {{ heat_bin | dirname }} \ {{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \