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.7k
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
290
Interact 2019 -OP01: ひよこでもわかるAnsible AnsibleによるAzure構成管理
hiyokotaisa
3
3k
RHTN: Ansible 2.8 x Windows
hiyokotaisa
1
4.1k
Twitter転職でなってみたグローバルサポートエンジニア
hiyokotaisa
1
2.3k
インフラ勉強会にみるコミュニティへの「貢献」
hiyokotaisa
2
3.1k
Red Hat Tech Night 2018: Ansible x Network Ansibleで実践するネットワーク自動化
hiyokotaisa
1
1.4k
Other Decks in Technology
See All in Technology
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
63k
AI に「学ばせ、調べさせ、作らせる」。Auth0 開発を加速させる7つの実践的アプローチ
scova0731
0
330
たかがボタン、されどボタン ~button要素から深ぼるボタンUIの定義について~ / BuriKaigi 2026
yamanoku
1
290
【Oracle Cloud ウェビナー】ランサムウェアが突く「侵入の隙」とバックアップの「死角」 ~ 過去の教訓に学ぶ — 侵入前提の防御とデータ保護 ~
oracle4engineer
PRO
1
170
AWS Network Firewall Proxyで脱Squid運用⁈
nnydtmg
1
120
善意の活動は、なぜ続かなくなるのか ーふりかえりが"構造を変える判断"になった半年間ー
matsukurou
0
610
クラウドセキュリティの進化 — AWSの20年を振り返る
kei4eva4
0
140
Master Dataグループ紹介資料
sansan33
PRO
1
4.2k
Eight Engineering Unit 紹介資料
sansan33
PRO
0
6.3k
AI アクセラレータチップ AWS Trainium/Inferentia に 今こそ入門
yoshimi0227
1
280
なぜCREを8年間続けているのか / cre-camp-4-2026-01-21
missasan
0
140
GitHub Copilot CLI 現状確認会議
torumakabe
8
2.8k
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
30 Presentation Tips
portentint
PRO
1
190
Automating Front-end Workflow
addyosmani
1371
200k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
88
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
560
How to build a perfect <img>
jonoalderson
1
4.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Why Our Code Smells
bkeepers
PRO
340
58k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
180
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
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!