Top Banner
リリースとPowerShell かめがわ かずし(@kkamegawa)
40

PowerShell and Release Management Server

Jun 22, 2015

Download

Technology

Introduct to PowerShell DSC and Release Management Server.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: PowerShell and  Release Management Server

リリースとPowerShellかめがわかずし(@kkamegawa)

Page 2: PowerShell and  Release Management Server

自己紹介亀川 和史(かめがわかずし) / 会社員

Twitter:@kkamegawaFacebook:https://www.facebook.com/kkamegawa/

Microsoft MVP for Visual Studio ALM(2012/7~)

@ITさんでちょこちょこ書かせていただいています。現在:アプリの運用監視サービスとは? New Relic vs. Application Insights http://www.atmarkit.co.jp/ait/articles/1410/06/news145.html

はじめてのTeam Foundation Server 現在発売中http://www.shuwasystem.co.jp/products/7980html/4046.html

Page 3: PowerShell and  Release Management Server

PowerShell成分かなり薄めですほかの特濃セッションで補充してください

Page 4: PowerShell and  Release Management Server

Agenda

リリース振り返り

リリース方式について

PowerShell DSCとRelease Management Serverを使った活用

Page 5: PowerShell and  Release Management Server

やることとやらないことやること PowerShell DSCとRelease Managementを使ったリリースの承認フロー

やらないこと PowerShell DSCの詳細 PowerShellの基礎文法 TFSとはといった情報

Page 6: PowerShell and  Release Management Server

リリースを自動化している?

Page 7: PowerShell and  Release Management Server

手作業リリース

リリース職人の手による伝統

完璧な手順書 チェックシート

リリース日フォルダに整理

一部スクリプト エビデンスをExcel貼り付け

Page 8: PowerShell and  Release Management Server

手作業のどこが悪い?

職人じゃないとできない

手順書の日本語レビューになりがち

チェックしづらい作業がある

新規環境作る時多くのパッチ適用

スクリプト実行手順失敗の可能性

作業完了までに時間かかる

Page 9: PowerShell and  Release Management Server

よろしい、ならば自動化だ

OS設定 パッチ 再起動

追加設定 発行(インストール)

(アプリ固有の)設定変更

Page 10: PowerShell and  Release Management Server

リリースの難しさ

リリースの責任者は?

え、知らなかった!

ステージングと本番

リリースする根拠は?

自動化のテスト

リリース検証

Page 11: PowerShell and  Release Management Server

リリース方式いろいろStaging(検証)環境なし。すべてが本番 Facebook(ただし、特定の人のみに機能をONするといった仕組みはある)

https://www.facebook.com/publications/514128035341603/http://wazanova.jp/items/724 (日本語概要)

自己責任でデプロイ Cookpad などのGitを使っている企業に多い(?)

https://speakerdeck.com/mirakui/cookpads-deployment-and-auto-scalinghttp://www.publickey1.jp/blog/14/110jaws_day_2014_1.html

リリース承認制顧客の依頼を受けて開発する場合多い

Page 12: PowerShell and  Release Management Server

リリースの自己責任方式

リリース用 本番

開発者 開発者

開発者 開発者

ユーザ

コミット コミット

コミット コミット

Page 13: PowerShell and  Release Management Server

リリースの組織方式

リリース用

開発者 リーダー 品質管理

本番

ユーザ

コミット

確認

承認

承認

デプロイ

Page 14: PowerShell and  Release Management Server

どっちが好き?

Page 15: PowerShell and  Release Management Server

自己責任方式 承認方式

Page 16: PowerShell and  Release Management Server

リリースワークフロー好き嫌いは別にして、承認フローを通してリリースしたい要件もある。客先作業自分が信用できないテストも承認フローの一部として組み込まれている

Visual Studioから担当者の裁量で発行は楽だけど、台数多くなると…

承認ワークフローでも自動化の恩恵は必要QAの人が自動化を組めるとは限らないむしろできない前提

Page 17: PowerShell and  Release Management Server

Release Management Serverリリース作業に承認フローを提供するソフトウェア

もともとInCycle Softwareという会社のTFS拡張機能(TFSがあるとビルド時にリリーストリガを設定可能)

Visual Studio 2013リリースのタイミングでMicrosoftに部門買収されて、Visual Studio 2013の一部分となる

