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
習慣とAIと環境 — 技術探求を続ける3つの鍵
azukiazusa1
2
690
Data Intelligence on Lakehouse Paradigm
scotthsieh825
0
180
Databricks Free Edition講座 データエンジニアリング編
taka_aki
0
2.7k
持続可能な開発のためのミニマリズム
sansantech
PRO
3
420
GitHub Copilot CLI 現状確認会議
torumakabe
10
3.2k
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
340
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
950
エンジニアとして長く走るために気づいた2つのこと_大賀愛一郎
nanaism
0
200
[Iceberg Meetup #4] ゼロからはじめる: Apache Icebergとはなにか? / Apache Iceberg for Beginners
databricksjapan
0
280
Hardware/Software Co-design: Motivations and reflections with respect to security
bcantrill
1
210
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
12k
Java 25に至る道
skrb
3
230
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
200
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
290
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
110
How Software Deployment tools have changed in the past 20 years
geshan
0
31k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Music & Morning Musume
bryan
46
7k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Designing Experiences People Love
moore
143
24k
Mind Mapping
helmedeiros
PRO
0
53
Six Lessons from altMBA
skipperchong
29
4.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
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!