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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hiyokotaisa
June 30, 2018
Technology
7
6.8k
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
300
Interact 2019 -OP01: ひよこでもわかるAnsible AnsibleによるAzure構成管理
hiyokotaisa
3
3k
RHTN: Ansible 2.8 x Windows
hiyokotaisa
1
4.2k
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
スピンアウト講座04_ルーティン処理
overflowinc
0
1.2k
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
190
Why we keep our community?
kawaguti
PRO
0
220
脳が溶けた話 / Melted Brain
keisuke69
1
1k
MCPで決済に楽にする
mu7889yoon
0
100
契約書からの情報抽出を行うLLMのスループットを、バッチ処理を用いて最大40%改善した話
sansantech
PRO
2
260
「捨てる」を設計する
kubell_hr
0
250
Kiroで見直す開発プロセスとAI-DLC
k_adachi_01
0
130
スピンアウト講座03_CLAUDE-MDとSKILL-MD
overflowinc
0
1.3k
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
230
AIエージェント勉強会第3回 エージェンティックAIの時代がやってきた
ymiya55
0
120
The Rise of Browser Automation: AI-Powered Web Interaction in 2026
marcthompson_seo
0
310
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2.3k
How to make the Groovebox
asonas
2
2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Accessibility Awareness
sabderemane
0
84
The Curse of the Amulet
leimatthew05
1
10k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
240
Navigating Weather and Climate Data
rabernat
0
150
YesSQL, Process and Tooling at Scale
rocio
174
15k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
From π to Pie charts
rasagy
0
160
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
280
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!