Visual Studio 2013 Update 3でPowerShell DSCをサポート

複数台のデプロイもサポートPowerShell DSCを使えばエージェントなくてもいい

Page 18: PowerShell and  Release Management Server

PowerShellでリリーススクリプト作れば?「設定の手順」を自分で考えてPowerShellで作る必要がある

スクリプト自身のテストも大変まっさらの環境用意してOSパッチ当てて各種ソフト入れて順番に設定変更…デバッグ…

Install-WindowsFeature (略)$exe = new-object system.diagnostics.Process$exe.StartInfo.FileName = “¥¥server¥share¥build¥22222¥drop¥hoge.msi";$exe.StartInfo.Arguments=“/Silent”$exe.Start()$exe.WaitForExit()

Page 19: PowerShell and  Release Management Server

PowerShell DSCで何とか救おうDSC = Desired State Configuration

「あるべき設定」を定義して、あっていないところを自動的に更新する→(ある)べき→冪等制

@guitarrapc_tech さんの連載と資料を見るといいよ!http://www.atmarkit.co.jp/ait/articles/1405/22/news131.html

PowerShell DSCのサーバとしてWindows Server 2012 R2が必要クライアントにはWindows Management Framework(PowerShell込) 4.0があるといい(エージェントとどっちを入れるのがいい?)http://www.microsoft.com/ja-jp/download/details.aspx?id=40855→もちろん PowerShell !

Page 20: PowerShell and  Release Management Server

Release Management Serverの構成

デプロイ先

TFS Webサーバ

Release ManagementWebサーバ

SQL Server(Express可)

DomainController

クライアント

PowerShell DSCサーバ

Release Management Agentインストール

Page 21: PowerShell and  Release Management Server

Release Managementのリリース構成標準と vNextの構成の二種類

サーバ、リリースパス、環境それぞれ別に設定

別な理由は使用するインフラの差標準:WinRM→Release Management ServerがコントロールvNext:ChefやPowerShell DSC→外部のインフラに依存(承認ワークフローのみ提供)

Page 22: PowerShell and  Release Management Server

PowerShell DSC と Release Management

PowerShell DSC サーバが必要になる代わりに、Release Management Agentが不要になるただし、Windows Management Framework 4.0が必要なので、Windows Server 2012 R2/Windows 8.1より前のOSでは注意

PowerShell DSCサーバはほかと兼用でもOKTFS WebサーバとPowerShell DSCとRelease Management Server共存させるSQL Serverも同一環境で実行可能今回の構成では全部入りちなみにChefも使えます

Page 23: PowerShell and  Release Management Server

オンプレミスとクラウドAzure対応済み。Azureへのデプロイ時に必要な情報サブスクリプションIDストレージアカウント管理証明書(拡張子publishsettingsに含まれている長いあれ)

オンプレミスActive Directoryがほぼ必須(アカウントやTFS連携で必要)デプロイも認証がからむと難しい

Page 24: PowerShell and  Release Management Server

ステージの設定

任意のステージを追加可能

Page 25: PowerShell and  Release Management Server

提供コマンド

Page 26: PowerShell and  Release Management Server

リリース対象サーバ

エージェント有無

Page 27: PowerShell and  Release Management Server

ビルドパスの定義

TFSのビルド定義を指定

Page 28: PowerShell and  Release Management Server

Azureへのリリース承認も同じUI

Page 29: PowerShell and  Release Management Server

ビルドをトリガーにしてリリースRelease Management Serverの以下の場所にあるビルドテンプレートを

Visual Studioから追加%ProgramFiles(x86)%¥Visual Studio 12.0¥Release Management¥bin

接続するTFSのバージョンによって指定するビルドテンプレートが変わるので注意 TFS 2013 Git:ReleaseGitTemplate.12.xaml TFVC:TfvcTemplate.12.xaml TFS 2012:ReleaseDefaultTemplate.11.1.xaml TFS 2010:ReleasedefaultTemplate.xaml

Page 30: PowerShell and  Release Management Server

ビルドトリガを設定するときの注意点「ビルドからリリースをトリガーできますか?」にチェックがあるかどうか

ビルド定義が正しいか確認

ステージで受け入れと配置手順が「自動」に設定されていないとリリースは開始されないので注意

TFSビルドサーバにRMクライアントがない

配置完了までにデフォルトの10分が経過した

※リリーステンプレートの名前変更できないので注意

Page 31: PowerShell and  Release Management Server

ビルドをトリガーにしてリリース(VS)

ビルド定義にリリースターゲットを

指定

Tokenは特定の機能を持つデプロイ用に振り分

けるために使う

Page 32: PowerShell and  Release Management Server

標準のリリーステンプレート

従来のVBScriptなどで手続き書くのと変わらな

Page 33: PowerShell and  Release Management Server

vNextのリリーステンプレート

Chefと標準(DSCのこと)の選択のみ

Page 34: PowerShell and  Release Management Server

リリース承認

承認フロー

Page 35: PowerShell and  Release Management Server

最終的なリリース承認

Page 36: PowerShell and  Release Management Server

PowerShell DSCを使う前に実行前にはWinRMを有効にして、信頼するホストを設定

Set-Item wsman:¥localhost¥Client¥TrustedHosts -Value * -Force (全ホストを信頼)

PowerShell Resource Kit(現在Wave7)にいろんなモジュールが登録されている。 Technet Galleryから入手

https://gallery.technet.microsoft.com/DSC-Resource-Kit-All-c449312d以下のフォルダに展開

64bit版:%ProgramFiles%¥WindowsPowerShell¥Modules※:Hyper-Vもあるけど、おそらくWindows Server 2008 R2では使えない(名前空間非互換のため)

Import-DscResourceコマンドレットで使用する例:import-DscResource –Module xWebAdministration

Page 37: PowerShell and  Release Management Server

本日の環境(オンプレミス)

デプロイ先Release ManagementTFS + SQL Server Windows 8.1 Domain

Controller

ThinkPad T440p(8core 16GB 480GB SSD)

Page 38: PowerShell and  Release Management Server

本日の環境(Azure on IaaS)

デプロイ先Azure Basic A2

Release Management +TFS + SQL Server

Azure Basic A3(4core 7GB RAM 10GB Data HDD)

• Azure ADなしのぬるい環境• SQL Serverイメージ使うと高いので、SQL ServerはMSDNのライセンスで持ち込み。検証ならExpressでもOK

• ISOイメージの持ち込みではまった(Add-AzureVHDコマンドレットで容量固定VHDをアップロード)

• レポートなど動いてない機能がある

Page 39: PowerShell and  Release Management Server

まとめリリースにワークフローが必要な場合は便利

環境作成結構大変なので、燃え尽きないように

PowerShell DSCやChef使えばリリースフローから依存性を切り離せてよい

PowerShell DSCはアドホックなインストールスクリプトのデバッグから解放してくれる(かも)

とりあえず @guitarrapc_tech さんをフォローしておこう

Page 40: PowerShell and  Release Management Server

参考資料 How to trigger deployments to Chef managed environments from Release Management 2013 with

Update 3 RChttp://blogs.msdn.com/b/visualstudioalm/archive/2014/07/08/how-to-trigger-deployments-to-chef-managed-environment-from-release-management.aspx How to deploy to Standard or Azure environments in Release Management 2013 with Update 3 RC

http://blogs.msdn.com/b/visualstudioalm/archive/2014/07/07/how-to-deploy-to-standard-or-azure-environments-in-release-management-2013-with-update-3-rc.aspx Release Management Update 3 CTP1 is now available with DSC Deployment Feature!

http://blogs.msdn.com/b/visualstudioalm/archive/2014/05/22/release-management-for-microsoft-visual-studio-2013-with-update-3-ctp1-is-live.aspx How to modify the TFS 2013 default build process template (GitTemplate.12.xaml &

TfvcTemplate.12.xaml) to enable releasing from a buildhttp://blogs.msdn.com/b/visualstudioalm/archive/2013/12/09/how-to-modify-the-build-process-template-to-use-the-option-trigger-release-from-build.aspx リリース管理を使用したリリースの管理

http://msdn.microsoft.com/ja-jp/library/dn217874.aspx PowerShell DSCで始めるWindowsインフラストラクチャ自動化の基本

http://www.atmarkit.co.jp/fwin2k/operation/indexpage/index.html#powershelldsc