1. 環境構築
まずは開発環境の構築。CentOS7には行かずCentOS6.6で一旦Vagrantを使ってセットアップ。
Vagrant init shugepad # Vagrantfile修正 vi Vagrantfile # 起動およびssh接続 vagrant up vagrant ssh
必要最小限のツールをインストール。MacBookProで作業しているが色々汚したくないので今後の作業は全部VM上で行う。
# gitのインストール sudo yum install -y git # rbenvのインストール git clone https://github.com/sstephenson/rbenv.git ~/.rbenv git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(rbenv init -)"' >> ~/.bash_profile source ~/.bash_profile # ruby 2.2.3のインストール rbenv install 2.2.3 rbenv global 2.2.3 # bundlerのインストール rbenv exec gem install bundler
itamaeレシピ用のリポジトリをGitHubに作成。リポジトリは基本GitHubの手順通りに作成。originはhttpsで。(キーの発行を横着)
mkdir shugepad-prov cd !$ echo "# shugepad-prov" >> README.md git init git add README.md git commit -m "first commit" git remote add origin https://wata-gh@github.com/wata-gh/shugepad-prov.git git push -u origin master
Gemfile作成して、bundle install。nownabe_nginxを入れるとitamaeが古くなってしまうのでforkして使用。メンテされていないところを見ると恐らく使われていない。
vi Gemfile
source 'https://rubygems.org' gem 'itamae' gem 'itamae-plugin-recipe-selinux' gem 'itamae-plugin-recipe-nownabe_nginx', :git => 'https://github.com/wata-gh/itamae-plugin-recipe-nownabe_nginx.git' gem 'itamae-plugin-resource-ssh_key' gem 'itamae-plugin-recipe-rbenv'
bundle install --path vendor/bundle
itamaeレシピ作成。vagrantユーザで実行していたのでrootになるためにlocalhostにsshでitamae実行。
bundle exec itamae ssh --user root --host localhost roles/web.rb