Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Interact 2019 -OP01: ひよこでもわかるAnsible Ansibleによる...
Search
hiyokotaisa
June 29, 2019
Technology
3.1k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Interact 2019 -OP01: ひよこでもわかるAnsible AnsibleによるAzure構成管理
2019年6月29日に開催されたInteract 2019のスライド資料です。
hiyokotaisa
June 29, 2019
More Decks by hiyokotaisa
See All by hiyokotaisa
JTF2020 C1: テクニカルサポートエンジニアという働き方
hiyokotaisa
2
15k
RHTN - 5分でわかるAnsible TowerのSSO
hiyokotaisa
0
320
RHTN: Ansible 2.8 x Windows
hiyokotaisa
1
4.6k
Twitter転職でなってみたグローバルサポートエンジニア
hiyokotaisa
1
2.4k
インフラ勉強会にみるコミュニティへの「貢献」
hiyokotaisa
2
3.1k
Red Hat Tech Night 2018: Ansible x Network Ansibleで実践するネットワーク自動化
hiyokotaisa
1
1.4k
AnsibleではじめるWindows自動化
hiyokotaisa
7
6.9k
Other Decks in Technology
See All in Technology
今さら理解するウェブフォントver.2026
takanorip
2
300
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
200
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
17
120k
AI時代に必要な脅威モデリング― 変化の速度に負けない理解とリスク判断
masakane55
5
1.2k
並行性の問題を防げ!実践トランザクション入門
occhi
0
280
OR学会2026年秋期大会_機械学習と数理最適化の融合による、配合レシピ最適化システム開発事例
brainpadpr
0
110
購入ドメインでの課題と取り組み
ykagano
0
150
AI時代だからこそ推したい!Gitコマンド再入門
munakata
0
160
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
1
320
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
検証フェーズはAIの回答を判断するための学習機会
toru_kubota
2
530
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
410
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
300
RailsConf 2023
tenderlove
30
1.6k
Automating Front-end Workflow
addyosmani
1369
210k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Bash Introduction
62gerente
615
220k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
510
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
So, you think you're a good person
axbom
PRO
2
2.2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
910
Transcript
Interact 2019 Ansible による Azure 構成管理 ひよこでもわかる Ansible Kento Yagisawa
(@hiyoko_taisa) Technical Support Engineer Red Hat 1 ×
自己紹介 Agenda 2 八木澤 健人 (やぎさわ けんと) ITエンジニア 7年目 (昨年3月にTwitter転職しました)
Ansible Engine / Ansible Tower のテクニカルサポートをしています @hiyoko_taisa https://github.com/hiyokotaisa
本日のおしながき Agenda 3 1. Ansibleのおさらい 2. Azureのおさらい 3. AnsibleからAzureを操作する 4.
Dynamic Inventoryを活用してみる 5. Ansible Tower(AWX)からAzureを活用する
What is Ansible? 4 のおさらい
Ansibleとは? What is Ansible 5 • Red Hatとコミュニティが開発している構成管理ツール • 学習コストの低いYAML形式のPlaybook
• 冪等性(べきとうせい)を保った変更 • 多種多様な環境に対応 (Linux/Windows/Network/etc…) • エージェントレス • 最新バージョンは2.8.1
Ansibleの動作イメージ What is Ansible 6 SSH / WinRM / etc...
Ansibleの動作イメージ What is Ansible 7 Inventory host_A host_B ... Playbook
test.yml 1. スクリプトを転送 host_A 3.結果を返却 Connection Plugin Modules 2.実行
What is Azure? 8 のおさらい
Azureとは? What is Azure? 9 • Microsoftが提供するパブリッククラウドプラットフォーム • 100を超えるサービス ◦
Azure Virtual Maches ◦ Azure SQL Database ◦ Azure Cosmos DB ◦ Azure Active Directory(Azure AD) ◦ etc...
What is Azure? 10
Managing Azure from Ansible 11 から を操作する
Azureを操作するとは? Managing Azure from Ansible 12 • Azure上のリソース管理 → azure_rm_*
モジュール • Azure VM上のインスタンスに接続 → Dynamic Inventory
Azure関連モジュール Managing Azure from Ansible 13 146 モジュール (2019年6月29日時点)
Managing Azure from Ansible 14
事前準備 Managing Azure from Ansible 15 • 実行するノードにAzure SDK Moduleをインストール
https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html ※ Azure Cloud ShellからもAnsibleを実行できる Azure Cloud Shell の概要 https://docs.microsoft.com/ja-jp/azure/cloud-shell/overview $ pip install 'ansible[azure]'
事前準備 Agenda 16 • Azure用の認証情報 ◦ Service Principalを利用 https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal ◦
ADのユーザー名/パスワード ※2FAは利用不可
Service Principal Agenda 17 • 必要な認証情報 Client ID Tenant ID
Secret Key Subscription ID
Agenda 18
Agenda 19
Agenda 20
Agenda 21
Agenda 22
Agenda 23
Agenda 24
認証情報を定義する Agenda 25 • 下記のどれかに定義 ◦ 環境変数 ◦ Playbook内の各taskのパラメーター ◦
ファイルに定義
環境変数に定義する Agenda 26 • AZURE_CLIENT_ID • AZURE_SECRET • AZURE_SUBSCRIPTION_ID •
AZURE_TENANT
Task内のパラメーターに定義する Agenda 27 - name: Power Off azure_rm_virtualmachine: resource_group: myResourceGroup
name: testvm002 started: no client_id: xxxxxx secret: xxxx subscription_id: xxxx tenant: xxxx
ファイルに定義する(検証用) Agenda 28 • $HOME/.azure/credentials [default] subscription_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx secret=xxxxxxxxxxxxxxxxx tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Managing Azure from Dynamic Inventory 29 VMインスタンスを つくってみよう
azure_rm_storageaccount Agenda 30 • ストレージアカウントを作成する azure_rm_storageaccount: resource_group: Testing name: hiyokotest
account_type: Standard_LRS
azure_rm_virtualnetwork Agenda 31 • Virtual Networkを作成する azure_rm_virtualnetwork: resource_group: Testing name:
testvn001 address_prefixes: "10.10.0.0/16"
azure_rm_subnet Agenda 32 • Virtual NetworkにSubnetを作成する azure_rm_subnet: resource_group: Testing name:
subnet001 address_prefix: "10.10.0.0/24" virtual_network: testvn001
azure_rm_publicipaddress Agenda 33 • Public IP addressを作成する azure_rm_publicipaddress: resource_group: Testing
allocation_method: Static name: publicip001
azure_rm_securitygroup Agenda 34 • セキュリティグループを作成する azure_rm_securitygroup: resource_group: Testing name: secgroup001
rules: - name: SSH protocol: Tcp destination_port_range: 22 access: Allow priority: 101 direction: Inbound
azure_rm_networkinterface Agenda 35 • NICを作成する azure_rm_networkinterface: resource_group: Testing name: testnic001
virtual_network: testvn001 subnet: subnet001 public_ip_name: publicip001 security_group: secgroup001
azure_rm_virtualmachine Agenda 36 • VMの作成・削除・起動・停止などができる azure_rm_virtualmachine: resource_group: Testing name: testvm
vm_size: Standard_D1_v2 admin_username: test ssh_password_enabled: false image: offer: CentOS publisher: OpenLogic sku: '7.6' version: latest
Inventoryファイルをつくる Agenda 37 • hosts localhost ansible_connection=local
Playbookをつくる Agenda 38 • createvm.yml --- - hosts: localhost vars:
tasks: - name: Create storage account azure_rm_storageaccount: resource_group: Testing name: hiyokotest account_type: Standard_LRS - name: Create virtual network azure_rm_virtualnetwork: ...
Managing Azure from Dynamic Inventory 39
Managing Azure from Dynamic Inventory 40 Dynamic Inventory を活用してみる
Dynamic Inventoryとは? What is Ansible 41 • インベントリ情報をAPIから動的に取得する • 実体はPythonスクリプト
• AWS/Azure/vCenter/OpenStackなど https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html
なにがうれしい? What is Ansible 42 • 都度かわるインスタンス情報をスマートに管理できる (いちいちインベントリを書き換えなくてよい) • 既存のインベントリ管理ソースを使える(vCenterとか)
azure_rm.py What is Ansible 43 • Azure VM向けDynamic Inventory https://github.com/ansible/ansible/blob/devel/contrib/inventory/azure_rm.py
• 設定ファイルは azure_rm.ini https://github.com/ansible/ansible/blob/devel/contrib/inventory/azure_rm.ini
Dynamic Inventoryを指定する What is Ansible 44 • 通常のインベントリと指定方法は同じ $ ansible-playbook
-i azure_rm.py createvm.yml
Managing Azure from Ansible Tower (AWX) 45 から を活用する
Ansible Towerとは? What is Ansible 46 • Red Hatが開発するAnsible用オーケストレーションツール •
Web UIによる管理 • 権限管理(RBAC) • Git等のVCSとの統合 • ワークフローの作成
AWXとは? What is Ansible 47 • Ansible Tower のアップストリームプロジェクト •
最新の機能が導入され、安定したものがAnsible Towerへ • コンテナ環境必須 • エンタープライズな環境にはAnsible Towerがオススメ
なにがうれしい? What is Ansible Tower? 48 • 認証情報やPlaybookを一元管理できる • 実行結果を一元管理できる
• 強力な権限管理 • LDAPやSSOによるユーザー管理 • Splunk等へのexternal logging • virtualenvを使って複数のAnsibleバージョンを 共存させられる
Managing Azure from Dynamic Inventory 49
What is Ansible Tower! 50 Towerのデモ (動くように祈りましょう)
Ansible Lightbulb What is Ansible Tower? 51 • 各種教材やデモ用のリソース https://github.com/ansible/lightbulb
Ansibleもくもく会でも同様の教材を使っています もくもく会にも遊びにきてください!
52 Ansibleで Happy Automation!
CONFIDENTIAL Designator linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHat Red Hat is the
world’s leading provider of enterprise open source software solutions. Award-winning support, training, and consulting services make Red Hat a trusted adviser to the Fortune 500. Thank you 53
Managing Azure from Dynamic Inventory 54 おまけ
Ansible 2.8 x Windows 55 Ansible 2.8で追加された新機能 • Connection PluginにSSHを指定可能
(Experimental Support) • 新モジュール: ◦ win_user_profile ◦ win_partition ◦ win_psrepository
Ansible 2.8 x Windows 56 ようこそSSH! (ベータだけど)
Ansible 2.8 x Windows 57 従来: WinRMによる接続 • HTTPS/HTTPベースの独自プロトコル •
ansible_connection: winrm を指定する • Remote Management Serviceの有効化などの事前設定が必要 WinRM(WS-Management) HTTPS / HTTP Windows
Ansible 2.8 x Windows 58 SSHによる接続 • Linux/Unixなどで広く使われてきたプロトコル • WinRMと比較してオーバーヘッドが少ない
• ansible_connection: ssh を指定する • Windows側にOpenSSHのインストールが必要 Win32-OpenSSH SSH Windows
Ansible 2.8 x Windows 59 SSH接続手順 1. Win32-OpenSSHのインストール 参考: https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH
2. sshd_configの設定変更 (必要に応じて) PATH: %programdata%\ssh\sshd_config 3. ansible_shell_type を指定 ( cmd | powershell ) Windows側のDefault Shell設定と一致している必要がある (デフォルトはcmd.exe) 注意事項: v7.9.0.0p1-Betaより以前のバージョンのOpenSSHは、 ansible_shell_type: powershell を指定できない。 (Windows Server 2019に同梱されているOpenSSHなど)
Ansible 2.8 x Windows 60 Win32-OpenSSHのインストール Win32-OpenSSHのインストールは、ChocolateyもしくはAnsible GalaxyのRoleからも実行可能 $ ansible-galaxy
install jborean93.win_openssh 参考: https://galaxy.ansible.com/jborean93/win_openssh
Ansible 2.8 x Windows 61 Playbook
Ansible 2.8 x Windows 62 実行結果
Ansible 2.8 x Windows 63 SSHで接続していることが読み取れる
Ansible 2.8 x Windows 64 参考資料 • Windows SSH Setup
- Ansible https://docs.ansible.com/ansible/2.8/user_guide/windows_setup.html#windows-ssh-setup • Win32-OpenSSH https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH • Galaxy Role https://galaxy.ansible.com/jborean93/win_openssh