仕事で使ってるtmuxを動かしているサーバーがあるのですが、タワー型のやっすいの使っててそこにCentOS7突っ込んでオフィスに直置きしてます。法定停電でもあった日にゃ育てたtmuxのセッションが死滅し、その明けの出勤は気が重くなること請け合いな感じになっていたので、CentOSからの脱却もかねてAWS上にUbuntuサーバーを立てて俺色に染めてやろうと思ったわけですはい。とりあえず手動でガシガシと構築していって最終的にAnsibleのPlaybookを作るとこまでやっております。
要件
基本的にこの子たちがいればどこにいてもやっていけると思う。
- Zsh(zplug/ghq/peco)
- tmux
- Vim
- Git
- Ansible
- Docker
Ubuntuの良いところ
弊社はほとんどがCentOSでgitやtmuxが最初から入ってなくてしかもyum
でインストールできるのはバージョンが古いものになってしまうけど、Ubuntuの18.04.1 LTSはさいしょからtmux 2.6
とgit 2.17.1
が入っているのでとっても良いぞってなったのでこれからUbuntuを愛していこうとおもいます。
やること
AWSでのインスタンス作成は割愛します。
- rootアカウントでのパスワード認証を許可する
- Zsh(peco/go/ghq)のインストール
- Ansibleのインストール
- Dockerのインストール
- Playbook化
rootアカウントでのパスワード認証を許可する
自分が使い倒すだけのサーバーなのでrootアカウントのパスワードを設定しパスワードログインができるようにします。
# passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
/etc/ssh/sshd_config
を以下のように編集
- PasswordAuthentication no + PasswordAuthentication yes + PermitRootLogin yes
sshdの再起動
# systemctl restart sshd
Zsh(zplug/ghq/peco)のインストール
まずはzshを以下のようにインストール
# apt install zsh
お次に公式手順に従いzplugをインストール
# curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
pecoのインストール
cd /usr/src wget https://github.com/peco/peco/releases/download/v0.5.3/peco_linux_amd64.tar.gz tar zxvf peco_linux_amd64.tar.gz cd peco_linux_amd64 cp -p peco /usr/local/bin peco --version peco version v0.5.3 (built with go1.10)
ghqを使うためにgoをインストール
apt-get install gcc make apt-get install golang go version go version go1.10.4 linux/amd64
.zshrcの配布
ghqのインストール
go get github.com/motemen/ghq
※ちなみにghqコマンドにパスを通すために.zshrc
または.zshenv
にに以下を追記する必要があります。
## golang export GOPATH=$HOME export PATH=$PATH:$GOPATH/bin
zshをデフォルトのログインシェルにする
chsh -s /usr/bin/zsh
Ansibleのインストール
公式手順にのっとり以下のようにインストールを実施
Installation Guide — Ansible Documentation
apt-get update apt install software-properties-common apt-add-repository ppa:ansible/ansible apt update apt install ansible
Dockerのインストール
以下手順にのっとり以下のようにスクリプトでインストールを実施
curl -fsSL get.docker.com -o get-docker.sh sh get-docker.sh # Executing docker install script, commit: 46dc063 + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null + sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null Warning: apt-key output should not be parsed (stdout is not a terminal) + sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic edge" > /etc/apt/sources.list.d/docker.list + [ ubuntu = debian ] + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null + sh -c docker version Client: Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:49:01 2018 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:16:44 2018 OS/Arch: linux/amd64 Experimental: false If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group with something like: sudo usermod -aG docker your-user Remember that you will have to log out and back in for this to take effect! WARNING: Adding a user to the "docker" group will grant the ability to run containers which can be used to obtain root privileges on the docker host. Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface for more information.
Playbook化
まだやってないけど、Ubuntuに変えたのでこれからは普通にTravisCIを使った自動テストも組めるぞ~! github.com
そんな感じで
やはりCentOSはちょっと使いづらいなぁと感じつつ、VimからNeoVimへの移行もしないといけないかなぁと思い始めたのでまた別の機会にまとめようかと思いますー!