如何使用ansible在azure中添加磁盘

时间:2015-10-21 18:38:44

标签: azure azure-storage ansible ansible-playbook

我们使用此模块(http://docs.ansible.com/ansible/azure_module.html)在azure上创建了实例。但是它没有显示如何添加额外的VHD磁盘。有没有办法用ansible在azure中添加磁盘?

1 个答案:

答案 0 :(得分:0)

   vars:

        vm2:
            - name: azu-ve109456
              network_interface:
                  name: azu-eu-west-subnet-a-ni-ve108456
              vm_size: Standard_DS1_v2
              username: ubuntu

  - name: Create VM
    azure_rm_virtualmachine:
      resource_group: NAME
      name: "{{ item.name }}"
      vm_size: "{{ item.vm_size }}"
      admin_username: "{{ item.username }}"
      ssh_password_enabled: false
      ssh_public_keys:
        - path: "/home/{{ item.username }}/.ssh/authorized_keys"
          key_data: "ssh-rsa AAAABxxxxxxgxYN"
      network_interfaces: "{{ item.network_interface.name }}"
      image:
          offer: UbuntuServer
          publisher: Canonical
          sku: 16.04-LTS
          version: latest
      managed_disk_type: Premium_LRS
      data_disks:
          - lun: 0
            disk_size_gb: 64
            managed_disk_type: Premium_LRS
          - lun: 1
            disk_size_gb: 128
            managed_disk_type: Premium_LRS
          - lun: 2
            disk_size_gb: 128
            managed_disk_type: Premium_LRS

      with_items: "{{ vm2 }}"