diff --git a/bin/conda_utils.sh b/bin/conda_utils.sh index dc36b9de6..91212a9ae 100644 --- a/bin/conda_utils.sh +++ b/bin/conda_utils.sh @@ -21,6 +21,8 @@ miniconda_installer="${miniconda_install_root}/miniconda_installer.sh" miniconda_installer_url="https://repo.anaconda.com/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh" miniconda_checksum="634d76df5e489c44ade4085552b97bebc786d49245ed1a830022b0b406de5817" packages_download_root="${miniconda_install_root}/aurora_host_packages" +shadow_conda_ws_dir="${miniconda_install_location}/envs/${conda_ws_name}" +aurora_python_version="3.8" # Some molecule tests install to `/home/...` (no user account) if [ -z $USER ]; then @@ -68,7 +70,7 @@ _fetch_new_files() { echo "Fetching ${aws_bucket_dir}..." mkdir -p $local_download_dir - remote_packages=$(curl -Ls ${aws_bucket_url} | xq | grep $aws_bucket_dir | grep 'Key' | sed -r "s/.*${aws_bucket_dir}\///g" | sed -r 's/",//g' | sed -r 's;;;g') + remote_packages=$(curl -Ls ${aws_bucket_url} | python -m xq | grep $aws_bucket_dir | grep 'Key' | sed -r "s/.*${aws_bucket_dir}\///g" | sed -r 's/",//g' | sed -r 's;;;g') echo "remote_packages: ${remote_packages}" @@ -116,14 +118,14 @@ create_conda_ws(){ if [ -d "$shadow_conda_ws_dir" ]; then rm -rf $shadow_conda_ws_dir fi - ${miniconda_install_location}/bin/conda create -y -n ${conda_ws_name} python=3.8 && source ${miniconda_install_location}/bin/activate ${conda_ws_name} - python -m pip install yq xq + ${miniconda_install_location}/bin/conda create -y -n ${conda_ws_name} python=${aurora_python_version} && source ${miniconda_install_location}/bin/activate ${conda_ws_name} + ${shadow_conda_ws_dir}/bin/pip install yq xq } fetch_pip_files(){ _fetch_new_files "http://shadowrobot.aurora-host-packages-${codename}.s3.eu-west-2.amazonaws.com" "pip_packages"; } fetch_ansible_files() { _fetch_new_files "http://shadowrobot.aurora-host-packages-${codename}.s3.eu-west-2.amazonaws.com" "ansible_collections"; } -install_pip_packages() { ANSIBLE_SKIP_CONFLICT_CHECK=1 python -m pip install ${packages_download_root}/pip_packages/* ; } +install_pip_packages() { ANSIBLE_SKIP_CONFLICT_CHECK=1 ${shadow_conda_ws_dir}/bin/pip install ${packages_download_root}/pip_packages/* ; } install_ansible_collections() { ansible_galaxy_executable=$1 "${ansible_galaxy_executable}" collection install $(realpath ${packages_download_root}/ansible_collections/*) diff --git a/bin/run-ansible.sh b/bin/run-ansible.sh index 0f3d5068f..4c95dc4f9 100755 --- a/bin/run-ansible.sh +++ b/bin/run-ansible.sh @@ -421,24 +421,32 @@ else echo "" fi -ansible_executable=~/.local/bin/ansible-playbook -if [[ ! -f "${ansible_executable}" ]]; then +# Awful hack to make bionic checks pass (they need to be disabled) +if [[ $codename == *"bionic"* ]]; then + ansible_executable=~/.local/bin/ansible-playbook + if [[ ! -f "${ansible_executable}" ]]; then + ansible_executable=ansible-playbook + fi + ansible_basic_executable=~/.local/bin/ansible + if [[ ! -f "${ansible_basic_executable}" ]]; then + ansible_basic_executable=ansible + fi + ansible_galaxy_executable=~/.local/bin/ansible-galaxy + if [[ ! -f "${ansible_galaxy_executable}" ]]; then + ansible_galaxy_executable=ansible-galaxy + fi + else ansible_executable=ansible-playbook -fi -ansible_basic_executable=~/.local/bin/ansible -if [[ ! -f "${ansible_basic_executable}" ]]; then ansible_basic_executable=ansible -fi -ansible_galaxy_executable=~/.local/bin/ansible-galaxy -if [[ ! -f "${ansible_galaxy_executable}" ]]; then ansible_galaxy_executable=ansible-galaxy + # Use conda packages/modules first + export PYTHONPATH="${shadow_conda_ws_dir}/lib/python${aurora_python_version}/site-packages" fi # install ansible galaxy docker and aws collections "${ansible_basic_executable}" --version install_ansible_collections "${ansible_galaxy_executable}" - #configure DHCP before running the actual playbook if [[ "${playbook}" = "server_and_nuc_deploy" ]]; then # router = false is default group_var, only install dhcp server on laptop if product is not arm+hand and user has not overridden router=true @@ -460,4 +468,4 @@ echo "" echo " ------------------------------------------------" echo " | Operation completed |" echo " ------------------------------------------------" -echo "" \ No newline at end of file +echo ""