Skip to content

Instantly share code, notes, and snippets.

@haxwithaxe
Last active May 1, 2024 11:17
Show Gist options
  • Select an option

  • Save haxwithaxe/5f6d97f936cc5ebc71192b3c93fca218 to your computer and use it in GitHub Desktop.

Select an option

Save haxwithaxe/5f6d97f936cc5ebc71192b3c93fca218 to your computer and use it in GitHub Desktop.
A script to bootstrap ansible, run ansible-pull, and cleanup after
#!/bin/bash
REPO="$1"
shift
BRANCH="${1:-main}" # Or commit or tag
shift
DEBIAN_NONINTERACTIVE=true
apt update -y
apt install --no-install-recommends --no-install-suggests -q -y python3-pip python3-venv git
python3 -m venv /tmp/ansible-venv
source /tmp/ansible-venv/bin/activate
pip install ansible
apt purge -y --autoremove python3-pip python3-venv
ansible-pull -U "$REPO" -C "$BRANCH" $@
rm -rf /tmp/ansible-venv ~/.ansible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment