As mention on subject,I want to configure azure module in ansible, also find out azure module in github but i don't not how to setup, please help me to install and configure.
问题:
回答1:
you need to install
sudo pip install azure==0.11.1
(newest azure version > 1.0 not compatible with ansible yet here is github issue https://github.com/ansible/ansible-modules-core/pull/2114)Now you need to create Storage_account in the azure console(and later specify it in the playbook)
Generate ssh key for VM
openssl req -x509 -key ~/.ssh/id_rsa -nodes -days 365 -newkey rsa:2048 -out ~/.ssh/ssh_key.pem
- Give owner-only permissions for generated key
chmod 600 ~/.ssh/ssh_key.pem
Upload this certificate to your azure subscription. I did it via node azure-cli
yum install npm or apt-get install npm
nsudo npm install -g azure-cli
azure account download
downloading your subscription file by displayed link.
azure account import <path to downloaded file>
Export manage certificate for your subscription
azure account cert export -f ~/.ssh/manage.cer
Also I needed to get VM image name via azurecli because I could not find it in the azure console.
azure vm image list | grep CentOS
then you need to write playbook which will launch azure VM:
- local_action:
module: azure
name: 'vm_name'
role_size: Small
image: '5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-67-20150815'
password: 'some_pass'
location: 'East US 2'
user: admin
wait: yes
subscription_id: 'some subscription'
management_cert_path: '~/.ssh/manage.cer'
storage_account: 'some account'
endpoints: '22,8080,80'
register: azure_vm
- add_host:
name: '{{ azure_vm.public_dns_name }}'
- name: wait when instance become ready to use
wait_for:
host: '{{ azure_vm.public_dns_name }}'
port: "22"
delay: "60"
timeout: "320"
state: "started"
This playbook will create Centos6 machine with admin
user and password
. Currently I could not create machine with ssh-key authentication. I'm keep getting msg: password parameter is required for new instance
UPDATED: Fixed certificate generation procedure.