Replace software-install scripts with Ansible playbook and role.
This commit is contained in:
parent
e4806a8ea8
commit
ac373d3479
41
.Brewfile
41
.Brewfile
|
@ -1,41 +0,0 @@
|
||||||
tap "caskroom/versions"
|
|
||||||
tap "buo/homebrew-cask-upgrade"
|
|
||||||
|
|
||||||
brew "ack"
|
|
||||||
brew "bash-completion"
|
|
||||||
brew "git"
|
|
||||||
brew "coreutils"
|
|
||||||
brew "htop-osx"
|
|
||||||
brew "ipcalc"
|
|
||||||
brew "mosh"
|
|
||||||
brew "nmap"
|
|
||||||
brew "p7zip"
|
|
||||||
brew "psgrep"
|
|
||||||
brew "pv"
|
|
||||||
brew "python3"
|
|
||||||
brew "rename"
|
|
||||||
brew "task"
|
|
||||||
brew "tree"
|
|
||||||
brew "vim"
|
|
||||||
|
|
||||||
cask "alfred"
|
|
||||||
cask "bbc-iplayer-downloads"
|
|
||||||
cask "beardedspice"
|
|
||||||
cask "cleanmymac"
|
|
||||||
cask "enpass"
|
|
||||||
cask "firefox"
|
|
||||||
cask "google-backup-and-sync"
|
|
||||||
cask "google-chrome"
|
|
||||||
cask "google-hangouts"
|
|
||||||
cask "handbrake"
|
|
||||||
cask "iterm2"
|
|
||||||
cask "itsycal"
|
|
||||||
cask "osxfuse"
|
|
||||||
cask "resilio-sync"
|
|
||||||
cask "sonos"
|
|
||||||
cask "sublime-text"
|
|
||||||
cask "virtualbox"
|
|
||||||
cask "wireshark"
|
|
||||||
cask "xquartz"
|
|
||||||
cask "yubikey-manager"
|
|
||||||
cask "yubikey-personalization-gui"
|
|
2
.ansible.cfg
Normal file
2
.ansible.cfg
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[defaults]
|
||||||
|
inventory = ~/.ansible/inventory.yaml
|
4
.ansible/inventory.yaml
Normal file
4
.ansible/inventory.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
mac_desktops:
|
||||||
|
hosts:
|
||||||
|
localhost:
|
||||||
|
ansible_connection: local
|
39
.ansible/roles/mac_desktop/tasks/homebrew.yaml
Normal file
39
.ansible/roles/mac_desktop/tasks/homebrew.yaml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# Install Homebrew
|
||||||
|
- name: Check for Homebrew
|
||||||
|
stat:
|
||||||
|
path: /usr/local/bin/brew
|
||||||
|
register: st
|
||||||
|
|
||||||
|
- name: Install Homebrew
|
||||||
|
command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||||
|
when: st.stat.executable != True
|
||||||
|
|
||||||
|
- name: Disable Homebrew analytics
|
||||||
|
command: brew analytics off
|
||||||
|
|
||||||
|
# Taps
|
||||||
|
- name: Install Homebrew Taps
|
||||||
|
homebrew_tap:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ homebrew_tap_items }}"
|
||||||
|
|
||||||
|
# Update and upgrades
|
||||||
|
- name: Homebrew update and upgrades
|
||||||
|
homebrew:
|
||||||
|
update_homebrew: True
|
||||||
|
upgrade_all: True
|
||||||
|
|
||||||
|
# Brews
|
||||||
|
- name: Install Homebrew Brews
|
||||||
|
homebrew:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ homebrew_brew_items }}"
|
||||||
|
|
||||||
|
# Casks
|
||||||
|
- name: Install Homebrew Casks
|
||||||
|
homebrew_cask:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ homebrew_cask_items }}"
|
4
.ansible/roles/mac_desktop/tasks/main.yaml
Normal file
4
.ansible/roles/mac_desktop/tasks/main.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Homebrew tasks
|
||||||
|
import_tasks: homebrew.yaml
|
||||||
|
- import_tasks: mas.yaml
|
||||||
|
- import_tasks: prefs.yaml
|
2
.ansible/roles/mac_desktop/tasks/mas.yaml
Normal file
2
.ansible/roles/mac_desktop/tasks/mas.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
- name: Upgrade AppStore apps
|
||||||
|
command: mas upgrade
|
2
.ansible/roles/mac_desktop/tasks/prefs.yaml
Normal file
2
.ansible/roles/mac_desktop/tasks/prefs.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
- name: Clear preferences cache
|
||||||
|
command: pkill -u ${USER} cfprefsd
|
50
.ansible/roles/mac_desktop/vars/main.yaml
Normal file
50
.ansible/roles/mac_desktop/vars/main.yaml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
homebrew_tap_items:
|
||||||
|
- caskroom/versions
|
||||||
|
- buo/homebrew-cask-upgrade
|
||||||
|
|
||||||
|
homebrew_brew_items:
|
||||||
|
- ack
|
||||||
|
- bash-completion
|
||||||
|
- curl
|
||||||
|
- git
|
||||||
|
- coreutils
|
||||||
|
- htop-osx
|
||||||
|
- ipcalc
|
||||||
|
- mas
|
||||||
|
- mosh
|
||||||
|
- nmap
|
||||||
|
- p7zip
|
||||||
|
- psgrep
|
||||||
|
- pv
|
||||||
|
- python3
|
||||||
|
- rename
|
||||||
|
- screen
|
||||||
|
- task
|
||||||
|
- tree
|
||||||
|
- vim
|
||||||
|
- watch
|
||||||
|
|
||||||
|
homebrew_cask_items:
|
||||||
|
- alfred
|
||||||
|
- bbc-iplayer-downloads
|
||||||
|
- beardedspice
|
||||||
|
- cleanmymac
|
||||||
|
- enpass
|
||||||
|
- firefox
|
||||||
|
- flux
|
||||||
|
- google-backup-and-sync
|
||||||
|
- google-chrome
|
||||||
|
- google-hangouts
|
||||||
|
- handbrake
|
||||||
|
- iterm2
|
||||||
|
- itsycal
|
||||||
|
- osxfuse
|
||||||
|
- resilio-sync
|
||||||
|
- sonos
|
||||||
|
- sublime-text
|
||||||
|
- virtualbox
|
||||||
|
- whatsapp
|
||||||
|
- wireshark
|
||||||
|
- xquartz
|
||||||
|
- yubikey-manager
|
||||||
|
- yubikey-personalization-gui
|
4
.ansible/site.yaml
Normal file
4
.ansible/site.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Mac desktops
|
||||||
|
hosts: mac_desktops
|
||||||
|
roles:
|
||||||
|
- mac_desktop
|
|
@ -1,103 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
function configure_Linux_software {
|
|
||||||
echo "Not configured yet."
|
|
||||||
}
|
|
||||||
|
|
||||||
function configure_Darwin_software {
|
|
||||||
# Ensure any preference cache is cleared
|
|
||||||
pkill -u ${USER} cfprefsd
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_Linux_software {
|
|
||||||
#-------------------------------
|
|
||||||
# Check the OS and set install command
|
|
||||||
#-------------------------------
|
|
||||||
if [ -x "$(which yum)" ]; then
|
|
||||||
INSTALLCMD="yum install -y"
|
|
||||||
elif [ -x "$(which apt-get)" ]; then
|
|
||||||
INSTALLCMD="apt-get install -y"
|
|
||||||
else
|
|
||||||
echo "Sorry, I don't know how to install software on this OS yet."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
#-------------------------------
|
|
||||||
|
|
||||||
xargs -n1 sudo ${INSTALLCMD} <<-EOF
|
|
||||||
ack
|
|
||||||
archey
|
|
||||||
bash-completion
|
|
||||||
git
|
|
||||||
htop
|
|
||||||
mosh
|
|
||||||
nmap
|
|
||||||
p7zip
|
|
||||||
psgrep
|
|
||||||
pv
|
|
||||||
ss
|
|
||||||
vim
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_Darwin_software {
|
|
||||||
#-------------------------------
|
|
||||||
# Install Homebrew if missing
|
|
||||||
#-------------------------------
|
|
||||||
if [ ! -x /usr/local/bin/brew ]; then
|
|
||||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
||||||
brew tap buo/cask-upgrade
|
|
||||||
fi
|
|
||||||
#-------------------------------
|
|
||||||
|
|
||||||
# Disable Homebrew's Google Analytics tracking
|
|
||||||
brew analytics off
|
|
||||||
|
|
||||||
# Update Brew formulae if older than 24 hours
|
|
||||||
find /usr/local/Homebrew/.git -name FETCH_HEAD -mtime +0 -exec brew update \;
|
|
||||||
|
|
||||||
# Install homebrew/bundle tap if we don't have it
|
|
||||||
[ -d /usr/local/Library/Taps/homebrew/homebrew-bundle ] || brew tap homebrew/bundle
|
|
||||||
|
|
||||||
#-------------------------------
|
|
||||||
# Run brew bundle if there's a newer version of Brewfile
|
|
||||||
#-------------------------------
|
|
||||||
if [ ~/.Brewfile -nt ~/.Brewfile.updated ]; then
|
|
||||||
( brew bundle --global install && touch ~/.Brewfile.updated )
|
|
||||||
fi
|
|
||||||
#-------------------------------
|
|
||||||
|
|
||||||
#-------------------------------
|
|
||||||
# Upgrade and clean Brew
|
|
||||||
#-------------------------------
|
|
||||||
brew upgrade
|
|
||||||
brew cleanup
|
|
||||||
brew bundle --global check
|
|
||||||
brew cask cleanup
|
|
||||||
brew cu -y --cleanup
|
|
||||||
#-------------------------------
|
|
||||||
|
|
||||||
#-------------------------------
|
|
||||||
# OS X software update
|
|
||||||
#-------------------------------
|
|
||||||
softwareupdate -ia --verbose
|
|
||||||
#-------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_python_modules {
|
|
||||||
pip install pyopenssl
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "#-------------------------------"
|
|
||||||
echo "# START: $(date)"
|
|
||||||
echo "#-------------------------------"
|
|
||||||
|
|
||||||
# Call the install function appropriate for this platform
|
|
||||||
install_$(uname -s)_software
|
|
||||||
configure_$(uname -s)_software
|
|
||||||
install_python_modules
|
|
||||||
|
|
||||||
echo "#-------------------------------"
|
|
||||||
echo "# END: $(date)"
|
|
||||||
echo "#-------------------------------"
|
|
||||||
|
|
||||||
exit 0
|
|
Loading…
Reference in a new issue