Ansible playbook and guide for quickly provisioning personal work environment when setting up MacOS.
- Ansible versions: 2.12.x
- macOS versions: 11.6, 12.3
- Ubuntu versions: 16.x, 18.x
For MacOS user:
$ brew install ansible
# If python3 is not installed yet,
# brew install python3
For Ubuntu user:
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible python3
In this repo's root directory,
$ ansible-galaxy install --roles-path=.galaxy_roles viasite-ansible.zsh
If you encounter a connection error on first run,
- (Only MacOS) Check
Remote Login
in System Preferences -> Sharing - Add
ECDSA
key into your~/.ssh/known_hosts
by typeyes
in below comamnd:
$ ssh 127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:ifxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0o.
Are you sure you want to continue connecting (yes/no)?
- Add current user's key into itself
~/.ssh/authorized_keys
file:
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
If No such file or directory
error occurs,
first you need to generate SSH Key like this:
$ ssh-keygen
## Then just input 'Enter' continuously without passphrase for your convenience.
You need to provide the ansible_become_pass
variable as an encrypted file.
$ ansible-vault create vars-user.yml
New Vault password: `<Temporary password>`
Confirm New Vault password: `<Temporary password>`
Then, when the editor opens, write the following:
# password to run sudo.
# If the current user can use sudo without a password, it can be omitted.
ansible_become_pass: '<user-sudo-password>'
# If "Incorrect su password" error occurs, try belows:
ansible_become_method: su
ansible_become_user: root
ansible_become_pass: '<root-password>'
# for Ubuntu
ansible_python_interpreter: /usr/bin/python3 # this overwrite vars.yml's value
# optional variables:
EXTRA_VAR_UPDATE_VIM_PLUGIN: true # default: false
EXTRA_VAR_NO_SPECIAL_CHAR_IN_PROMPT: true # default: false
# for MacOS 10.15
$ ansible-playbook site-macos-10-or-11.yml -v -u $USER --ask-vault-pass
# for Ubuntu 16 or 18
$ ansible-playbook site-ubuntu-16-or-18.yml -v -u $USER --ask-vault-pass
## or you can excute only specific tagged task, using -t
$ ansible-playbook <site-xxx.yml> -v -u $USER --ask-vault-pass -t git
insecure directories and files 문제로 Reset antigen cache task등에서 진행이 막혔을 때,
** 확인: **
$ compaudit
There are insecure directories:
/usr/local/share/zsh/site-functions
/usr/local/share/zsh
** 해결: **
$ compaudit | xargs chmod g-w
ansible-playbook
실행 후 해야 할 수동 작업 들:
Install node:
$ nvm ls-remote --lts
$ nvm install <node-version>
$ nvm use <node-version>
(Only Ubuntu) Install yarn:
$ npm install --global yarn
Install terraform:
$ tfenv list-remote
$ tfenv install <terraform-version>
$ tfenv use <terraform-version>
if Command not found error occurs, close the shell(ssh) and try again after reconnecting.
(Only Ubuntu) Install Docker:
- https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script
- This guide is Tested in Ubuntu 18.04
$ curl -fsSL https://get.docker.com/ | sudo sh -
$ sudo groupadd docker
$ sudo usermod -aG docker <userid>
$ newgrp docker
if you are using Proxy network,
$ sudo mkdir -p /etc/systemd/system/docker.service.d
$ sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf
Edit http-proxy.conf like below:
[Service]
Environment="HTTP_PROXY=http://your.proxy.server:8080"
Environment="HTTPS_PROXY=http://your.proxy.server:8080"
Environment="NO_PROXY=localhost,.company.internal.net"
Restart docker:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
Check installation:
$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
Server:
Containers: 18
Running: 4
Paused: 0
Stopped: 14
Images: 42
Server Version: 20.10.6
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
...
If permission error occur, below might resolve the problem.
$ sudo chmod 660 /var/run/docker.sock
Hello world:
$ docker login # by username/password in https://hub.docker.com
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:9f6ad537c5132bcce57f7a0a20e317228d382c3cd61edae14650eec68b2b345c
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
- References: https://andrewpage.tistory.com/95
- 만일의 사태를 대비해 plist 파일을 백업
$ cp ~/Library/Preferences/com.apple.symbolichotkeys.plist ~/Library/Preferences/com.apple.symbolichotkeys.plist.backup
- plist 파일을 xml 형식으로 변경
$ plutil -convert xml1 ~/Library/Preferences/com.apple.symbolichotkeys.plist
~/Library/Preferences/com.apple.symbolichotkeys.plist
xml 문서를 수정
...
<key>61</key> <!-- 여기 key: 61 을 찾아서, -->
<dict>
<key>enabled</key>
<true/>
<key>value</key>
<dict>
<key>parameters</key>
<array>
<integer>32</integer>
<integer>49</integer>
<integer>8519680</integer> <!-- 3번째 integer 값을 131072로 변경 -->
</array>
<key>type</key>
<string>standard</string>
...
- 다시 원래의 plist binary 형태로 변환
$ plutil -convert binary1 ~/Library/Preferences/com.apple.symbolichotkeys.plist
- macOS reboot
- Preferences - Keyboard - Adjust
Key Repeat
,Delay Until Repeat
- Preferences - Keyboard - Modifier Keys... - Caps Lock Key:
No Action
- Preferences - Keyboard - Text - uncheck:
Use smart quotes and dashes
매크로 설정 sync를 통해 기존 셋팅을 그대로 싱크:
- 처음 싱크를 시작하는 방법: File - Start Syncing Macros... - Create New... 이후 Dropbox 디렉토리를 선택하여 싱크 시작.
- 기존 싱크 파일로 싱크 시작하는 방법: File - Start Syncing Macrots... - Open Existing... 이후 Dropbox 디렉토리의 싱크파일 선택.
- https://www.alfredapp.com/
- Advanced - Syncing - Set preferences folder... 에서 Dropbox를 사용하여 Alfred 설정을 싱크 할수 있음.
- https://iterm2colorschemes.com/
- recommend: NightLion v2, Tango Dark
$ defaults write -g ApplePressAndHoldEnabled -bool false
- TODO: Catalina에서 동작 확인 필요
#!/bin/bash
if [ -f ~/Library/KeyBindings/DefaultkeyBinding.dict ]; then
echo "~/Library/KeyBindings/DefaultkeyBinding.dict already exists"
exit -1
fi
mkdir -p ~/Library/KeyBindings
cat << EOF > ~/Library/KeyBindings/DefaultkeyBinding.dict
{
"₩" = ("insertText:", "\`");
}
EOF
echo "Done."
참고:
- 구름 입력기 사용자는 환경설정에서
한글 입력기일 때 역따옴표로 원화 기호 입력
을 체크 해제로 같은 효과
- https://github.com/naver/d2codingfont/releases
D2Coding/D2Coding-Ver1.3.2-20180524
,D2Coding/D2CodingBold-Ver1.3.2-20180524
파일 2개만 설치하는 것을 추천