Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Gradle SSH Plugin
Search
Hidetake Iwata
June 20, 2014
Technology
0
220
Gradle SSH Plugin
わいわいGroovy ~ 教えてG*小ネタ大会!
https://jggug.doorkeeper.jp/events/11365
Hidetake Iwata
June 20, 2014
Tweet
Share
More Decks by Hidetake Iwata
See All by Hidetake Iwata
Rewrite Go error handling using AST transformation
int128
1
1.2k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.6k
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
int128
7
7.1k
CLIでOAuth/OIDCを快適に利用する
int128
0
680
AppEngine × Spring Boot × Kotlin
int128
0
79
いつものJIRA設定
int128
1
150
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.6k
本番環境のリリースを自動化した話
int128
0
670
Swagger × Spring Cloud
int128
0
80
Other Decks in Technology
See All in Technology
忙しい人のためのLangGraph概要まとめ
__ymgc__
1
190
JTCや セキュリティチェックリストが夢の跡
nikinusu
1
660
どこよりも遅めなWinActor Ver.7.5.0 新機能紹介
tamai_63
0
210
App Router を実プロダクトで採用して見えてきた勘所をちょっとだけ紹介
marokanatani
1
930
リアルお遍路+SORACOM IoT
ozk009
1
140
Swift Testingのconfirmationを コードリーディング/Dive into Swift Testing confirmation
laprasdrum
2
260
やってやろうじゃないかメカアジャイル! / Let's do it, mechanical agile!
psj59129
1
670
『GRANBLUE FANTASY Relink』キャラクターの魅力を支えるリグ・シミュレーション制作事例
cygames
0
120
ナレッジグラフとLLMの相互利用
koujikozaki
0
420
Google CloudのLLM活用の選択肢を広げるVertex AIのパートナーモデル
nayuts
0
130
社内の学びの場・コミュニティ形成とエンジニア同士のリレーションシップ構築/devreljapan2024
nishiuma
3
290
グイグイ系QAマネージャーの仕事
sadonosake
0
340
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
25
3.9k
Facilitating Awesome Meetings
lara
49
6k
Six Lessons from altMBA
skipperchong
26
3.4k
How STYLIGHT went responsive
nonsquared
93
5.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
5
480
Music & Morning Musume
bryan
46
6k
Raft: Consensus for Rubyists
vanstee
135
6.5k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
The Brand Is Dead. Long Live the Brand.
mthomps
53
38k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Teambox: Starting and Learning
jrom
131
8.7k
Building an army of robots
kneath
302
42k
Transcript
Gradle SSH Plugin @int128 #jggug
はじめに 5分ぐらいで Gradle SSH Pluginを紹介します。 http://gradle-ssh-plugin.github.io @int128 Groovy and Scala
Programmer Certified ScrumMaster
どうやって デプロイしてますか?
どうやってデプロイしてますか? アプリをサーバにデプロイする方法 ➔ 手順書 ➔ シェルスクリプト ➔ Capistrano ➔ Maven
➔ Ant ➔ Gradle
Gradleからデプロイできると 便利ですよね
Gradleからデプロイするメリット 使い慣れたツールでビルドからデプロイまでをシー ムレスに記述できます ビルドやデプロイの設定を一元管理することでメン テナンスの無駄がなくなります JavaVMさえ入っていればすぐにデプロイできます (Gradle Wrapperのおかげ)
Gradle SSH Pluginとは GradleでSSHを使うためのプラグイン ➔ Gradleとの統合 ➔ コマンド実行やファイル転送 ➔ 標準入出力とのインタラクション
➔ パスワード、公開鍵、ssh-agentによる認証 ➔ 踏み台サーバやプロキシを経由した接続
使用例1: アプリのデプロイ Gradleでビルドした成果物 (JARやWAR) をサー バに配置する例 1. ビルドしてWARファイルを生成 2. WebサーバにWARファイルを配置
3. プロセスを再起動
apply plugin: 'war' apply plugin: 'ssh' remotes { webServer {
host = '192.168.1.101' user = 'jenkins' } } task deploy(type: SshTask, dependsOn: war) { session(remotes.webServer) { put war.archivePath, '/webapps' execute 'sudo service tomcat restart' } } Webサーバを定義 WebサーバにWARをデプロイ WARファイルを配置し、Tomcatサービスを再起動 プラグインを適用 warタスクの後にdeployタスクを実行
例2: SSHオペレーションの自動化 ネットワーク機器 (Cisco Catalyst) から設定を取 得してファイルに保存する例 1. ネットワーク機器にSSHで接続 2.
特権モードに移行 3. パスワードを入力 4. 現在の設定を取得 5. 終了
task backupConfig(type: SshTask) { session(remotes.switch01) { file('config.txt').withWriter { writer ->
shell { interaction { when(partial: ~/.*>/) { standardInput << 'terminal length 0\n' standardInput << 'enable\n' when(partial: /Password: /) { standardInput << enablePassword << '\n' when(partial: ~/.*#/) { standardInput << 'show run\n' when(partial: ~/.*[#>]/) { standardInput << 'exit\n' } when(line: _) { line -> writer << line << '\n' } } } パスワードを入力 プロンプトが出現したらコマンドを入力 show runコマンドを入力 プロンプトが出現したらexitコマンドを入力 プロンプト以外の標準出力をファイルに保存 ネットワーク機器の設定を取得
まとめ Gradle SSH Pluginを使用することで、 使い慣れたGradleでビルドからデプロイまでを シームレスに実現できます デプロイだけでなく、SSHオペレーションの 自動化全般に使用できます
おまけ:アーキテクチャ プロダクト ➔ Groovy 1.8(Gradle 1.xに同梱) ➔ JSch テスト ➔
Spock ➔ Apache MINA SSHD server 受け入れテスト ➔ Travis CI ◆ localhostにSSH接続してテストを実行