Skip to content

Instantly share code, notes, and snippets.

@tsubakimoto
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubakimoto/c389925be109239532d6 to your computer and use it in GitHub Desktop.
Save tsubakimoto/c389925be109239532d6 to your computer and use it in GitHub Desktop.

Azure の管理証明書を作る

Visual Studio 開発者ツールで以下を入力

makecert -r -pe -n CN=azure-cert -sky exchange azure.cer -sv azure.pvk

pvk2pfx -pvk azure.pvk -spc azure.cer -pfx azure.pfx

OpenSSL をインストールして以下を入力

openssl pkcs12 -in azure.pfx -out azure.pem -nodes

vagrant-azure プラグインの導入

vagrant plugin install vagrant-azure

Vagrant で Azure を起動

vagrant up --provider=azure

西日本リージョンに Windows Server 2012 R2 を最小構成で作成する Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "azure"
  config.vm.box_url = "https://github.com/msopentech/vagrant-azure/raw/master/dummy.box"
  config.vm.provider :azure do |azure|
      azure.mgmt_certificate = 'azure-cert.pem'
      azure.mgmt_endpoint = 'https://management.core.windows.net'
      azure.subscription_id = 'YOUR AZURE SUBSCRIPTION ID'
      azure.vm_image = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201411.01-en.us-127GB.vhd'
      azure.vm_location = 'Japan West'
      azure.vm_size = 'ExtraSmall' # ExtraSmall,Small,Medium,Large,ExtraLarge,A6,A7
      azure.vm_user = 'vagrant'
      azure.vm_password = 'PROVIDE A VALID PASSWORD'
      azure.vm_name = 'vagrant-test-01'
      azure.cloud_service_name = 'vagrant-test-01'
      azure.tcp_endpoints = '3389:53389' # IISにアクセスするなら'80,3389:53389'
  end
end

Azure の仮想マシンに Ansible からアクセスする準備

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "azure"
  config.vm.box_url = "https://github.com/msopentech/vagrant-azure/raw/master/dummy.box"
  config.vm.provider :azure do |azure|
      azure.mgmt_certificate = 'azure-cert.pem'
      azure.mgmt_endpoint = 'https://management.core.windows.net'
      azure.subscription_id = 'YOUR AZURE SUBSCRIPTION ID'
      azure.vm_image = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201411.01-en.us-127GB.vhd'
      azure.vm_location = 'Japan West'
      azure.vm_size = 'ExtraSmall'
      azure.vm_user = 'vagrant'
      azure.vm_password = 'PROVIDE A VALID PASSWORD'
      azure.vm_name = 'vagrant-test-01'
      azure.cloud_service_name = 'vagrant-test-01'
      azure.winrm_transport = [ 'http', 'https' ]
      azure.tcp_endpoints = '3389:53389'
  end
end

PowerShell

Set-NetConnectionProfile -InterfaceAlias (Get-NetConnectionProfile -IPv4Connectivity Internet).InterfaceAlias -NetworkCategory Private
iex ((new-object net.webclient).DownloadString('https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))

hosts

[windows]
vagrant-test-01.cloudapp.net

[windows:vars]
ansible_ssh_user=vagrant
ansible_ssh_pass=(PROVIDE A VALID PASSWORD)
ansible_ssh_port=5986
ansible_connection=winrm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment