├── .gitignore ├── LICENSE ├── README.md ├── ansible.cfg ├── hosts ├── playbook.yml ├── roles ├── dotfiles │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── fzf │ └── tasks │ │ └── main.yml ├── go │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── homebrew │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── macos │ ├── handlers │ │ └── main.yml │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── neovim │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── node │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── python │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── ruby │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml ├── scripts │ ├── tasks │ │ └── main.yml │ └── vars │ │ └── main.yml └── zsh │ ├── tasks │ └── main.yml │ └── vars │ └── main.yml └── setup /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | 25 | # PyInstaller 26 | # Usually these files are written by a python script from a template 27 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 28 | *.manifest 29 | *.spec 30 | 31 | # Installer logs 32 | pip-log.txt 33 | pip-delete-this-directory.txt 34 | 35 | # Unit test / coverage reports 36 | htmlcov/ 37 | .tox/ 38 | .coverage 39 | .cache 40 | nosetests.xml 41 | coverage.xml 42 | 43 | # Translations 44 | *.mo 45 | *.pot 46 | 47 | # Django stuff: 48 | *.log 49 | 50 | # Sphinx documentation 51 | docs/_build/ 52 | 53 | # PyBuilder 54 | target/ 55 | 56 | # Ansible 57 | *.retry 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Soshi Katsuta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible playbook for macOS 2 | 3 | This playbook provides automatic installation of: 4 | 5 | - dot files 6 | - zsh 7 | - Vim 8 | - Go 9 | - Homebrew / Cask packages 10 | - Ruby and Gems 11 | - Vagrant plugins 12 | - fzf 13 | - Node modules 14 | - Python packages 15 | 16 | on your macOS. 17 | 18 | ## Usage 19 | 20 | ### Setup 21 | 22 | ```sh 23 | $ curl -O https://raw.githubusercontent.com/skatsuta/ansible-macos/master/setup 24 | $ bash setup 25 | ``` 26 | 27 | Then you will be prompted like the following: 28 | 29 | ```sh 30 | Copying your SSH public key into your clipboard... 31 | Now you should add the generated key to GitHub before proceeding. 32 | Are you sure you want to proceed? [Y/n] 33 | ``` 34 | 35 | Your public key is already copied in your clipboard, so add the key to GitHub before hitting the enter key. 36 | 37 | After all the setup processes are done, you will see the following message: 38 | 39 | ```sh 40 | Initialization has been completed successfully. 41 | To start provisioning, run 42 | 43 | $ cd /Users/skatsuta/src/github.com/skatsuta/ansible-macos 44 | $ GOPATH=~ ansible-playbook playbook.yml 45 | ``` 46 | 47 | Then go to the next step. 48 | (If you encounter any problem during setup, fix it and re-run the script.) 49 | 50 | ### Full Installation 51 | 52 | If you want to install all the packages above, just run 53 | 54 | ```sh 55 | $ ansible-playbook playbook.yml 56 | ``` 57 | 58 | ### Partial Installation 59 | 60 | If you want to install a paticular package, for example, `go`, run with `-t` option: 61 | 62 | ```sh 63 | $ ansible-playbook playbook.yml -t go 64 | ``` 65 | 66 | This provisions only Go environment. 67 | -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | # config file for ansible -- http://ansible.com/ 2 | # ============================================== 3 | 4 | # nearly all parameters can be overridden in ansible-playbook 5 | # or with command line flags. ansible will read ANSIBLE_CONFIG, 6 | # ansible.cfg in the current working directory, .ansible.cfg in 7 | # the home directory or /etc/ansible/ansible.cfg, whichever it 8 | # finds first 9 | # 10 | # for a commented example file with all possible values, 11 | # see https://raw.github.com/ansible/ansible/devel/examples/ansible.cfg 12 | 13 | [defaults] 14 | inventory = ./hosts 15 | # http://www.ansibleworks.com/docs/gettingstarted.html#a-note-about-host-key-checking 16 | host_key_checking = False 17 | # Do not create a .retry file 18 | retry_files_enabled = False 19 | 20 | [ssh_connection] 21 | # Enabling pipelining reduces the number of SSH operations required to 22 | # execute a module on the remote server. This can result in a significant 23 | # performance improvement when enabled, however when using "sudo:" you must 24 | # first disable 'requiretty' in /etc/sudoers 25 | # 26 | # By default, this option is disabled to preserve compatibility with 27 | # sudoers configurations that have requiretty (the default on many distros). 28 | # 29 | pipelining = True 30 | -------------------------------------------------------------------------------- /hosts: -------------------------------------------------------------------------------- 1 | [macos] 2 | localhost ansible_connection=local 3 | -------------------------------------------------------------------------------- /playbook.yml: -------------------------------------------------------------------------------- 1 | - hosts: macos 2 | roles: 3 | - role: dotfiles 4 | tags: dotfiles 5 | - role: zsh 6 | tags: zsh 7 | - role: neovim 8 | tags: neovim 9 | - role: homebrew 10 | tags: homebrew 11 | - role: macos 12 | tags: macos 13 | - role: scripts 14 | tags: scripts 15 | - role: node 16 | tags: node 17 | - role: ruby 18 | tags: ruby 19 | - role: go 20 | tags: go 21 | - role: fzf 22 | tags: fzf 23 | - role: python 24 | tags: python 25 | -------------------------------------------------------------------------------- /roles/dotfiles/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: clone dotfiles repo 3 | git: 4 | repo: '{{ dotfiles.repo }}' 5 | dest: '{{ dotfiles.dir }}' 6 | tags: dotfiles-clone 7 | 8 | - name: deploy each symlink of dotfiles into $HOME 9 | command: ./install 10 | args: 11 | chdir: '{{ dotfiles.dir }}' 12 | creates: '{{ dotfiles.creates }}' 13 | tags: dotfiles-symlink 14 | 15 | -------------------------------------------------------------------------------- /roles/dotfiles/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dotfiles: 3 | repo: ssh://git@github.com/skatsuta/dotfiles.git 4 | dir: ~/src/github.com/skatsuta/dotfiles 5 | creates: ~/.zshrc 6 | -------------------------------------------------------------------------------- /roles/fzf/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install fzf 3 | homebrew: 4 | name: fzf 5 | state: latest 6 | register: fzf_status 7 | tags: fzf-install 8 | 9 | - name: install useful key bindings and fuzzy completion 10 | shell: $(brew --prefix)/opt/fzf/install --key-bindings --completion --no-update-rc 11 | when: fzf_status.changed 12 | tags: fzf-install-extra 13 | -------------------------------------------------------------------------------- /roles/go/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install Go with cross compilers via Homebrew 3 | homebrew: 4 | name: go 5 | state: latest 6 | install_options: with-cc-common 7 | tags: go-install 8 | 9 | - name: install packages 10 | command: 'go install {{ item }}@latest' 11 | args: 12 | # Trim trailing '/...' 13 | creates: '{{ lookup("env", "GOPATH") }}/src/{{ item | regex_replace("/\.\.\.$", "") }}' 14 | with_items: '{{ go.pkgs }}' 15 | tags: go-pkg-install 16 | -------------------------------------------------------------------------------- /roles/go/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | go: 3 | pkgs: 4 | - github.com/Alistanis/st 5 | - github.com/axw/gocov/gocov 6 | - github.com/go-bootstrap/go-bootstrap 7 | - github.com/jstemmer/gotags 8 | - github.com/kisielk/errcheck 9 | - github.com/mailgun/godebug 10 | - github.com/mattn/goveralls 11 | - github.com/mholt/archiver/cmd/arc 12 | - github.com/monochromegane/argen/... 13 | - github.com/x-motemen/gore/cmd/gore 14 | - github.com/nsf/gocode 15 | - github.com/onsi/ginkgo/ginkgo 16 | - github.com/onsi/gomega/... 17 | - github.com/pilu/fresh 18 | - github.com/pquerna/ffjson 19 | - github.com/rogpeppe/godef 20 | - golang.org/x/tools/cmd/goimports 21 | - golang.org/x/tools/cmd/gorename 22 | - golang.org/x/tools/cmd/present 23 | - golang.org/x/tools/cmd/stringer 24 | - rsc.io/2fa 25 | -------------------------------------------------------------------------------- /roles/homebrew/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: update Homebrew itself 3 | homebrew: 4 | update_homebrew: yes 5 | tags: homebrew-update 6 | 7 | - name: tap extra repositories 8 | homebrew_tap: 9 | tap: '{{ homebrew.taps }}' 10 | state: present 11 | tags: homebrew-tap 12 | 13 | - name: install Homebrew Casks 14 | homebrew_cask: 15 | name: '{{ homebrew.casks }}' 16 | state: present 17 | tags: homebrew-cask-install 18 | 19 | - name: install Homebrew formula 20 | homebrew: 21 | name: '{{ homebrew.formula }}' 22 | state: latest 23 | tags: homebrew-install 24 | -------------------------------------------------------------------------------- /roles/homebrew/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | homebrew: 3 | taps: 4 | - buo/cask-upgrade # useful to upgrade casks 5 | formula: 6 | - ansible 7 | - aria2 8 | - autojump 9 | - awscli 10 | - bash 11 | - bat 12 | - black 13 | - cheat 14 | - cmake 15 | - coreutils 16 | - ctags 17 | - curl 18 | - diff-so-fancy 19 | - direnv 20 | - eslint 21 | - eza 22 | - fd 23 | - flake8 24 | - ghq 25 | - git 26 | - git-secrets 27 | - gnu-sed 28 | - golangci-lint 29 | - grip 30 | - httpie 31 | - htop 32 | - hub 33 | - icdiff 34 | - isort 35 | - java 36 | - jid 37 | - jq 38 | - knqyf263/pet/pet 39 | - legit 40 | - llvm 41 | - mycli 42 | - neovim 43 | - nkf 44 | - node 45 | - openssl 46 | - peco 47 | - pipenv 48 | - prettier 49 | - pyenv 50 | - pyright 51 | - python 52 | - rbenv 53 | - reattach-to-user-namespace 54 | - remarshal 55 | - ripgrep 56 | - ruby 57 | - ruby-build 58 | - rust 59 | - ssh-copy-id 60 | - terminal-notifier 61 | - tig 62 | - tree 63 | - vitorgalvao/tiny-scripts/cask-repair 64 | - wget 65 | - zsh 66 | casks: 67 | - alfred 68 | - appcleaner 69 | - authy 70 | - dash 71 | - docker 72 | - dropbox 73 | - evernote 74 | - goland 75 | - google-cloud-sdk 76 | - google-chrome 77 | - google-drive 78 | - google-japanese-ime 79 | - iterm2 80 | - kindle 81 | - omnidisksweeper 82 | - sequel-ace 83 | - slack 84 | - spectacle 85 | - the-unarchiver 86 | - visual-studio-code 87 | - vlc 88 | -------------------------------------------------------------------------------- /roles/macos/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Restart Dock 3 | shell: | 4 | killall Dock 5 | 6 | - name: Restart Finder 7 | shell: | 8 | killall Finder 9 | -------------------------------------------------------------------------------- /roles/macos/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Configure macOS defaults 3 | osx_defaults: 4 | domain: '{{ item.domain }}' 5 | host: '{{ item.host | default(omit) }}' 6 | key: '{{ item.key }}' 7 | type: '{{ item.type }}' 8 | value: '{{ item.value }}' 9 | state: present 10 | # default(omit): see http://docs.ansible.com/ansible/playbooks_filters.html#omitting-parameters 11 | notify: '{{ item.notify | default(omit) }}' 12 | with_items: '{{ macos_defaults }}' 13 | -------------------------------------------------------------------------------- /roles/macos/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | macos_defaults: 3 | #===== Global Settings ===== 4 | # Make key repeat fastest 5 | - domain: NSGlobalDomain 6 | key: InitialKeyRepeat 7 | type: float 8 | value: 10 9 | 10 | # Make key repeat fastest 11 | - domain: NSGlobalDomain 12 | key: KeyRepeat 13 | type: float 14 | value: 1 15 | 16 | # Do not upload documents to iCloud 17 | - domain: NSGlobalDomain 18 | key: NSDocumentSaveNewDocumentsToCloud 19 | type: bool 20 | value: false 21 | 22 | # Show all file extensions 23 | - domain: NSGlobalDomain 24 | key: AppleShowAllExtensions 25 | type: bool 26 | value: true 27 | notify: Restart Finder 28 | 29 | # Make Trackpad's tracking speed fastest 30 | - domain: NSGlobalDomain 31 | key: com.apple.trackpad.scaling 32 | type: float 33 | value: 3 34 | 35 | 36 | #===== Software Update ===== 37 | # Check for software update daily, not once per week 38 | - domain: com.apple.SoftwareUpdate 39 | key: ScheduleFrequency 40 | type: int 41 | value: 1 42 | 43 | 44 | #===== Finder ===== 45 | # Set new Finder windows 46 | - domain: com.apple.finder 47 | key: NewWindowTargetPath 48 | type: string 49 | value: 'file://{{ ansible_user_dir }}/Dropbox/' 50 | notify: Restart Finder 51 | 52 | # Show mounted servers on desktop 53 | - domain: com.apple.finder 54 | key: ShowMountedServersOnDesktop 55 | type: bool 56 | value: true 57 | notify: Restart Finder 58 | 59 | # Show all hidden files 60 | - domain: com.apple.finder 61 | key: AppleShowAllFiles 62 | type: string 63 | value: 'true' 64 | notify: Restart Finder 65 | 66 | # Show full path in Finder title 67 | - domain: com.apple.finder 68 | key: _FXShowPosixPathInTitle 69 | type: bool 70 | value: true 71 | notify: Restart Finder 72 | 73 | 74 | #===== Dock ===== 75 | # Turn hiding on 76 | - domain: com.apple.dock 77 | key: autohide 78 | type: bool 79 | value: true 80 | notify: Restart Dock 81 | 82 | # Show Dock immediately 83 | - domain: com.apple.dock 84 | key: autohide-delay 85 | type: float 86 | value: 0 87 | notify: Restart Dock 88 | 89 | # Set position on screen 90 | - domain: com.apple.dock 91 | key: orientation 92 | type: string 93 | value: "right" 94 | notify: Restart Dock 95 | 96 | 97 | #===== Trackpad ===== 98 | # Enable three finger drag (Built-in) 99 | - domain: com.apple.AppleMultitouchTrackpad 100 | key: TrackpadThreeFingerDrag 101 | type: bool 102 | value: true 103 | 104 | # Enable three finger drag (Bluetooth) 105 | - domain: com.apple.driver.AppleBluetoothMultitouch.trackpad 106 | key: TrackpadThreeFingerDrag 107 | type: bool 108 | value: true 109 | 110 | # Enable "Look up & data detectors" with three fingers tap 111 | - domain: com.apple.driver.AppleBluetoothMultitouch.trackpad 112 | key: TrackpadThreeFingerTapGesture 113 | type: int 114 | value: 2 115 | 116 | 117 | #===== Desktop Services ===== 118 | # Do not create .DS_Store 119 | - domain: com.apple.desktopservices 120 | key: DSDontWriteNetworkStores 121 | type: bool 122 | value: true 123 | notify: Restart Finder 124 | 125 | 126 | #===== Screen Saver ===== 127 | # Disable screen saver 128 | - domain: com.apple.screensaver 129 | host: currentHost 130 | key: idleTime 131 | type: int 132 | value: 0 133 | 134 | # Require password after sleep 135 | - domain: com.apple.screensaver 136 | key: askForPassword 137 | type: int 138 | value: 1 139 | 140 | # Require password after 5 seconds from sleep 141 | - domain: com.apple.screensaver 142 | key: askForPasswordDelay 143 | type: float 144 | value: 5 145 | 146 | 147 | #===== Visual Studio Code ===== 148 | # Disable the Apple press and hold for VSCode 149 | - domain: com.microsoft.VSCode 150 | key: ApplePressAndHoldEnabled 151 | type: bool 152 | value: false 153 | -------------------------------------------------------------------------------- /roles/neovim/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install Neovim via Homebrew 3 | homebrew: 4 | name: 5 | - neovim 6 | - python3 7 | state: latest 8 | tags: neovim-install 9 | 10 | - name: install Python provider 11 | pip: 12 | name: neovim 13 | state: latest 14 | executable: pip3 15 | tags: neovim-install-python 16 | 17 | - name: install Node.js 18 | homebrew: 19 | name: node 20 | state: latest 21 | tags: neovim-install-node 22 | 23 | - name: install Node.js provider 24 | npm: 25 | name: neovim 26 | state: latest 27 | global: yes 28 | tags: neovim-install-node 29 | 30 | - name: prepare necessary directories 31 | file: 32 | path: '{{ item }}' 33 | state: directory 34 | recurse: yes 35 | mode: 0755 36 | with_items: 37 | - '{{ neovim.autoload }}' 38 | - '{{ neovim.colors }}' 39 | tags: neovim-prepare-dirs 40 | 41 | - name: install color schemes 42 | get_url: 43 | url: '{{ item.url }}' 44 | dest: '{{ neovim.colors }}/{{ item.file }}' 45 | with_items: '{{ neovim.color_schemes }}' 46 | tags: neovim-install-color-scheme 47 | 48 | - name: install Python client for Neovim 49 | pip: 50 | name: neovim 51 | state: latest 52 | executable: pip3 53 | tags: neovim-install-python 54 | 55 | - name: install Vim-Plug 56 | get_url: 57 | url: '{{ vim_plug.url }}' 58 | dest: '{{ neovim.autoload }}/{{ vim_plug.file }}' 59 | tags: neovim-install-plug 60 | 61 | - name: install plugins 62 | command: nvim +UpdateRemotePlugins +PlugInstall +qall 63 | args: 64 | creates: '{{ vim_plug.home }}' 65 | tags: neovim-install-plugins 66 | -------------------------------------------------------------------------------- /roles/neovim/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | neovim: 3 | autoload: ~/.local/share/nvim/site/autoload 4 | colors: ~/.config/nvim/colors 5 | color_schemes: 6 | # Molokai 7 | - url: https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim 8 | file: molokai.vim 9 | 10 | vim_plug: 11 | url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 12 | file: plug.vim 13 | home: ~/.local/share/nvim/plugged 14 | -------------------------------------------------------------------------------- /roles/node/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: create a directory for nvm 3 | file: 4 | path: '{{ nvm_home }}' 5 | state: directory 6 | mode: '0755' 7 | tags: nvm-install 8 | 9 | - name: install nvm 10 | shell: curl -o- "{{ nvm_installer_url }}" | bash 11 | args: 12 | creates: '{{ nvm_home }}' 13 | tags: nvm-install 14 | 15 | - name: install npm modules 16 | npm: 17 | name: '{{ item }}' 18 | state: latest 19 | global: yes 20 | with_items: '{{ node_modules }}' 21 | tags: npm-install 22 | -------------------------------------------------------------------------------- /roles/node/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | nvm_version: v0.39.5 3 | nvm_installer_url: 'https://raw.githubusercontent.com/nvm-sh/nvm/{{ nvm_version }}/install.sh' 4 | nvm_home: ~/.nvm 5 | node_modules: 6 | - npm-check-updates 7 | - tldr 8 | -------------------------------------------------------------------------------- /roles/python/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: install Python 3 2 | homebrew: 3 | name: python3 4 | state: latest 5 | tags: python-install 6 | 7 | - name: install Python packages 8 | pip: 9 | name: '{{ packages }}' 10 | state: latest 11 | executable: pip3 12 | tags: python-package-install 13 | -------------------------------------------------------------------------------- /roles/python/vars/main.yml: -------------------------------------------------------------------------------- 1 | packages: 2 | - flake8 3 | - isort 4 | - neovim 5 | - yapf 6 | -------------------------------------------------------------------------------- /roles/ruby/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install Ruby 3 | homebrew: 4 | name: ruby 5 | state: latest 6 | tags: ruby-install 7 | 8 | - name: install Gems 9 | gem: 10 | name: '{{ item }}' 11 | state: latest 12 | with_items: '{{ gems }}' 13 | tags: ruby-gem-install 14 | -------------------------------------------------------------------------------- /roles/ruby/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | gems: 3 | - bundler 4 | - rake 5 | - rubocop 6 | - refe2 7 | -------------------------------------------------------------------------------- /roles/scripts/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: clone scripts repo 3 | git: 4 | repo: 'ssh://git@github.com/{{ scripts_repo }}.git' 5 | dest: '{{ scripts_dir }}' 6 | tags: scripts-clone 7 | 8 | - name: deploy each symlink of scripts into the target directory 9 | command: ./install 10 | args: 11 | chdir: '{{ scripts_dir }}' 12 | creates: '{{ target_dir }}/bu' 13 | tags: scripts-symlink 14 | 15 | -------------------------------------------------------------------------------- /roles/scripts/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | scripts_repo: skatsuta/scripts 3 | scripts_dir: ~/src/github.com/skatsuta/scripts 4 | target_dir: ~/bin 5 | -------------------------------------------------------------------------------- /roles/zsh/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: install zsh via Homebrew 3 | homebrew: 4 | name: zsh 5 | state: latest 6 | tags: zsh-install 7 | 8 | 9 | ##### Plugins ##### 10 | - name: install zaw 11 | git: 12 | repo: 'ssh://git@github.com/{{ item.user }}/{{ item.name }}.git' 13 | dest: '{{ zsh_plugin_home }}/{{ item.name }}' 14 | with_items: '{{ zsh_plugins }}' 15 | tags: zsh-install-plugins 16 | 17 | 18 | ###### Configuration framework ##### 19 | - name: install Prezto 20 | git: 21 | repo: 'ssh://git@github.com/sorin-ionescu/prezto.git' 22 | dest: '{{ zsh_prezto_home }}' 23 | recursive: yes 24 | tags: zsh-cfg-fwk 25 | 26 | - name: create symlinks to zsh config files 27 | file: 28 | src: '{{ zsh_prezto_home }}/runcoms/{{ item }}' 29 | dest: '~/.{{ item }}' 30 | state: link 31 | with_items: '{{ zsh_prezto_config_files }}' 32 | tags: zsh-cfg-fwk 33 | -------------------------------------------------------------------------------- /roles/zsh/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | zsh_plugin_home: ~/.zsh 3 | 4 | zsh_prezto_home: ~/.zprezto 5 | zsh_prezto_config_files: 6 | - zlogin 7 | - zlogout 8 | - zprofile 9 | - zshenv 10 | 11 | zsh_plugins: 12 | - user: zsh-users 13 | name: zaw 14 | - user: marzocchi 15 | name: zsh-notify 16 | -------------------------------------------------------------------------------- /setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e -u 3 | 4 | # Configurations 5 | GHUSER=${GHUSER:-skatsuta} 6 | REPO=${REPO:-ansible-macos} 7 | DEST=${DEST:-${HOME}/src/github.com/${GHUSER}} 8 | DIR="${DEST}/${REPO}" 9 | SSH_KEY_TYPE=${SSH_KEY_TYPE:-ed25519} 10 | SSH_KEY_PATH=$HOME/.ssh/id_$SSH_KEY_TYPE 11 | 12 | 13 | # Show variables 14 | show_variables() { 15 | echo "Configurations:" 16 | echo " - Username: ${GHUSER}" 17 | echo " - Repository: ${REPO}" 18 | echo " - Destination: ${DEST}" 19 | echo " - SSH key type: ${SSH_KEY_TYPE}" 20 | } 21 | 22 | # Show ~/Library folder 23 | configure() { 24 | echo "Setting to show ~/Library..." 25 | chflags nohidden ~/Library 26 | echo "Turning off startup chime..." 27 | sudo nvram SystemAudioVolume=" " 28 | } 29 | 30 | # Generate SSH Key 31 | generate_ssh_key() { 32 | if [[ -f "$SSH_KEY_PATH" ]]; then 33 | echo "Your SSH key already exists." 34 | return 35 | fi 36 | 37 | echo "Generating a SSH key..." 38 | read -p "Type your email address: " email 39 | ssh-keygen -t "$SSH_KEY_TYPE" -C "$email" 40 | 41 | echo "Adding your SSH key to your ssh-agent..." 42 | eval "$(ssh-agent -s)" 43 | ssh-add "$SSH_KEY_PATH" 44 | } 45 | 46 | # Prompt the confirmation of adding the SSH key to GitHub 47 | prompt_confirmation() { 48 | echo "Copying your SSH public key into your clipboard..." 49 | pbcopy < "$SSH_KEY_PATH.pub" 50 | 51 | echo "Now you should add the generated key to GitHub before proceeding." 52 | while true; do 53 | read -p "Are you sure you want to proceed? [Y/n] " yn 54 | case $yn in 55 | [Yy]*|'') 56 | echo "Proceeding..." 57 | break 58 | ;; 59 | [Nn]*) 60 | echo "Stopped." 61 | exit 1 62 | ;; 63 | esac 64 | done 65 | } 66 | 67 | # Install Command Line Tools 68 | install_command_line_tools() { 69 | if [[ -d /Library/Developer/CommandLineTools ]]; then 70 | echo "Command Line Tools is already installed." 71 | return 72 | fi 73 | 74 | echo "Installing Command Line Tools..." 75 | echo "*** If a dialog is shown, push 'Install' button to install Command Line Tools before proceeding! ***" 76 | xcode-select --install 77 | } 78 | 79 | # Install Homebrew 80 | install_homebrew() { 81 | if [[ -f /usr/local/bin/brew ]]; then 82 | echo "Homebrew is already installed." 83 | return 84 | fi 85 | 86 | echo "Installing Homebrew..." 87 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 88 | 89 | echo "Adding environment variables to $HOME/.zprofile..." 90 | local homebrew_home=/usr/local 91 | if [[ $(sysctl -n machdep.cpu.brand_string) =~ 'Apple' ]]; then 92 | homebrew_home=/opt/homebrew 93 | fi 94 | echo '# Homebrew' >> $HOME/.zprofile 95 | echo 'eval $('${homebrew_home}'/bin/brew shellenv)' >> $HOME/.zprofile 96 | eval $(${homebrew_home}/bin/brew shellenv) 97 | 98 | echo "Running 'brew doctor'..." 99 | brew doctor 100 | } 101 | 102 | # Install packages for running Ansible playbook 103 | install_packages_for_ansible() { 104 | echo "Installing packages for running Ansible..." 105 | brew install git ansible 106 | } 107 | 108 | # Clone my GitHub repository 109 | clone_repo() { 110 | if [[ -d "${DIR}" ]]; then 111 | echo "Repository already exists." 112 | return 113 | fi 114 | 115 | git clone git@github.com:${GHUSER}/${REPO}.git ${DIR} 116 | cd ${DIR} 117 | } 118 | 119 | # Provision 120 | provision() { 121 | #cd ${DEST}/${REPO} 122 | #echo "Start provisioning..." 123 | #ansible-playbook playbook.yml 124 | 125 | echo "Initialization has been completed successfully." 126 | echo "To start provisioning, run" 127 | echo 128 | echo " \$ cd ${DIR}" 129 | echo ' $ ansible-playbook playbook.yml' 130 | } 131 | 132 | # Run the above functions 133 | run() { 134 | show_variables 135 | configure 136 | generate_ssh_key 137 | prompt_confirmation 138 | install_command_line_tools 139 | install_homebrew 140 | install_packages_for_ansible 141 | clone_repo 142 | provision 143 | } 144 | 145 | run 146 | --------------------------------------------------------------------------------