Skip to content

Instantly share code, notes, and snippets.

@EntropyWorks
Last active November 12, 2018 22:41
Show Gist options
  • Save EntropyWorks/b0bc8e752c27b70196d64e1bf420cc18 to your computer and use it in GitHub Desktop.
Save EntropyWorks/b0bc8e752c27b70196d64e1bf420cc18 to your computer and use it in GitHub Desktop.
Backing up my brew install
#!/bin/bash
# Pipe the output to create your own restore-brew.sh
#
brew_command=/usr/local/bin/brew
echo '#!/usr/bin/env ANSIBLE_HOSTS="" ANSIBLE_CONNECTION=local ansible-playbook'
echo '# vim:ft=yaml'
echo ''
echo '---'
echo "- name: Homebrew Restore from $(date)"
echo ' hosts: all'
echo ' connection: local'
echo ' '
echo ' tasks:'
echo ' - name: check for xcode'
echo ' command: xcode-select --print-path'
echo ' register: xcode_select_result'
echo ' '
echo ' - name: check to see if xcode has been run'
echo ' command: xcodebuild -checkFirstLaunchStatus'
echo ' register: xcodebuild_launch_result'
echo ' when: ( xcode_select_result.rc == 69 ) or ( xcode_select_result.rc == 0 )'
echo ' ignore_errors: true'
echo ' '
echo '# - name: accept xcode license'
echo '# command: xcodebuild -license accept'
echo '# when: xcodebuild_launch_result.rc != 0'
echo '# sudo: true'
echo '# '
echo '# - name: install xcode cli'
echo '# command: xcode-select --install'
echo '# when: xcodebuild_launch_result.changed'
echo ' '
echo ' - name: Check if homebrew installed'
echo ' stat:'
echo ' path: /usr/local/bin/brew'
echo ' follow: true'
echo ' register: brew_stat_result'
echo ' '
echo ' - name: Install homerew if brew is not found'
# shellcheck disable=SC2016
echo ' raw: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
echo ' register: homebrew_result'
echo ' failed_when: homebrew_result.rc != 0 and "Homebrew is already installed" not in homebrew_result.stderr'
echo ' when: brew_stat_result.stat.exists == False'
echo ' '
echo ' - name: update brew'
echo ' homebrew:'
echo ' update_homebrew: yes'
echo ' upgrade_all: yes'
echo ' '
echo ' - name: Tap some casks'
echo ' homebrew_tap:'
echo ' name: "{{ item }}"'
echo ' state: present'
echo ' with_items:'
$brew_command tap --full | while read -r item; do
echo " - $item";
done
echo ' '
echo ' - name: Install homebrew items'
echo ' homebrew:'
echo ' name={{ item.name }}'
echo ' state=present'
echo ' install_options={{ item.options }}'
echo ' with_items:'
$brew_command list -1 | grep -v "\(\!\)" | while read -r item; do
# shellcheck disable=SC1083
echo " - { name: '$item', options: '$($brew_command info "$item" 2>/dev/null | /usr/bin/grep 'Built from source with:' | /usr/bin/sed 's/^[ \t]*Built from source with:/ /g; s/\,/ /g')'" }
done
echo ' '
echo ' - name: install osx brew cask software'
echo ' homebrew_cask:'
echo ' name={{ item }}'
echo ' state=present'
echo ' with_items:'
$brew_command cask list -1 | grep -v "\(\!\)" | while read -r item; do
echo " - $item";
done
#!/usr/bin/env ANSIBLE_HOSTS="" ANSIBLE_CONNECTION=local ansible-playbook
# vim:ft=yaml
---
- name: Homebrew Restore from Mon Nov 12 14:10:13 PST 2018
hosts: all
connection: local
tasks:
- name: check for xcode
command: xcode-select --print-path
register: xcode_select_result
- name: check to see if xcode has been run
command: xcodebuild -checkFirstLaunchStatus
register: xcodebuild_launch_result
when: ( xcode_select_result.rc == 69 ) or ( xcode_select_result.rc == 0 )
ignore_errors: true
# - name: accept xcode license
# command: xcodebuild -license accept
# when: xcodebuild_launch_result.rc != 0
# sudo: true
#
# - name: install xcode cli
# command: xcode-select --install
# when: xcodebuild_launch_result.changed
- name: Check if homebrew installed
stat:
path: /usr/local/bin/brew
follow: true
register: brew_stat_result
- name: Install homerew if brew is not found
raw: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
register: homebrew_result
failed_when: homebrew_result.rc != 0 and "Homebrew is already installed" not in homebrew_result.stderr
when: brew_stat_result.stat.exists == False
- name: update brew
homebrew:
update_homebrew: yes
upgrade_all: yes
- name: Tap some casks
homebrew_tap:
name: "{{ item }}"
state: present
with_items:
- ammonite-repl
- folly
- gflags
- gjs
- groovy
- groovysdk
- jetty
- minizinc
- pgcli
- prettier
- sbcl
- sphinx-doc
- tbb
- tile38
- azure/draft
- grammarly/tap
- homebrew/bundle
- homebrew/cask
- homebrew/cask-drivers
- homebrew/cask-fonts
- homebrew/cask-versions
- homebrew/completions
- homebrew/core
- homebrew/dupes
- homebrew/fuse
- homebrew/games
- homebrew/python
- homebrew/science
- homebrew/services
- homebrew/versions
- jlhonora/lsusb
- justwatchcom/gopass
- minio/stable
- neovim/neovim
- wata727/tflint
- name: Install homebrew items
homebrew:
name={{ item.name }}
state=present
install_options={{ item.options }}
with_items:
- { name: 'ack', options: '' }
- { name: 'adns', options: '' }
- { name: 'amazon-ecs-cli', options: '' }
- { name: 'ansible', options: '' }
- { name: 'ansible-cmdb', options: '' }
- { name: 'ant', options: '' }
- { name: 'aptly', options: '' }
- { name: 'argp-standalone', options: '' }
- { name: 'arp-scan', options: '' }
- { name: 'asciinema', options: '' }
- { name: 'aspcud', options: '' }
- { name: 'atk', options: '' }
- { name: 'augeas', options: '' }
- { name: 'auto-scaling', options: '' }
- { name: 'autoconf', options: '' }
- { name: 'autoconf-archive', options: '' }
- { name: 'automake', options: '' }
- { name: 'aws-shell', options: '' }
- { name: 'awscli', options: '' }
- { name: 'awslogs', options: '' }
- { name: 'bash', options: '' }
- { name: 'bash-completion', options: '' }
- { name: 'bash-git-prompt', options: '' }
- { name: 'bazel', options: '' }
- { name: 'bdw-gc', options: '' }
- { name: 'berkeley-db', options: '' }
- { name: 'bfg', options: '' }
- { name: 'boost', options: '' }
- { name: 'brew-cask-completion', options: '' }
- { name: 'byobu', options: '' }
- { name: 'cabextract', options: '' }
- { name: 'cairo', options: '' }
- { name: 'camlp4', options: '' }
- { name: 'carthage', options: '' }
- { name: 'certbot', options: '' }
- { name: 'cfssl', options: '' }
- { name: 'checkbashisms', options: '' }
- { name: 'clasp', options: '' }
- { name: 'clingo', options: '' }
- { name: 'cloud-watch', options: '' }
- { name: 'cmake', options: '' }
- { name: 'cmatrix', options: '' }
- { name: 'consul', options: '' }
- { name: 'consul-backinator', options: '' }
- { name: 'coreutils', options: '' }
- { name: 'cppunit', options: '' }
- { name: 'crystal', options: '' }
- { name: 'cscope', options: '' }
- { name: 'dcraw', options: '' }
- { name: 'dep', options: '' }
- { name: 'dfu-programmer', options: '' }
- { name: 'dfu-util', options: '' }
- { name: 'dialog', options: '' }
- { name: 'diff-so-fancy', options: '' }
- { name: 'diffoscope', options: '' }
- { name: 'diffuse', options: '' }
- { name: 'dirmngr', options: '' }
- { name: 'dnsmasq', options: '' }
- { name: 'docbook', options: '' }
- { name: 'docker-machine-driver-xhyve', options: '' }
- { name: 'dos2unix', options: '' }
- { name: 'doxygen', options: '' }
- { name: 'draft', options: '' }
- { name: 'duplicity', options: '' }
- { name: 'duti', options: '' }
- { name: 'envconsul', options: '' }
- { name: 'ffmpeg', options: '' }
- { name: 'fftw', options: '' }
- { name: 'flac', options: '' }
- { name: 'flex', options: '' }
- { name: 'fontconfig', options: '' }
- { name: 'freetype', options: '' }
- { name: 'fribidi', options: '' }
- { name: 'gawk', options: '' }
- { name: 'gcc', options: '' }
- { name: 'gd', options: '' }
- { name: 'gdbm', options: '' }
- { name: 'gdk-pixbuf', options: '' }
- { name: 'gettext', options: '' }
- { name: 'gist', options: '' }
- { name: 'git', options: '' }
- { name: 'git-cola', options: '' }
- { name: 'git-extras', options: '' }
- { name: 'git-fixup', options: '' }
- { name: 'git-flow', options: '' }
- { name: 'git-imerge', options: '' }
- { name: 'git-lfs', options: '' }
- { name: 'git-secrets', options: '' }
- { name: 'git-town', options: '' }
- { name: 'glew', options: '' }
- { name: 'glfw', options: '' }
- { name: 'glib', options: '' }
- { name: 'gmp', options: '' }
- { name: 'gnome-doc-utils', options: '' }
- { name: 'gnu-getopt', options: '' }
- { name: 'gnu-sed', options: '' }
- { name: 'gnu-tar', options: '' }
- { name: 'gnupg', options: '' }
- { name: 'gnuplot', options: '' }
- { name: 'gnutls', options: '' }
- { name: 'go', options: '' }
- { name: 'gobject-introspection', options: '' }
- { name: 'gperf', options: '' }
- { name: 'gpg-agent', options: '' }
- { name: 'graphite2', options: '' }
- { name: 'graphviz', options: '' }
- { name: 'gringo', options: '' }
- { name: 'grsync', options: '' }
- { name: 'gsettings-desktop-schemas', options: '' }
- { name: 'gsl', options: '' }
- { name: 'gtk+', options: '' }
- { name: 'gtk+3', options: '' }
- { name: 'harfbuzz', options: '' }
- { name: 'hicolor-icon-theme', options: '' }
- { name: 'highlight', options: '' }
- { name: 'hilite', options: '' }
- { name: 'htop', options: '' }
- { name: 'htop-osx', options: '' }
- { name: 'hub', options: '' }
- { name: 'icdiff', options: '' }
- { name: 'ice', options: '' }
- { name: 'icu4c', options: '' }
- { name: 'imagemagick', options: '' }
- { name: 'intltool', options: '' }
- { name: 'ipcalc', options: '' }
- { name: 'ipv6calc', options: '' }
- { name: 'isl', options: '' }
- { name: 'itpp', options: '' }
- { name: 'jack', options: '' }
- { name: 'jansson', options: '' }
- { name: 'jasper', options: '' }
- { name: 'jemalloc', options: '' }
- { name: 'jpeg', options: '' }
- { name: 'jq', options: '' }
- { name: 'json-c', options: '' }
- { name: 'kops', options: '' }
- { name: 'kubernetes-cli', options: '' }
- { name: 'kubernetes-helm', options: '' }
- { name: 'lame', options: '' }
- { name: 'legit', options: '' }
- { name: 'libarchive', options: '' }
- { name: 'libassuan', options: '' }
- { name: 'libbladerf', options: '' }
- { name: 'libepoxy', options: '' }
- { name: 'libev', options: '' }
- { name: 'libevent', options: '' }
- { name: 'libffi', options: '' }
- { name: 'libgcrypt', options: '' }
- { name: 'libgeotiff', options: '' }
- { name: 'libgit2', options: '' }
- { name: 'libgpg-error', options: '' }
- { name: 'libgphoto2', options: '' }
- { name: 'libicns', options: '' }
- { name: 'libidn2', options: '' }
- { name: 'libksba', options: '' }
- { name: 'libmagic', options: '' }
- { name: 'libmpc', options: '' }
- { name: 'libogg', options: '' }
- { name: 'libpcap', options: '' }
- { name: 'libpng', options: '' }
- { name: 'librsync', options: '' }
- { name: 'libsamplerate', options: '' }
- { name: 'libsndfile', options: '' }
- { name: 'libssh2', options: '' }
- { name: 'libtasn1', options: '' }
- { name: 'libtermkey', options: '' }
- { name: 'libtiff', options: '' }
- { name: 'libtool', options: '' }
- { name: 'libunistring', options: '' }
- { name: 'libusb', options: '' }
- { name: 'libusb-compat', options: '' }
- { name: 'libuv', options: '' }
- { name: 'libvorbis', options: '' }
- { name: 'libvpx', options: '' }
- { name: 'libvterm', options: '' }
- { name: 'libxml2', options: '' }
- { name: 'libxmlsec1', options: '' }
- { name: 'libyaml', options: '' }
- { name: 'libyubikey', options: '' }
- { name: 'little-cms', options: '' }
- { name: 'little-cms2', options: '' }
- { name: 'lldpd', options: '' }
- { name: 'llvm', options: '' }
- { name: 'llvm@5', options: '' }
- { name: 'llvm@6', options: '' }
- { name: 'lmdb', options: '' }
- { name: 'logstash', options: '' }
- { name: 'lrzsz', options: '' }
- { name: 'lsusb', options: '' }
- { name: 'lua', options: '' }
- { name: 'luajit', options: '' }
- { name: 'lzlib', options: '' }
- { name: 'makedepend', options: '' }
- { name: 'mc', options: '' }
- { name: 'mcpp', options: '' }
- { name: 'md5sha1sum', options: '' }
- { name: 'memcached', options: '' }
- { name: 'mercurial', options: '' }
- { name: 'mono', options: '' }
- { name: 'mpfr', options: '' }
- { name: 'msgpack', options: '' }
- { name: 'mtr', options: '' }
- { name: 'mysql', options: '' }
- { name: 'ncdu', options: '' }
- { name: 'ncurses', options: '' }
- { name: 'neovim', options: '' }
- { name: 'net-snmp', options: '' }
- { name: 'nettle', options: '' }
- { name: 'newt', options: '' }
- { name: 'nmap', options: '' }
- { name: 'npth', options: '' }
- { name: 'oath-toolkit', options: '' }
- { name: 'ocaml', options: '' }
- { name: 'ocamlbuild', options: '' }
- { name: 'oniguruma', options: '' }
- { name: 'opam', options: '' }
- { name: 'open-completion', options: '' }
- { name: 'openblas', options: '' }
- { name: 'openconnect', options: '' }
- { name: 'openjpeg', options: '' }
- { name: 'openssh', options: '' }
- { name: 'openssl', options: '' }
- { name: '[email protected]', options: '' }
- { name: 'opus', options: '' }
- { name: 'otto', options: '' }
- { name: 'p11-kit', options: '' }
- { name: 'p7zip', options: '' }
- { name: 'packer', options: '' }
- { name: 'pandoc', options: '' }
- { name: 'pango', options: '' }
- { name: 'parallel', options: '' }
- { name: 'patchutils', options: '' }
- { name: 'pcre', options: '' }
- { name: 'pcre2', options: '' }
- { name: 'perl', options: '' }
- { name: 'phantomjs', options: '' }
- { name: 'pinentry', options: '' }
- { name: 'pinentry-mac', options: '' }
- { name: 'pixman', options: '' }
- { name: 'pkg-config', options: '' }
- { name: 'poco', options: '' }
- { name: 'popt', options: '' }
- { name: 'postgresql', options: '' }
- { name: 'pre-commit', options: '' }
- { name: 'proj', options: '' }
- { name: 'protobuf', options: '' }
- { name: 'pstree', options: '' }
- { name: 'pth', options: '' }
- { name: 'putty', options: '' }
- { name: 'pwgen', options: '' }
- { name: 'py2cairo', options: '' }
- { name: 'pyenv', options: '' }
- { name: 'pyenv-virtualenv', options: '' }
- { name: 'pygobject', options: '' }
- { name: 'pygtk', options: '' }
- { name: 'pyqt', options: '' }
- { name: 'python', options: '' }
- { name: 'python3', options: '' }
- { name: 'python@2', options: '' }
- { name: 'qemu', options: '' }
- { name: 'qrencode', options: '' }
- { name: 'qt', options: '' }
- { name: 'qt5', options: '' }
- { name: '[email protected]', options: '' }
- { name: 'qwt', options: '' }
- { name: 'rarian', options: '' }
- { name: 'rclone', options: '' }
- { name: 'readline', options: '' }
- { name: 'reattach-to-user-namespace', options: '' }
- { name: 'rlog', options: '' }
- { name: 'rocker', options: '' }
- { name: 'ruby', options: '' }
- { name: 's-lang', options: '' }
- { name: 'salt', options: '' }
- { name: 'saltstack', options: '' }
- { name: 'sane-backends', options: '' }
- { name: 'sdl', options: '' }
- { name: 'sdl2', options: '' }
- { name: 'shared-mime-info', options: '' }
- { name: 'shellcheck', options: '' }
- { name: 'shfmt', options: '' }
- { name: 'shyaml', options: '' }
- { name: 'sip', options: '' }
- { name: 'sipcalc', options: '' }
- { name: 'snappy', options: '' }
- { name: 'socat', options: '' }
- { name: 'splint', options: '' }
- { name: 'sqlite', options: '' }
- { name: 'squid', options: '' }
- { name: 'ssh-copy-id', options: '' }
- { name: 'ssh-vault', options: '' }
- { name: 'sshpass', options: '' }
- { name: 'sslscan', options: '' }
- { name: 'stormssh', options: '' }
- { name: 'stormssh-completion', options: '' }
- { name: 'swaks', options: '' }
- { name: 'swig', options: '' }
- { name: 'terraform', options: '' }
- { name: 'terraform-inventory', options: '' }
- { name: 'terraforming', options: '' }
- { name: 'tflint', options: '' }
- { name: 'the_silver_searcher', options: '' }
- { name: 'theora', options: '' }
- { name: 'tig', options: '' }
- { name: 'tmux', options: '' }
- { name: 'tree', options: '' }
- { name: 'ttyrec', options: '' }
- { name: 'ufraw', options: '' }
- { name: 'uhd', options: '' }
- { name: 'uncrustify', options: '' }
- { name: 'unibilium', options: '' }
- { name: 'unrar', options: '' }
- { name: 'utf8proc', options: '' }
- { name: 'vagrant-completion', options: '' }
- { name: 'vault', options: '' }
- { name: 'vault-cli', options: '' }
- { name: 'vim', options: '' }
- { name: 'webp', options: '' }
- { name: 'wemux', options: '' }
- { name: 'wget', options: '' }
- { name: 'wxmac', options: '' }
- { name: 'wxpython', options: '' }
- { name: 'x264', options: '' }
- { name: 'x265', options: '' }
- { name: 'xhyve', options: '' }
- { name: 'xvid', options: '' }
- { name: 'xz', options: '' }
- { name: 'yajl', options: '' }
- { name: 'yaml-cpp', options: '' }
- { name: 'ykpers', options: '' }
- { name: 'yubico-piv-tool', options: '' }
- { name: 'zbar', options: '' }
- { name: 'zenity', options: '' }
- { name: 'zeromq', options: '' }
- { name: 'zlib', options: '' }
- name: install osx brew cask software
homebrew_cask:
name={{ item }}
state=present
with_items:
- amazon-drive
- android-file-transfer
- apache-directory-studio
- appcleaner
- applepi-baker
- atom
- audiomate
- bartender
- betterzipql
- box-sync
- boxcryptor
- chromium
- cord
- cyberduck
- dbeaver-community
- dbglass
- diffmerge
- disk-inventory-x
- docker-beta
- dropbox
- duplicati
- easyfind
- etcher
- firefox
- fission
- flycut
- font-awesome-terminal-fonts
- font-source-code-pro
- font-source-code-pro-for-powerline
- font-stardos-stencil
- force-paste
- franz
- gimp
- github-desktop
- gitup
- go2shell
- google-chrome
- google-cloud-sdk
- google-drive
- google-earth
- google-photos-backup
- google-play-music-desktop-player
- gpgtools-beta
- inkscape
- iterm2-beta
- java
- jiggler
- keeweb
- keybase
- kitematic
- krita
- logitech-control-center
- logitech-unifying
- macvim
- meld
- mkchromecast
- mouse-locator
- pallotron-yubiswitch
- pgadmin4
- psequel
- pycharm-ce
- qlcolorcode
- qlimagesize
- qlmarkdown
- qlprettypatch
- qlstephen
- qlvideo
- quicklook-csv
- quicklook-json
- quicklookase
- rclone-browser
- revisions
- ripit
- semaphor
- sequel-pro
- shiba
- sitesucker
- soundflower
- sourcetree
- spideroakone
- squidman
- sublime-text
- suspicious-package
- syncthing-bar
- synergy
- taskpaper
- telegram
- the-unarchiver
- thunderbird
- typora
- vagrant
- valentina-studio
- vimr
- virtualbox
- virtualbox-extension-pack
- visual-studio-code
- webpquicklook
- wineskin-winery
- wireshark
- xquartz
- yed
- yubico-authenticator
- yubico-yubikey-manager
- yubico-yubikey-personalization-gui
- yubico-yubikey-piv-manager
- yubikey-neo-manager
- yubikey-personalization-gui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment