Created
February 25, 2020 22:54
-
-
Save nweddle/d1d012ac30e45926aa4f1bea81f27f7c to your computer and use it in GitHub Desktop.
Ubuntu Idempotent Ansible Install Check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
output="$(apt-cache policy ansible)" | |
installed="$(echo "$output" | sed -n -r 's/^(.*)(Installed: )(.*)$/\3/p')" | |
candidate="$(echo "$output" | sed -n -r 's/^(.*)(Candidate: )(.*)$/\3/p')" | |
if [[ $installed != "$candidate" ]]; then | |
echo Install Ansible | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
sudo apt update | |
sudo apt install --yes software-properties-common | |
sudo apt-add-repository --yes --update ppa:ansible/ansible | |
sudo apt install --yes ansible | |
else | |
echo Ansible up to date | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment