Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
roles/base/task/main.yaml
- name: Command Line Toolsが入っているかの確認
stat: path=/usr/include
register: command_line_tools_dir
- name: Command Line Toolsが入っていなかったらインストールする
shell: |
PLACEHOLDER=/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
touch $PLACEHOLDER
PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
softwareupdate -i "${PROD}"
[[ -f $PLACEHOLDER ]] && rm $PLACEHOLDER
when: not command_line_tools_dir.stat.exists
- name: homebrewが入っているかの確認
command: type /usr/local/bin/brew
register: exist_homebrew
ignore_errors: yes
- name: homebrewが入っていなかったらインストールする
shell: echo '\n' | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
when: "'not found' in exist_homebrew.stderr"
- homebrew: update_homebrew=yes
- homebrew_tap: tap={{ item }} state=present
with_items: homebrew.tap
- homebrew_cask: name={{ item }}
with_items: homebrew.cask
- homebrew: name={{ item }}
with_items: homebrew.formula
- name: rbenv関係のformulaをインストールする
homebrew: name={{ item }}
with_items:
- rbenv
- ruby-build
- rbenv-gem-rehash
- file: path=~/.bash_profile state=touch
- lineinfile: dest=~/.bash_profile line='if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi'
- lineinfile: dest=~/.bash_profile line='export PATH=$HOME/.rbenv/shims:$PATH'
- shell: /bin/bash -lc "rbenv install --skip-existing {{ rbenv.global }}"
- shell: /bin/bash -lc "rbenv global {{ rbenv.global }}"
- gem: name={{ item }}
with_items: ruby.gems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment