Skip to content
Snippets Groups Projects
Commit ade5f7c8 authored by Georg Krause's avatar Georg Krause
Browse files

feat: Install Ansible in venv

parent 75ab16ce
Branches
No related tags found
1 merge request!36ci: Run tests on debian 12
Pipeline #31990 failed
...@@ -20,7 +20,7 @@ min_python_version_major="3" ...@@ -20,7 +20,7 @@ min_python_version_major="3"
min_python_version_minor="5" min_python_version_minor="5"
base_path="/srv/funkwhale" base_path="/srv/funkwhale"
ansible_conf_path="$base_path/ansible" ansible_conf_path="$base_path/ansible"
ansible_bin_path="$HOME/.local/bin" ansible_venv_path="$HOME/.local/ansible"
ansible_funkwhale_role_version="${ANSIBLE_FUNKWHALE_ROLE_VERSION-master}" ansible_funkwhale_role_version="${ANSIBLE_FUNKWHALE_ROLE_VERSION-master}"
ansible_funkwhale_role_path="${ANSIBLE_FUNKWHALE_ROLE_PATH-}" ansible_funkwhale_role_path="${ANSIBLE_FUNKWHALE_ROLE_PATH-}"
funkwhale_systemd_after="" funkwhale_systemd_after=""
...@@ -216,9 +216,10 @@ do_install() { ...@@ -216,9 +216,10 @@ do_install() {
init_ansible() { init_ansible() {
echo "[2/$total_steps] Installing ansible dependencies..." echo "[2/$total_steps] Installing ansible dependencies..."
install_packages curl git python3-pip python3-apt python3-psycopg2 sudo locales locales-all install_packages curl git python3-pip python3-venv python3-apt python3-psycopg2 sudo locales locales-all
echo "[2/$total_steps] Installing Ansible..." echo "[2/$total_steps] Installing Ansible..."
pip3 install --user ansible=="$ansible_version" python3 -m venv $ansible_venv_path
$ansible_venv_path/bin/pip3 install ansible=="$ansible_version"
echo "[2/$total_steps] Creating ansible configuration files in $ansible_conf_path..." echo "[2/$total_steps] Creating ansible configuration files in $ansible_conf_path..."
mkdir -p "$ansible_conf_path" mkdir -p "$ansible_conf_path"
...@@ -287,7 +288,7 @@ EOF ...@@ -287,7 +288,7 @@ EOF
#!/bin/sh #!/bin/sh
# reapply playbook with existing parameter # reapply playbook with existing parameter
# Useful if you changed some variables in playbook.yml # Useful if you changed some variables in playbook.yml
exec $ansible_bin_path/ansible-playbook -i $ansible_conf_path/inventory.ini $ansible_conf_path/playbook.yml -u root $ansible_flags exec $ansible_venv_path/bin/ansible-playbook -i $ansible_conf_path/inventory.ini $ansible_conf_path/playbook.yml -u root $ansible_flags
EOF EOF
chmod +x ./reconfigure chmod +x ./reconfigure
if [ "$funkwhale_redis_managed" = "false" ]; then if [ "$funkwhale_redis_managed" = "false" ]; then
...@@ -306,7 +307,7 @@ EOF ...@@ -306,7 +307,7 @@ EOF
EOF EOF
if [ "$ansible_funkwhale_role_path" = '' ]; then if [ "$ansible_funkwhale_role_path" = '' ]; then
echo "[2/$total_steps] Downloading Funkwhale playbook dependencies" echo "[2/$total_steps] Downloading Funkwhale playbook dependencies"
$ansible_bin_path/ansible-galaxy install -r requirements.yml -f $ansible_venv_path/bin/ansible-galaxy install -r requirements.yml -f
else else
echo "[2/$total_steps] Skipping playbook dependencies, using local role instead" echo "[2/$total_steps] Skipping playbook dependencies, using local role instead"
fi fi
...@@ -314,7 +315,7 @@ EOF ...@@ -314,7 +315,7 @@ EOF
run_playbook() { run_playbook() {
cd "$ansible_conf_path" cd "$ansible_conf_path"
echo "[3/$total_steps] Installing Funkwhale using ansible playbook in $ansible_conf_path..." echo "[3/$total_steps] Installing Funkwhale using ansible playbook in $ansible_conf_path..."
playbook_command="$ansible_bin_path/ansible-playbook -i $ansible_conf_path/inventory.ini $ansible_conf_path/playbook.yml -u root $ansible_flags" playbook_command="$ansible_venv_path/bin/ansible-playbook -i $ansible_conf_path/inventory.ini $ansible_conf_path/playbook.yml -u root $ansible_flags"
if [ "$is_dry_run" = "true" ]; then if [ "$is_dry_run" = "true" ]; then
playbook_command="$playbook_command --check" playbook_command="$playbook_command --check"
echo "[3/$total_steps] Skipping playbook because DRY_RUN=true" echo "[3/$total_steps] Skipping playbook because DRY_RUN=true"
......
...@@ -14,7 +14,8 @@ skip_confirm="${SKIP_CONFIRM-}" ...@@ -14,7 +14,8 @@ skip_confirm="${SKIP_CONFIRM-}"
is_dry_run=${DRY_RUN-false} is_dry_run=${DRY_RUN-false}
base_path="/srv/funkwhale" base_path="/srv/funkwhale"
ansible_conf_path="$base_path/ansible" ansible_conf_path="$base_path/ansible"
ansible_bin_path="$HOME/.local/bin" ansible_venv_path="$HOME/.local/ansible"
ansible_bin_path="$ansible_venv_path/bin"
ansible_funkwhale_role_version="${ANSIBLE_FUNKWHALE_ROLE_VERSION-master}" ansible_funkwhale_role_version="${ANSIBLE_FUNKWHALE_ROLE_VERSION-master}"
funkwhale_systemd_after="" funkwhale_systemd_after=""
total_steps="4" total_steps="4"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment