diff --git a/roles/debian/ldap_server/meta/main.yml b/roles/debian/ldap_server/meta/main.yml deleted file mode 100644 index 551567003..000000000 --- a/roles/debian/ldap_server/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - role: debian/python_common diff --git a/roles/debian/ldap_server/tasks/main.yml b/roles/debian/ldap_server/tasks/main.yml index 9a773da58..bf2c0d3d1 100644 --- a/roles/debian/ldap_server/tasks/main.yml +++ b/roles/debian/ldap_server/tasks/main.yml @@ -14,6 +14,19 @@ purge: true when: ldap_server.slapd.purge +- name: Set up Python packages. + ansible.builtin.include_role: + name: debian/python_common + vars: + python_common: + remove_packages: + - python-pip + - python3-yaml + - python-botocore + - python-urllib3 + install_packages: + - python3-pip + - name: Ensure LDAP and python-ldap and dependencies are installed. ansible.builtin.apt: pkg: ["slapd", "ldapscripts", "libldap2-dev"] diff --git a/roles/debian/mysql_client/meta/main.yml b/roles/debian/mysql_client/meta/main.yml deleted file mode 100644 index 551567003..000000000 --- a/roles/debian/mysql_client/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - role: debian/python_common diff --git a/roles/debian/mysql_client/tasks/main.yml b/roles/debian/mysql_client/tasks/main.yml index d17123205..2ecca067e 100644 --- a/roles/debian/mysql_client/tasks/main.yml +++ b/roles/debian/mysql_client/tasks/main.yml @@ -6,6 +6,19 @@ update_cache: true cache_valid_time: 240 +- name: Set up Python packages. + ansible.builtin.include_role: + name: debian/python_common + vars: + python_common: + remove_packages: + - python-pip + - python3-yaml + - python-botocore + - python-urllib3 + install_packages: + - python3-pip + - name: Ensure PyMySQL is installed with pip3. ansible.builtin.pip: name: pymysql diff --git a/roles/debian/nginx/meta/main.yml b/roles/debian/nginx/meta/main.yml deleted file mode 100644 index 551567003..000000000 --- a/roles/debian/nginx/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - role: debian/python_common diff --git a/roles/debian/nginx/tasks/main.yml b/roles/debian/nginx/tasks/main.yml index 60a8c4246..0388ed007 100644 --- a/roles/debian/nginx/tasks/main.yml +++ b/roles/debian/nginx/tasks/main.yml @@ -6,6 +6,19 @@ update_cache: true cache_valid_time: 240 +- name: Set up Python packages. + ansible.builtin.include_role: + name: debian/python_common + vars: + python_common: + remove_packages: + - python-pip + - python3-yaml + - python-botocore + - python-urllib3 + install_packages: + - python3-pip + - name: Ensure passlib is installed with pip3. ansible.builtin.pip: name: passlib diff --git a/roles/debian/python_common/defaults/main.yml b/roles/debian/python_common/defaults/main.yml index afb3840df..59c3c7e72 100644 --- a/roles/debian/python_common/defaults/main.yml +++ b/roles/debian/python_common/defaults/main.yml @@ -8,5 +8,4 @@ python_common: install_packages: - python3-distutils - python3-venv - - python3-pip - cloud-init # package can get removed with python3-yaml but we need it for auto-scale \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index a1aae6923..da5277ef9 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,6 +12,7 @@ TARGET_PROVISION_BRANCH="" ANSIBLE_EXTRA_VARS="" ANSIBLE_DEFAULT_EXTRA_VARS="" ANSIBLE_PATH="" +PYTHON_INTERPRETER="" BUILD_WORKSPACE="" BUILD_WORKSPACE_BASE="$OWN_DIR/build" BUILD_ID="" @@ -101,6 +102,10 @@ parse_options(){ shift ANSIBLE_PATH="$1" ;; + "--python-interpreter") + shift + PYTHON_INTERPRETER="$1" + ;; *) usage exit 1 @@ -123,7 +128,11 @@ get_build_workspace(){ # Common extra-vars to pass to Ansible. get_ansible_defaults_vars(){ get_build_id - ANSIBLE_DEFAULT_EXTRA_VARS="{_ce_provision_base_dir: $OWN_DIR, _ce_provision_build_dir: $BUILD_WORKSPACE, _ce_provision_build_tmp_dir: $BUILD_TMP_DIR, _ce_provision_data_dir: $ANSIBLE_DATA_DIR, _ce_provision_build_id: $BUILD_ID, _ce_provision_force_play: $FORCE_PLAY, target_branch: $TARGET_PROVISION_BRANCH}" + if [ -n "$PYTHON_INTERPRETER" ]; then + ANSIBLE_DEFAULT_EXTRA_VARS="{ansible_python_interpreter: $PYTHON_INTERPRETER, _ce_provision_base_dir: $OWN_DIR, _ce_provision_build_dir: $BUILD_WORKSPACE, _ce_provision_build_tmp_dir: $BUILD_TMP_DIR, _ce_provision_data_dir: $ANSIBLE_DATA_DIR, _ce_provision_build_id: $BUILD_ID, _ce_provision_force_play: $FORCE_PLAY, target_branch: $TARGET_PROVISION_BRANCH}" + else + ANSIBLE_DEFAULT_EXTRA_VARS="{_ce_provision_base_dir: $OWN_DIR, _ce_provision_build_dir: $BUILD_WORKSPACE, _ce_provision_build_tmp_dir: $BUILD_TMP_DIR, _ce_provision_data_dir: $ANSIBLE_DATA_DIR, _ce_provision_build_id: $BUILD_ID, _ce_provision_force_play: $FORCE_PLAY, target_branch: $TARGET_PROVISION_BRANCH}" + fi } # Clone our target repo. diff --git a/scripts/provision.sh b/scripts/provision.sh index 92d2e0265..fda465e05 100755 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -14,6 +14,7 @@ usage(){ echo 'Available options:' echo '--ansible-extra-vars: Variable to pass as --extra-vars arguments to ansible-playbook. Make sure to escape them properly.' echo '--ansible-path: Pass the path to the directory containing the Ansible binaries if you are not using the version of Ansible in PATH.' + echo '--python-interpreter: When using Python virtual environments Ansible may not correctly determine the Python interpreter, use this to set it manually.' echo '--workspace: Local existing clone of the repo/branch (if your deployment tool already has one). This will skip the cloning/fetching of the repo.' echo '--user: Linux user executing the script (defaults to controller).' echo '--absolute-playbook-path: Prevent prepending of the workspace path to the playbook path when Ansible is called.'