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
AnsibleではじめるWindows自動化
Search
hiyokotaisa
June 30, 2018
Technology
7
6.6k
AnsibleではじめるWindows自動化
Interact 2018でお話ししたAnsibleによるWindows自動化のセッション資料です。
hiyokotaisa
June 30, 2018
Tweet
Share
More Decks by hiyokotaisa
See All by hiyokotaisa
JTF2020 C1: テクニカルサポートエンジニアという働き方
hiyokotaisa
2
15k
RHTN - 5分でわかるAnsible TowerのSSO
hiyokotaisa
0
250
Interact 2019 -OP01: ひよこでもわかるAnsible AnsibleによるAzure構成管理
hiyokotaisa
3
2.8k
RHTN: Ansible 2.8 x Windows
hiyokotaisa
1
4k
Twitter転職でなってみたグローバルサポートエンジニア
hiyokotaisa
1
2.2k
インフラ勉強会にみるコミュニティへの「貢献」
hiyokotaisa
2
3k
Red Hat Tech Night 2018: Ansible x Network Ansibleで実践するネットワーク自動化
hiyokotaisa
1
1.3k
Other Decks in Technology
See All in Technology
アジャイル脅威モデリング#1(脅威モデリングナイト#8)
masakane55
3
230
ガバクラのAWS長期継続割引 ~次の4/1に慌てないために~
hamijay_cloud
1
280
ここはMCPの夜明けまえ
nwiizo
28
10k
LLM as プロダクト開発のパワードスーツ
layerx
PRO
1
240
持続可能なドキュメント運用のリアル: 1年間の成果とこれから
akitok_
1
200
SmartHR プロダクトエンジニア求人ガイド_2025 / PdE job guide 2025
smarthr
0
130
Devinで模索する AIファースト開発〜ゼロベースから始めるDevOpsの進化〜
potix2
PRO
8
3.5k
Dynamic Reteaming And Self Organization
miholovesq
3
590
更新系と状態
uhyo
7
1.7k
AWSで作るセキュアな認証基盤with OAuth mTLS / Secure Authentication Infrastructure with OAuth mTLS on AWS
kaminashi
0
180
Writing Ruby Scripts with TypeProf
mame
0
250
Porting PicoRuby to Another Microcontroller: ESP32
yuuu
4
440
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
135
33k
Agile that works and the tools we love
rasmusluckow
328
21k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
530
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Speed Design
sergeychernyshev
29
900
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.2k
Producing Creativity
orderedlist
PRO
344
40k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Gamification - CAS2011
davidbonilla
81
5.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Transcript
Windows x Ansible Ansible ではじめる Windows 自動化 Interact 2018 |
June. 30th, 2018
Interact 2018 2 ひよこ大佐 テクニカルサポートエンジニア 3月にTwitter転職しました Twitter: @hiyoko_taisa blog :
http://hiyoko-infratech.hateblo.jp/ 自己紹介
Interact 2018 3 1. Ansibleとは 2. Windowsを管理しよう 3. トラブルシュート 本日のおしながき
Interact 2018 4 1. Ansibleの概要 2. Windowsを管理する上での基礎知識 3. トラブルシュートの基礎知識 本セッションでわかること
突然ですが……
Ansibleを使ったことがある人?
その中で…… AnsibleでWindowsを管理している人?
AnsibleはWindowsの管理でも 活躍します!
その前に…… Ansible とは?
Interact 2018 10 Ansibleとは? Red Hatとコミュニティで開発している構成管理ツール • 最新版はAnsible 2.6 (2018/6/29
リリース) • コミュニティ版とRed HatがサポートするAnsible Engine • 自動化オーケストレーションツールのAnsible Tower
Interact 2018 11 Ansibleの利点 • 学習コストの低いYAML形式のPlaybook • べき等性を保った変更 • シンプルかつ柔軟な拡張が可能
• コミュニティでの開発・拡張が活発 • 多種多様な環境をコントロール(Linux/Windows/Network機器)
Interact 2018 12 Ansible Playbookのサンプル --- - name: Add a
user hosts: all gather_facts: false tasks: - name: Add User win_user: name: ansible password: "@ns1bl3" state: present https://github.com/ansible/ansible-examples/blob/master/windows/create-user.yml
Interact 2018 13 Ansibleの接続イメージ SSH / WinRM
Interact 2018 14 Ansibleの構造 Inventory host_A host_B Playbook test.yml 1.
スクリプトを転送 host_A 3.結果を返却 Connection Plugin Modules 2.実行
Interact 2018 15 AnsibleでWindowsを管理するメリット • WindowsでもInfrastructure as Codeを実践 • Linuxサーバーと同時に自動化(統一化された管理)
Windows を管理しよう!
Interact 2018 17 必要なもの 事前準備 Playbook 作成 実行
Interact 2018 18 事前準備 ▪ Ansible側 • pywinrmのパッケージの導入 Playbookには…… •
ansible_connection: winrm を指定 • ansible_winrm_transportを指定
Interact 2018 19 Windows Serverを管理する ansible_winrm_transportで指定可能な認証方式
Interact 2018 20 Windows Serverを管理する ▪ Windows側 • Powershell 3.0以上
( Windows 7 SP1 / Windows Server 2008 SP1以上 ) • WinRM(Windows Remote Management)の有効化 • 自動でWindowsホストで必要な準備を実行するPowershellも (ConfigureRemotingForAnsible.ps1) https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotin gForAnsible.ps1
Interact 2018 21 Windows Module • 80を超えるWindows Module • 現在も増え続けている
Interact 2018 22 便利なWindows Module • win_domain_user Active Directoryのユーザを管理 win_domain_user:
name: bob firstname: Bob surname: Smith password: B0bP4ssw0rd state: present domain_username: DOMAIN\admin-account domain_password: SomePas2w0rd domain_server:
[email protected]
Interact 2018 23 便利なWindows Module • win_package パッケージのインストール/アンインストール • ネットワーク上のパッケージも取得可能
win_package: path: http://download.microsoft.com/.../vcredist_x64.exe product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}' arguments: /install /passive /norestart
Interact 2018 24 便利なWindows Module • win_updates Windows Updateの実行 -
name: Install only particular updates based on the KB numbers win_updates: category_name: - SecurityUpdates whitelist: - KB4056892 - KB4073117
トラブルシューティング
Interact 2018 26 確認するべきポイント • pywinrmのバージョン(最新版への更新) • WinRMサービスの状態 • WinRM
Configの確認 • Debugログから原因を追跡
Interact 2018 27 WinRMのトラブルシューティング ▪ WinRMの設定の問題か切り分ける • 他のWindowsマシンからWinRM接続を試してみる # test
out HTTP winrs -r:http://server:5985/wsman -u:Username -p:Password ipconfig # test out HTTPS (will fail if the cert is not verifiable) winrs -r:http://server:5985/wsman -u:Username -p:Password -ssl ipconfig
Interact 2018 28 WinRMのトラブルシューティング ▪ WinRMの設定確認 > winrm get winrm/config
Interact 2018 29 winrm/configの出力結果
Interact 2018 30 Debug出力の確認 WinRMのConnection含む詳細な出力を確認可能 $ ansible-playbook -i inventory all
test.yml -vvvvv
Interact 2018 31 事例: HTTP 401/Credentials Rejected • HTTP 401
エラーの場合、接続時の認証で失敗している • 認証情報が正しいか • ユーザがlocal Administrator groupに属するユーザであること • ansible_winrm_transport で指定した認証方法が、 Service\Auth\下でEnableになっていること • Basic認証をADのユーザーに対して指定していないか • 関連するpythonパッケージを更新
Interact 2018 32 事例: HTTP 500 Error • WinRMサービスに問題がある •
サービス再起動など
Interact 2018 33 事例: Timeout • FirewallがWinRMのListenerポートをブロックしていないか • WinRMサービスが起動しているか •
ネットワークで問題が発生していないか • 負荷の高いタスクで発生する場合、Timeout値を伸ばしてみる ansible_winrm_operation_timeout_sec ansible_winrm_read_timeout_sec
THANK YOU!