Successfully reported this slideshow.
Your SlideShare is downloading. ×

実は怖くないDevOps

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 57 Ad

実は怖くないDevOps

Download to read offline

DevOpsのOpsに関する話です。
インフラ側は、本番環境やそれに近い環境でテストする事があります。
しかし、開発側と環境が異なる為に、「あの環境でしか起きない」致命的な不具合に遭遇する事がままあります。

プロジェクトをスムースに回し、製品の品質向上に繋げる為には、インフラ側が「いつから」「何に」気を付ければ良いのでしょうか

DevOpsのOpsに関する話です。
インフラ側は、本番環境やそれに近い環境でテストする事があります。
しかし、開発側と環境が異なる為に、「あの環境でしか起きない」致命的な不具合に遭遇する事がままあります。

プロジェクトをスムースに回し、製品の品質向上に繋げる為には、インフラ側が「いつから」「何に」気を付ければ良いのでしょうか

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to 実は怖くないDevOps (20)

Advertisement

Recently uploaded (20)

実は怖くないDevOps

  1. 1. 第29回 TFSUG東京 Visual Studio OnlineでDevOps 実は恐くないOps 2015/10/26 いしがみ まさのり @masanori1102
  2. 2. DevOpsとは • 開発(Development)と運用(Operations)が協力し、ビジネス要 求に対して、より柔軟に、スピーディに対応できるシステム を作り上げるためのプラクティス • 多くの人々により議論は続けられているが、ITILとは異なり、 現時点においては、DevOpsに厳密な定義は無い 特集 DevOps時代の必須知識:いまさら聞けない「DevOps」 (1/2) - @IT http://www.atmarkit.co.jp/ait/articles/1307/02/news002.html
  3. 3. DevOpsとは
  4. 4. DevOpsとは 開発 テスト Dev 開発/ビルド 統合テスト環境 Ops ステージング環境 本番環境
  5. 5. Ops 開発 テスト Dev 開発/ビルド 統合テスト環境 Ops ステージング環境 本番環境
  6. 6. Ops 開発 テスト Dev 開発/ビルド 統合テスト環境 Ops ステージング環境 本番環境 怖くないですか?ココ
  7. 7. Ops テスト 統合テスト環境 ステージング環境 本番環境 無事に、次工程に引き渡せていますか? 前工程に戻っていませんか?
  8. 8. Ops でも、だいたい手戻り出しますよねー(小声)
  9. 9. Ops ソウダヨネー(白目)
  10. 10. Ops 終わっちゃ…ダメだ…
  11. 11. Ops 終わっちゃ…ダメだ…
  12. 12. 何で手戻るの? •Dev : 開発環境では発生しなかったし •Ops : この環境では初めてだったから •All : 早くリリースするから大丈夫
  13. 13. DevOpsとは : 出来てましたか? • 開発(Development)と運用(Operations)が協力し、ビジネス 要求に対して、より柔軟に、スピーディに対応できるシステ ムを作り上げるためのプラクティス • 多くの人々により議論は続けられているが、ITILとは異なり、 現時点においては、DevOpsに厳密な定義は無い 特集 DevOps時代の必須知識:いまさら聞けない「DevOps」 (1/2) - @IT http://www.atmarkit.co.jp/ait/articles/1307/02/news002.html
  14. 14. 分析 •問題点 本番環境でのテスト開始直後に不具合が起こる •提案 本番環境に近い環境で開発段階から、自動テストする •方法 設定の確認に、Serverspecを使う
  15. 15. Serverspec : 概要 •概要 テスト対象サーバーにテストアプリをインストールする必要 が無く、SSHなどを利用して状態を確認する仕組み。 テストは、テストコードを記載したファイルを使う。 •本当の目的 インフラのコードをリファクタリングを手助けする事
  16. 16. Serverspec : 構成 Serverspecインストール済の環境 テスト対象のサーバー テスト(SSHなど経由) テスト結果 テストファイル
  17. 17. Serverspec : テスト対象 •OS • Windows • Linux •環境 • 物理環境 • 仮想環境(VMアプリ、クラウド) • Dockerコンテナ
  18. 18. Serverspec : テスト対象の一部
  19. 19. やってみる
  20. 20. 構成 Microsoft Azure Visual Studio Online Cross platform build Execute test via SSH Test results Test server installed Serverspec Test target Client machine for control
  21. 21. シナリオ 1. Azure上にVMを準備する 2. VSO-Agentを設定する 3. Serverspecを準備する 4. Team Projectを作成する 5. VSO-Agentを実行する
  22. 22. 1. Azure上にVMを準備する 2. VSO-Agentを設定する 3. Serverspecを準備する 4. Team Projectを作成する 5. VSO-Agentを実行する
  23. 23. 1. Azure上にVMを準備する 目的 OS 開けるエンドポイント Serverspec実行 OpenLogic7.1 SSH(22), HTTP(80) テスト対象 CoreOS Stable SSH(22), HTTP(80)
  24. 24. 1. Azure上にVMを準備する VMが出来たら、 SSHでアクセス出来る事をputtyなどで確認する。 # OpenLogic7.1 as Test server installed Serverspec masanori@Serverspec-host.cloudapp.net's password: [masanori@serverspec-host ~]$ # CoreOS stable as Test target masanori@serverspec-work.cloudapp.net's password: CoreOS stable (766.4.0) masanori@serverspec-work ~ $
  25. 25. 1. Azure上にVMを準備する 2. VSO-Agentを設定する 3. Serverspecを準備する 4. Team Projectを作成する 5. VSO-Agentを実行する
  26. 26. 2. VSO-Agentを設定する [~]$ # 準備 [~]$ ## Test server installed Serverspecに準備を施す [~]$ ## Firewallをiptablesへ変更 [~]$ sudo systemctl stop firewalld [~]$ sudo systemctl mask firewalld [~]$ sudo yum install -y iptables-services [~]$ sudo systemctl enable iptables [~]$ sudo systemctl start iptables [~]$ ## Gitをインストールする [~]$ ### 理由 : VSO-AgentからVSO上のリポジトリの取得にGitを利用する為 [~]$ sudo yum install -y git
  27. 27. 2. VSO-Agentを設定する [~]$ # 準備 [~]$ ## Node.jsをインストールする [~]$ ### 理由 : VSO-AgentはNode.js上で動作する為 [~]$ ### 詳細 : https://github.com/nodejs/node-v0.x- archive/wiki/Installing-Node.js-via-package-manager 参照 [~]$ sudo yum install -y gcc-c++ [~]$ sudo yum install -y make [~]$ sudo curl --silent --location https://rpm.nodesource.com/setup | sudo bash - [~]$ sudo yum install -y nodejs
  28. 28. 2. VSO-Agentを設定する [~]$ # VSO-Agentのインストール [~]$ ## 詳細は、https://github.com/Microsoft/vso-agent 参照 [~]$ sudo npm install vsoagent-installer –g [~]$ sudo chown -R $USER /root/.npm [~]$ mkdir myagent [~]$ cd myagent [myagent]$ vsoagent-installer
  29. 29. 1. Azure上にVMを準備する 2. VSO-Agentを設定する 3. Serverspecを準備する 4. Team Projectを作成する 5. VSO-Agentを実行する
  30. 30. 3. Serverspecを準備する [~]$ # Test server installed Serverspecに準備を施す [~]$ ## Rubyがインストールされていない場合は、Rubyをインストールする [~]$ ### 理由 : gemを使って、Serverspecをインストールする為 [~]$ sudo yum -y install gcc zlib-devel openssl-devel sqlite sqlite-devel mysql-devel readline-devel libffi-devel [~]$ cd /usr/local/src [/usr/local/src]$ ### wgetがインストールされていなければ、wgetをインストール する [/usr/local/src]$ sudo yum install wget [/usr/local/src]$ ### 最新版は、https://www.ruby-lang.org/ja/downloads/ を 確認する事 [/usr/local/src]$ sudo wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby- 2.2.3.tar.gz [/usr/local/src]$ sudo tar zxvf ruby-2.2.3.tar.gz [/usr/local/src]$ cd ruby-2.2.3 [/usr/local/src/ruby-2.2.3]$ sudo ./configure [/usr/local/src/ruby-2.2.3]$ sudo make [/usr/local/src/ruby-2.2.3]$ sudo make install
  31. 31. 3. Serverspecを準備する [/usr/local/src/ruby-2.2.3]$ cd ~ [~]$ # Test server installed Serverspecに準備を施す [~]$ ## Rubyがインストールされた事を確認する [~]$ ruby –v ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] [~]$ which ruby /usr/local/bin/ruby [~]$ ## .gemrcを作成する [~]$ vi ~/.gemrc [~]$ ### 以下を追記して、保存する gem: --no-ri --no-rdoc [~]$ ## .bashrcを作成する [~]$ vi ~/.bashrc [~]$ ### 以下を追記して、保存する alias sudo='sudo env PATH=$PATH'
  32. 32. 3. Serverspecを準備する [~]$ # Test server installed Serverspecに準備を施す [~]$ ## ruby-develのインストール [~]$ sudo yum -y install ruby-devel [~]$ ## RubyGemを更新する [~]$ ### 理由 : RubyGemを使って、Serverspecをインストールする為 [~]$ sudo gem update –system [~]$ ## RubyGemを更新した事を確認する [~]$ gem –v 2.4.5.1
  33. 33. 3. Serverspecを準備する [~]$ # Test server installed Serverspecに準備を施す [~]$ ## 各種パッケージをインストールする [~]$ sudo gem install rake [~]$ sudo gem install rails [~]$ sudo gem install bundler [~]$ sudo gem install sqlite3 [~]$ sudo gem install thin [~]$ sudo gem install rspec [~]$ sudo gem install rspec-rails [~]$ sudo gem install cucumber [~]$ sudo gem install cucumber-rails [~]$ sudo gem install webrat [~]$ sudo gem install serverspec [~]$ sudo gem install highline
  34. 34. 3. Serverspecを準備する[~]$ # Test server installed Serverspecに準備を施す [~]$ ## Serverspecの初期化をおこなう [~]$ ### 詳細: http://serverspec.org/ 参照 [~]$ serverspec-init Select OS type: 1) UN*X 2) Windows Select number: 1 Select a backend type: 1) SSH 2) Exec (local) Select number: 1 Vagrant instance y/n: n Input target host name: serverspec-work.cloudapp.net + spec/ + spec/serverspec-work.cloudapp.net/ + spec/serverspec-work.cloudapp.net/sample_spec.rb + spec/spec_helper.rb + Rakefile + .rspec
  35. 35. 3. Serverspecを準備する[~]$ # Test server installed Serverspecに準備を施す [~]$ vi spec/serverspec-work.cloudapp.net/sample_spec.rb require 'spec_helper‘ describe package('httpd'), :if => os[:family] == 'redhat' do it { should be_installed } end describe package('apache2'), :if => os[:family] == 'ubuntu' do it { should be_installed } end describe service('httpd'), :if => os[:family] == 'redhat' do it { should be_enabled } it { should be_running } end describe service('apache2'), :if => os[:family] == 'ubuntu' do it { should be_enabled } it { should be_running } end describe service('org.apache.httpd'), :if => os[:family] == 'darwin' do it { should be_enabled } it { should be_running } end describe port(22) do it { should be_listening } end describe port(80) do it { should be_listening } end
  36. 36. 3. Serverspecを準備する[~]$ # とりあえず、実行してみる [~]$ rake spec /usr/bin/ruby rspec spec/serverspec-work.cloudapp.net/sample_spec.rb /usr/bin/ruby -I/usr/local/share/gems/gems/rspec-core- 3.3.2/lib:/usr/local/share/gems/gems/rspec-support-3.3.0/lib /usr/local/share/gems/gems/rspec- core-3.3.2/exe/rspec --pattern spec/serverspec-work.cloudapp.net/*_spec.rb Enter sudo password: masanori@serverspec-work.cloudapp.net's password: …
  37. 37. 3. Serverspecを準備する[~]$ # とりあえず、実行してみる Port “22“ should be listening Port ”80“ should be listening (FAILED - 1) Failures: 1) Port "80" should be listening On host `serverspec-work.cloudapp.net‘ Failure/Error: it { should be_listening } expected Port "80" to be listening sudo -p 'Password: ' /bin/sh -c netstat -tunl | grep -- :80 # ./spec/serverspec-work.cloudapp.net/sample_spec.rb:31:in `block (2 levels) in <top (required)>‘ Finished in 0.25522 seconds (files took 8.62 seconds to load) 2 examples, 1 failure Failed examples: rspec ./spec/serverspec-work.cloudapp.net/sample_spec.rb:31 # Port "80" should be listening
  38. 38. 3. Serverspecを準備する[~]$ # とりあえず、実行してみる [~]$ rake spec /usr/bin/ruby rspec spec/serverspec-work.cloudapp.net/sample_spec.rb /usr/bin/ruby -I/usr/local/share/gems/gems/rspec-core- 3.3.2/lib:/usr/local/share/gems/gems/rspec-support-3.3.0/lib /usr/local/share/gems/gems/rspec- core-3.3.2/exe/rspec --pattern spec/serverspec-work.cloudapp.net/*_spec.rb Enter sudo password: masanori@serverspec-work.cloudapp.net's password: # あ、パスワード聞かれた…
  39. 39. 1. Azure上にVMを準備する 2. VSO-Agentを設定する 3. Serverspecを準備する 4. Team Projectを作成する 5. VSO-Agentを実行する
  40. 40. 4. Team Projectを作成する https://www.visualstudio.com/ にアクセスして、サインインする
  41. 41. 4. Team Projectを作成する Recent projects & teamsでNewを選択する
  42. 42. 4. Team Projectを作成する 注意点 リポジトリにGitを選択する
  43. 43. 4. Team Projectを作成する 以下の内容を記載したファイルを登録する。 # run_serverspec.sh #!/bin/sh rake spec /usr/bin/ruby rspec /home/masanori/spec/serverspec- work.cloudapp.net/sample_spec.rb
  44. 44. 4. Team Projectを作成する
  45. 45. 1. Azure上にVMを準備する 2. VSO-Agentを設定する 3. Serverspecを準備する 4. Team Projectを作成する 5. VSO-Agentを実行する
  46. 46. 5. VSO-Agentを実行する Visual Studio OnlineとXcodeを連携する方法 Xcode側準備 編 #tfsug #xcode http://changesworlds.com/2015/07/how-to- cooperation-of-visual-studio-online-and-xcode-xcode- side-setup-guide/ を参考に
  47. 47. 5. VSO-Agentを実行する [~]$ node agent/vsoagent Enter alternate username > [Alternate authenthication credentials]で設定し たUser name Enter alternate password > [Alternate authenthication credentials]で設定し たPassword Enter server url > [あなたのVisual Studio OnlineのURL] e.g. https://sample.visualstudio.com/ Enter agent name (enter sets xxxx) > Enter agent pool name (enter sets default) > successful connect as あなたの名前
  48. 48. 5. VSO-Agentを実行する Agent poolに追加されました
  49. 49. 5. VSO-Agentを実行する 仕掛けておいたビルド が開始されました
  50. 50. 出来た事 構成に関するテストをServerspecで出来た
  51. 51. まとめ : 動かすまで 1. 設定したら、確認しましょう バージョン、ポートetc. 2. VSOで動かす前に、どう動いているかを確認しましょう 3. コードはコミットしましょう
  52. 52. まとめ : 動かすまで 1. 設定したら、確認しましょう バージョン、ポートetc. 2. VSOで動かす前に、どう動いているかを確認しましょう 3. コードはコミットしましょう ん?これって…
  53. 53. まとめ : 動かすまで アプリ作る時と同じですね
  54. 54. まとめ : Serverspecで変わる事 1. インフラに対するテストを始めやすくなる 2. CI出来るのは、アプリや設定だけじゃなく、インフラも
  55. 55. まとめ : Serverspecで変わる事 インフラのリファクタリングが進んで、 製品の品質が上がりますね(ニッコリ
  56. 56. 資料 • 開発と運用の新しい関係、「DevOps」とは何か? - Publickey http://www.publickey1.jp/blog/11/devops.html • DevOps時代に運用側が果たすべき三つの役割 - [1]溝が深まる開発と運用:Itpro http://itpro.nikkeibp.co.jp/article/COLUMN/20131030/514962/

Editor's Notes

  • 以下の図を抜粋した

    Enterprise DevOps
    http://www.microsoft.com/click/services/Redirect2.ashx?CR_EAC=300144365
  • この図は、1回の開発サイクルの内、DevとOpsの割り当てがどのようになっているかを示したものです。
    開発サイクルの前の方にDev、後ろの方にOpsがいますね。

    あなたは開発(Dev)と運用(Ops)のどちらに属していますか?
    また、あなたの属しないチームの役割を知っていますか?
  • 今回は、Opsについてのお話です。
    赤枠の部分について、考えましょう。

    さて、この図で、「怖い」箇所が1か所あります。
  • この赤枠の部分、毎回成功しますか?
  • 身も蓋も無い事を言ってしまいました。
  • こんな事を言うかも知れません。

    DevもOpsも言う事は事実だし、早くリリースするのは大事だから

    でも、
  • 最初に挙げた、DevOpsの定義で、
    目的を成し遂げる為に、協力し、より良くする
    と書かれていたのを思い出しましょう

    DevとOps、それぞれの言い分で、より良くする為の何か正しい方法について述べていましたか?
  • http://serverspec.org/
  • SSH, WinRM, Docker APIなどによって確認できます
  • SSH, WinRM, Docker APIなどによって確認できます
  • ざっくりと
  • 一例です
  • やってみましたよ
  • ざっくりと
  • ざっくりと
  • まず、クラウド(Microsoft Azure)上に仮想マシン(VM)を準備します。
  • ざっくりと
  • 参考資料
    Rubyを最新ソースからインストール | CentOSサーバ構築術 文具堂
    http://centos.bungu-do.jp/archives/000294.html
  • 参考資料
    WindowsマシンにUbuntuをインストールしてRails開発を始めるには - Rails 雑感 - Ruby on Rails with OIAX
    http://www.oiax.jp/rails/zakkan/ubuntu-and-rails-on-windows.html
  • 参考資料
    Rails3備忘録: 仮想環境にCentOSを入れてRails開発環境を構築する手順
    http://rails3beginner.blogspot.jp/2012/02/centosrails.html

    WindowsマシンにUbuntuをインストールしてRails開発を始めるには - Rails 雑感 - Ruby on Rails with OIAX
    http://www.oiax.jp/rails/zakkan/ubuntu-and-rails-on-windows.html
  • 参考資料
    Rails3備忘録: 仮想環境にCentOSを入れてRails開発環境を構築する手順
    http://rails3beginner.blogspot.jp/2012/02/centosrails.html

    Serverspec - Home
    http://serverspec.org/
  • 参考資料
    Serverspec - Home
    http://serverspec.org/
  • 参考資料
    Serverspec - Home
    http://serverspec.org/

    Port 22は、足しました
  • 参考資料
    Serverspec - Home
    http://serverspec.org/
  • 参考資料
    Serverspec - Home
    http://serverspec.org/
  • 参考資料
    Serverspec - Home
    http://serverspec.org/
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • ざっくりと
  • 私は、開発側です

×