tl;dr
- 暑い
朝
- 走ってきた
昼
- お昼ごはんと夕飯の買い出し、刺盛りが荷崩れしてグチャグチャになって悲しかった
夕方
- 早めに仕事を切り上げた
〆
- 熱中症に気をつけたい
福岡マラソンの抽選に落ちた。出場は絶望的。
夏は始まったばかり。
うっかりしていたら 7 月になっていた。
Q.なぜ毎年6月から7月にかけて、戦隊や仮面ライダーやプリキュアが次々とパワーアップするのですか? A.お父さんのボーナス時期だからです。
— hrn11_bot (@hrn011) 2016年7月2日
そういうことなのかと納得。
加齢と共に目視チェックが辛くなってきた年寄りインフラエンジニアには Infrataster がうってつけだと思って、Infrataster の DNS プラグインを使ってみたのでメモ。
% sw_vers ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G19a % bundle exec gem list | grep infrataster infrataster (0.3.2) infrataster-plugin-dns (0.0.2)
こちらを参考にさせて頂いて準備。
source 'https://rubygems.org' gem 'infrataster-plugin-dns'
bundle install --path vendor/bundle
require "infrataster/rspec" require "infrataster-plugin-dns" Infrataster::Server.define( :dns01, "8.8.8.8" ) Infrataster::Server.define( :dns02, "8.8.4.4" )
require "spec_helper" %w(dns01 dns02).each do |dns| # こんな書き方するのが正しいのか判らないけど describe server(dns.to_sym) do describe dns("inokara.com") do it { is_expected.to have_dns.with_type("NS").and_domainname(/dns.ne.jp/) } end %w( kome.inokara.com ).each do |domain| describe dns(domain) do it { is_expected.to have_entry.with_type("CNAME").and_domainname(/s3-website-ap-northeast-1/) } end end end end
require "spec_helper" %w(dns01 dns02).each do |dns| # こんな書き方するのが正しいのか判らないけど describe server(dns.to_sym) do describe dns("test.inokara.com") do it { is_expected.to have_dns.with_type("NS").and_domainname(/awsdns/) } end %w( pm25.test.inokara.com ).each do |domain| describe dns(domain) do it { is_expected.to have_entry.with_type("A").and_address(/54.231/) } end end end end
bundle exec rspec spec
server 'dns01' dns 'inokara.com' should have the correct dns entries with {:type=>"NS", :domainname=>/dns.ne.jp/} dns 'kome.inokara.com' should have the correct dns entries with {:type=>"CNAME", :domainname=>/s3-website-ap-northeast-1/} server 'dns02' dns 'inokara.com' should have the correct dns entries with {:type=>"NS", :domainname=>/dns.ne.jp/} dns 'kome.inokara.com' should have the correct dns entries with {:type=>"CNAME", :domainname=>/s3-website-ap-northeast-1/} server 'dns01' dns 'test.inokara.com' should have the correct dns entries with {:type=>"NS", :domainname=>/awsdns/} dns 'pm25.test.inokara.com' should have the correct dns entries with {:type=>"A", :address=>/54.231/} server 'dns02' dns 'test.inokara.com' should have the correct dns entries with {:type=>"NS", :domainname=>/awsdns/} dns 'pm25.test.inokara.com' should have the correct dns entries with {:type=>"A", :address=>/54.231/} Finished in 0.59681 seconds (files took 1.07 seconds to load) 8 examples, 0 failures
いい感じ。
DNS 移行時際のテスト等に非常に有効だと思う。また、プロジェクト終盤に疲弊した状態にはこのような(シェルスクリプトだってイイと思う)機械的な確認の方が安全なのは言うまでも無い。特に自分のような年寄りが関わっている場合にはなおさら。
素敵なインフラテストライフを。
Jenkins の練習していたら CLI で操作出来るとのことなので、Jenkins プラグインを CLI 利用してインストールしてみたメモ。
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty $ java -jar jenkins-cli.jar -s http://localhost:8080 version 1.651.3
wget http://localhost:8080/jnlpJars/jenkins-cli.jar
java -jar jenkins-cli.jar -s http://localhost:8080 help
以下のように出力される。
add-job-to-view Adds jobs to view. build Builds a job, and optionally waits until its completion. cancel-quiet-down Cancel the effect of the "quiet-down" command. clear-queue Clears the build queue. connect-node Reconnect to a node. console Retrieves console output of a build. copy-job Copies a job. (snip) update-view Updates the view definition XML from stdin. The opposite of the get-view command. version Outputs the current version. wait-node-offline Wait for a node to become offline. wait-node-online Wait for a node to become online. who-am-i Reports your credential and permissions.
前後してしまうが、CLI は以下のように実行する。
java -jar jenkins-cli.jar [-s JENKINS_URL] command [options...] [arguments...]
インストールしたいプラグイン。
以下のように実行する。
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin github java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin build-pipeline-plugin java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin docker-build-publish
尚、引数として指定するプラグインの名前は Plugins ページから辿れる個々のプラグインページで確認するプラグイン ID を指定する。
プラグインのインストール後は Jenkins プロセスを再起動して設定を反映させる。
適当に利用出来るオプションを叩いてみた。
$ java -jar jenkins-cli.jar -s http://localhost:8080 version 1.651.3
$ java -jar jenkins-cli.jar -s http://localhost:8080 list-jobs Docker_Build_Push Serverspec_Handson
$ java -jar jenkins-cli.jar -s http://localhost:8080 get-job Docker_Build_Push
以下のように出力される。
<?xml version='1.0' encoding='UTF-8'?> <project> <actions/> <description></description> <keepDependencies>false</keepDependencies> <properties/> <scm class="hudson.scm.NullSCM"/> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders> (snip) </builders> <publishers/> <buildWrappers/> </project>
$ java -jar jenkins-cli.jar -s http://localhost:8080 restart
あくまでも試してみた感じだと Jenkins CLI でセキュアに Jenkins にアクセスしたい場合には以下を設定したほうが良さそう。
尚、上記の設定を行った場合、Jenkins のジョブの詳細(get-job コマンド)等は以下のように利用出来なくなる。
$ java -jar jenkins-cli.jar -s http://localhost:8080 get-job Docker_Build_Push ERROR: anonymous is missing the Job/ExtendedRead permission
これを解決するには Jenkins に Jenkins CLI を実行するユーザーの公開鍵を Jenkins 上のユーザーに登録することで利用出来るようになる。
上記を設定した後に get-job コマンドを実行すると以下のようにジョブの詳細を確認することが出来る。
$ java -jar jenkins-cli.jar -s http://localhost:8080 get-job Docker_Build_Push <?xml version='1.0' encoding='UTF-8'?> <project> <actions/> <description></description> <keepDependencies>false</keepDependencies> <properties/> <scm class="hudson.scm.NullSCM"/> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders> (snip) </builders> <publishers/> <buildWrappers/> </project>
素敵な Jenkins ライフをお送り下さいmm
変な天気が続く。
眠い。
ニーズがあるかどうか解らないけど...Jenkins を触ってみたくて試してみた。Jenkins の Amazon ECR プラグインとの出会いに身震いした。
こんな感じ。
このサンプルでは以下のようなテストを行う。
以下のプラグインを順不同でインストール。(※ 以下のプラグイン以外でも依存関係で関連するプラグインがインストールされる)
対象となる GitHub リポジトリの設定で Jenkins (GitHub plugin) を追加して Jenkins の Webhook URL を設定する。
尚、Jenkins の Webhook を設定する際に GitHub 側の IP アドレスを制限したい場合には以下のように API を実行して GitHub 側の IP アドレスを確認することが出来る。(Webhook の接続元は hooks
キーの値を利用した)
curl -s https://api.github.com/meta
ビルドにて Docker Build and Publish を選択すると以下のようにレジストリの情報等を入力出来るようになる。
Registry credentials では 事前に Jenkins の「認証情報」に登録しておいた IAM ユーザーの設定を利用する。
PATH="/var/lib/jenkins/.rbenv/bin:$PATH" eval "$(rbenv init -)" cd /var/lib/jenkins/workspace/$JOB_NAME bundle install bundle exec rspec spec/docker_*_spec.rb
ビルドトリガにて「他のプロジェクトの後にビルド」を選択して、対象プロジェクトからジョブ (1) を選択する。
ジョブ (1) の workspace に展開されている Dockerfile を利用してコンテナをビルドしたいので Build Context と Dockerfile Path を下図のように指定する。
特に難しいことは無く、Build Pipeline Plugin 導入後に Jenkins のダッシュボードの Job 一覧にある + をクリックして作成する。
手元で Dockerfile を修正、spec ファイルを修正して push すれば Jenkins 先生がテストを走らせて、テストが合格であれば Dockerfile からコンテナイメージをビルドして Amazon ECR に push するという継続的デリバリー的な何かが動き始める。(これを継続的デリバリーと言うのかは解らないけど...)
そして、以下のように Amazon ECR のリポジトリにコンテナイメージが push されている。
また、Slack なんか絡めるとビルドの成功、失敗も以下のように通知してくれてナウい感じなるんぢゃないかと思ったり。
勉強会の資料作りをしながら、頭によぎったことをダンプする。
上記のブログ記事を読ませて頂いて、とても心動かされたし、自分の中でモヤモヤした迷いが吹っ切れた気がした。
ということで、発表の機会を得ることで、以下のような効果があると考えている。
もちろん、時間的な制約もあり完璧には理解を深めたり、情報の整理をすることは難しいが、その「きっかけ」が得られるという意味でとても有意義なことだと考えている。
当たり前のことかもしれないけど、発表資料は余裕を持って事前に用意するようにしたい。
事前に用意出来ることで読みなおしや、最新情報への対応等も行いやすく、資料自体のクオリティもきっと上がるはずだし、それが聞いてくれる方々への敬意であると考えている。そして、様々な事情で残念ながら、資料が間に合わない、間に合っていないことはネタではなく反省点として次の勉強会に生かすべきだと思う。
繰り返しになるけど、当たり前のことなのかもしれないけど、自戒を込めて文字に起こしてみた。
日々精進。
昨日の日記だけど。