ようへいの日々精進XP

よかろうもん

2016 年 10 月 13 日(木)

朝が辛いよおっかさん

  • 数年前までは朝早く起きて勉強とか平気だったのに、最近はめっきり辛いよおっかさん

LAMP 構成

  • 時代はサーバーレスだー Docker だーと言われているけど世の中を支えているのは LAMP 構成なんぢゃないかと思うくらい LAMP 構成

博多オフィス

  • 筑紫口二階のプロント、電源も取れて穴場
  • Surface Book を広げて仕事されている方がいらっしゃった
  • Surface Book を店頭以外で見たのは初めて

斎藤さん

  • 前々職で同僚だった斎藤さんとほろ酔い横丁で呑む
  • すげー久しぶりだったけど、お互いの近況報告等しながら日本酒を八合程呑む
  • 色々と苦労されているみたいだけど、あの頃と変わらないノリで話しが出来て本当に良かった
  • 斎藤さん、ありがとう

Infrataster

モチベーション

  • 構築した LAMP 構成のチェックで Serverspec を書こうと思ったけど、Infrataster を書いて Web サイトのレスポンスをテストした

サンプル

冗長な書き方かもしれないけど。

  • spec/spec_helper.rb
require 'infrataster/rspec'

Infrataster::Server.define("foo", "foo.example.com")
Infrataster::Server.define("bar", "bar.example.com")
  • spec/sample_spec.rb
require 'spec_helper'

VHOST=[
  { "server_name": "foo", "url": "foo.example.com/test.php" },
  { "server_name": "bar", "url": "bar.example.com/test.php" },
]

VHOST.each do |p|
  describe server(p[:server_name]) do
    describe http('http://' + p[:url]) do
      it "responds as '200'" do
        expect(response.status).to be 200
      end
      it "responds as 'ok'" do
        expect(response.body).to include('ok.')
      end
    end
  end
end

capistrano

モチベーション

  • 複数サーバーにテスト用のコンテンツをバラマキたい

サンプル

  • Gemfile
source "https://rubygems.org"

gem "capistrano", "2.15.9"
gem "capistrano_colors"

3 系で無いのはすいません。

  • capify から config/deploy.rb 修正(タスクを書く)
mkdir example
cd example
bundle exec capify .
vim config/deploy.rb

以下のような感じ。

require "capistrano_colors"

set :user, "ec2-user"
set :ssh_options, :keys=>"/path/to/key"
set :use_sudo, false

role :dev, "xxx.xxx.xxx.1"
role :stg, "xxx.xxx.xxx.10", "xxx.xxx.xxx.11"

#
# カレントディレクトリの index.html をリモートホストの /var/www/html/index.html にアップロードする
#
namespace :deploy do
  desc "contents upload"
  task :file_upload, :roles => :stg do
    top.upload("index.html", "/var/www/html/index.html", :via => :scp)
  end
end

久しぶりなので混乱したけど、Capistrano 便利。

ノーベル文学賞

怪しいメール

  • キャリアコンサルタントを名乗る外国の方から英語でなんかメールが来ていた
  • よくよく見ると何度か送って下さっているようで恐縮してしまう
  • こんなワシにもメールを送るってのはよっぽど人が集まらないんだろうな