Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save v1ct0rv/def163b7d97408979afc8247c3699cc9 to your computer and use it in GitHub Desktop.
Save v1ct0rv/def163b7d97408979afc8247c3699cc9 to your computer and use it in GitHub Desktop.
Install MacOS Homebrew Packages With Ansible
# Run these commands before run the playbook:
# $ xcode-select --install
# $ sudo easy_install pip
# $ sudo pip install ansible --quiet
# $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# to update ansible use: sudo pip install ansible --upgrade
# Then, run the playbook:
# $ curl https://gist.githubusercontent.com/V1ct0rV/def163b7d97408979afc8247c3699cc9/raw/ansible-macos-homebrew-packages.yml -o playbook.yml
# $ ansible-playbook playbook.yml
---
- name: Install MacOS Packages
hosts: localhost
become: false
vars:
brew_cask_packages:
- 'alfred'
- 'authy'
- 'balenaetcher'
- 'bettertouchtool'
- 'docker'
- 'divvy'
- 'dropbox'
- 'expressvpn'
- 'firefox'
- 'google-chrome'
- 'iterm2'
- 'jetbrains-toolbox'
- 'jdownloader'
- 'lastpass'
- 'microsoft-office'
- 'navicat-premium'
- 'onedrive'
- 'postman'
- 'royal-tsx'
- 'skype'
- 'slack'
- 'sourcetree'
- 'termius'
- 'teamviewer'
- 'the-unarchiver'
- 'transmit'
- 'tunnelblick'
- 'vmware-fusion'
- 'visual-studio-code'
- 'vmware-remote-console'
- 'whatsapp'
- 'zoomus'
- 'vlc'
- 'gpg-suite'
- 'microsoft-azure-storage-explorer'
brew_packages:
- 'antigen'
- 'docker-compose'
- 'git'
- 'git-lfs'
- 'gnu-sed'
- 'gnu-tar'
- 'go'
- 'helm'
- 'helm@2'
- 'jq'
- 'kubectx'
- 'kubernetes-cli'
- 'nmap'
- 'nvm'
- 'openssl'
- 'packer'
- 'pyenv'
- 'python'
- 'ssh-copy-id'
- 'terraform'
- 'tree'
- 'vault'
- 'watch'
- 'wget'
- 'zsh-completions'
python_modules:
- 'configparser'
- 'pylint'
- 'virtualenv'
- 'awscli'
- 'pywinrm'
- 'boto'
- 'PyYAML'
- 'hvac'
- 'cerberus'
- 'j2cli'
upgrade_homebrew_packages: false
pre_tasks:
- name: Ensuring Homebrew Is Installed
stat:
path: "/usr/local/bin/brew"
register: "homebrew_check"
- name: Fail If Homebrew Is Not Installed
fail:
msg: "Homebrew is missing...Install from http://brew.sh/"
when: >
not homebrew_check.stat.exists
tasks:
- name: Updating Homebrew
homebrew:
update_homebrew: true
when: homebrew_check.stat.exists
- name: Installing Homebrew Packages
homebrew:
name: "{{ brew_packages }}"
state: "present"
upgrade_all: "{{ upgrade_homebrew_packages }}"
when: homebrew_check.stat.exists
- name: Installing Homebrew Cask Packages
homebrew_cask:
name: "{{ item }}"
state: "present"
with_items: '{{ brew_cask_packages }}'
when: homebrew_check.stat.exists
- name: Installing Python Modules
pip:
name: "{{ python_modules }}"
state: "present"
extra_args: --user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment