Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_virtualmachine not create VM with multi NICs #26755

Closed
bronco0 opened this issue Jul 13, 2017 · 9 comments · Fixed by #38994
Closed

azure_rm_virtualmachine not create VM with multi NICs #26755

bronco0 opened this issue Jul 13, 2017 · 9 comments · Fixed by #38994
Labels
affects_2.3 This issue/PR affects Ansible v2.3 azure bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:certified This issue/PR relates to certified code.

Comments

@bronco0
Copy link

bronco0 commented Jul 13, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_virtualmachine

ANSIBLE VERSION
2.3.1.0
CONFIGURATION

Nope

OS / ENVIRONMENT

Linux Ubuntu 16.10 Yaketty
Linux Debian 8 Jessy

SUMMARY

Is not possible to create a VM with more than one NIC.
The azure_rm_virtualmachine module return error.

STEPS TO REPRODUCE
  1. Getting Started with Azure
    Follow this page https://docs.ansible.com/ansible/guide_azure.html

  2. Run this playbook

- name: Create Azure VM
  hosts: localhost
  connection: local
  tasks:
    - name: Create storage account
      azure_rm_storageaccount:
        resource_group: RGtest2
        name: 'jonstorage01'
        account_type: Standard_LRS
    
    - name: Create virtual network
      azure_rm_virtualnetwork:
        resource_group: RGtest2
        name: 'jon-vn'
        address_prefixes: "10.1.0.0/16"
    
    - name: Add subnet
      azure_rm_subnet:
        resource_group: RGtest2
        name: 'jon-subnet1'
        address_prefix: "10.1.0.0/24"
        virtual_network: 'jon-vn'

    - name: Add subnet2
      azure_rm_subnet:
        resource_group: RGtest2
        name: 'jon-subnet2'
        address_prefix: "10.1.1.0/24"
        virtual_network: 'jon-vn'

    - name: Create public ip
      azure_rm_publicipaddress:
        resource_group: RGtest2
        allocation_method: Static
        name: 'jon-public-ip'
    
    - name: Create security group that allows SSH
      azure_rm_securitygroup:
        resource_group: RGtest2
        name: 'jon-securitygroup-ssh'
        rules:
          - name: SSH
            protocol: Tcp
            destination_port_range: 22
            access: Allow
            priority: 101
            direction: Inbound

    - name: Create security group all denied
      azure_rm_securitygroup:
        resource_group: RGtest2
        name: 'jon-securitygroup-alldenied'

    - name: Create NIC
      azure_rm_networkinterface:
        resource_group: RGtest2
        name: 'jon-nic1'
        virtual_network: 'jon-vn'
        subnet: 'jon-subnet1'
        public_ip_name: 'jon-public-ip'
        security_group: 'jon-securitygroup-ssh'

    - name: Create NIC02
      azure_rm_networkinterface:
        resource_group: RGtest2
        name: 'jon-nic2'
        virtual_network: 'jon-vn'
        subnet: 'jon-subnet2'
        public_ip: no
        security_group: 'jon-securitygroup-alldenied'

    - name: Create virtual machine
      azure_rm_virtualmachine:
        resource_group: RGtest2
        name: 'jon-vm'
        vm_size: Standard_D1
        storage_account: 'jonstorage01'
        storage_container: 'jon-vm'
        storage_blob: 'jon-vm01.vhd'
        admin_username: Ansible
        admin_password: Password99!
        network_interfaces: [ 'jon-nic1', 'jon-nic2' ]
        image:
          offer: Debian
          publisher: credativ
          sku: '8'
          version: latest
EXPECTED RESULTS

Create VM.

ACTUAL RESULTS

Error, the VM is not created.
Problem with Primary property for network interfaces.

TASK [Create virtual machine] ********************************************************************************************************************************
task path: /home/jon/test/azure/azure.yml:88
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/azure/azure_rm_virtualmachine.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jon
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "ad_user": null, 
            "admin_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "admin_username": "Ansible", 
            "allocated": true, 
            "append_tags": true, 
            "client_id": null, 
            "image": {
                "offer": "Debian", 
                "publisher": "credativ", 
                "sku": "8", 
                "version": "8.0.201706210"
            }, 
            "location": null, 
            "name": "jon-vm", 
            "network_interface_names": [
                "jon-nic1", 
                "jon-nic2"
            ], 
            "network_interfaces": [
                "jon-nic1", 
                "jon-nic2"
            ], 
            "open_ports": null, 
            "os_disk_caching": "ReadOnly", 
            "os_type": "Linux", 
            "password": null, 
            "profile": null, 
            "public_ip_allocation_method": "Static", 
            "remove_on_absent": [
                "all"
            ], 
            "resource_group": "RGtest2", 
            "restarted": false, 
            "secret": null, 
            "short_hostname": null, 
            "ssh_password_enabled": true, 
            "ssh_public_keys": null, 
            "started": true, 
            "state": "present", 
            "storage_account": "jonstorage01", 
            "storage_account_name": "jonstorage01", 
            "storage_blob": "jon-vm01.vhd", 
            "storage_blob_name": "jon-vm01.vhd", 
            "storage_container": "jon-vm", 
            "storage_container_name": "jon-vm", 
            "subnet_name": null, 
            "subscription_id": null, 
            "tags": null, 
            "tenant": null, 
            "virtual_network_name": null, 
            "vm_size": "Standard_D1"
        }
    }, 
    "msg": "Error creating or updating virtual machine jon-vm - Azure Error: NetworkInterfaceMustHavePrimaryPropertySet\nMessage: Network interface jon-nic1 must have Primary property set."
}
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Error creating or updating virtual machine jon-vm - Azure Error: NetworkInterfaceMustHavePrimaryPropertySet\nMessage: Network interface jon-nic1 must have Primary property set."}
bronco0 pushed a commit to bronco0/ansible that referenced this issue Jul 13, 2017
@ansibot
Copy link
Contributor

ansibot commented Jul 13, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 azure bug_report cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Jul 13, 2017
@calfonso calfonso removed the needs_triage Needs a first human triage before being processed. label Jul 13, 2017
bronco0 pushed a commit to bronco0/ansible that referenced this issue Jul 18, 2017
…e NICs (# 26755).

Adding the 'network_interface_primary' parameter to define which network interface will be primary when creating a vm with multiple NICs.

The class 'NetworkInterfaceReference' of the azure SDK already allows to take account of this parameter 'primary'.
I just modified the 'network_interfaces' list to a list of tuples with the network interface id and a boolen defining the interface as primary or not.

Fix for (ansible#26755)
@trstringer
Copy link
Contributor

We can use pull request #26887 to discuss.

@ansibot ansibot added support:certified This issue/PR relates to certified code. and removed support:curated labels Aug 16, 2017
@ansibot
Copy link
Contributor

ansibot commented Oct 4, 2017

@ansibot
Copy link
Contributor

ansibot commented Nov 5, 2017

@ansibot
Copy link
Contributor

ansibot commented Nov 21, 2017

cc @yuwzho
click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Jan 16, 2018

@kyliel
Copy link
Contributor

kyliel commented Jan 31, 2018

Since #32882 merged and covered multiple NIC, can we close this one? @yuwzho

@yuwzho
Copy link
Contributor

yuwzho commented Jan 31, 2018

@kyliel no, #32882 is NIC with multiple ip configuration, this is about vm with multiple NIC.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
spmp pushed a commit to spmp/ansible that referenced this issue Apr 19, 2018
…primary set to True, and all other nics have primary set to False.
@spmp
Copy link
Contributor

spmp commented Apr 19, 2018

Fix in pr 38994

yungezz pushed a commit that referenced this issue Apr 26, 2018
…38994)

* Fix #26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this issue May 12, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this issue May 14, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this issue May 14, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this issue May 15, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this issue May 15, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
yuwzho pushed a commit to VSChina/ansible that referenced this issue May 28, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
ilicmilan pushed a commit to ilicmilan/ansible that referenced this issue Nov 7, 2018
…rimary (ansible#38994)

* Fix ansible#26755 by ensuring that the first nic in the nic list has primary set to True, and all other nics have primary set to False.

* Fix sanity issues and add test for two nics

* Fix typo in test

* fix nic list

* Ensure the niclist variable is used rather than a niclist string

* Add tests just for dual nic, reverting changes to single nic VM creation tests

* Correct idempotency test
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 azure bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:certified This issue/PR relates to certified code.
Projects
None yet
7 participants