Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make aurora use conda ansible #628

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bin/conda_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;</Key>;;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;</Key>;;g')

echo "remote_packages: ${remote_packages}"

Expand Down Expand Up @@ -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/*)
Expand Down
28 changes: 18 additions & 10 deletions bin/run-ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -460,4 +468,4 @@ echo ""
echo " ------------------------------------------------"
echo " | Operation completed |"
echo " ------------------------------------------------"
echo ""
echo ""