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

[Automated Integration]Merge Azure module changes from Ansible repo #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions files/sha.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lib/ansible/module_utils/azure_rm_common.py": "52a665e224a82b09cb26436d29a753dc8f7facad",
"lib/ansible/modules/cloud/azure": "dfc023209fc7460c449b2e97feb1b5e6d79d1491",
"lib/ansible/module_utils/azure_rm_common.py": "926e423690162b3bdf3ab255b0d50f0a9ae48e1a",
"lib/ansible/modules/cloud/azure": "abad4fbf5e01d1d9bb443a4612dd8677c42298c7",
"packaging/requirements/requirements-azure.txt": "68fa03138c719377b754dc1bbd083529297d38b3",
"test/integration/targets": "ff53ca76b83d151fb05ba0c69def6089dc893135"
"test/integration/targets": "222b6dec8af9834d041c9287bdf7758fd86d1c4f"
}
2 changes: 1 addition & 1 deletion library/_azure_rm_applicationsecuritygroup_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationSecurityGroups/MyAsg"
location:
description:
- Loation of the application security group.
- Location of the application security group.
type: str
returned: always
sample: eastus
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_automationaccount_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
limit:
description:
- Max limit, C(-1) for unlimited.
type: long
type: int
returned: always
sample: -1
name:
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_cdnendpoint_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
sample: xxxxxxxx.blob.core.windows.net
origin_path:
description:
- A directory path on the origin that CDN can use to retreive content from.
- A directory path on the origin that CDN can use to retrieve content from.
type: str
sample: /pic/
tags:
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_containerregistry_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
credentials:
description:
- Credentials, fields will be empty if admin user is not enabled for ACR.
return: when C(retrieve_credentials) is set and C(admin_user_enabled) is set on ACR
returned: when C(retrieve_credentials) is set and C(admin_user_enabled) is set on ACR
type: complex
contains:
username:
Expand Down
3 changes: 1 addition & 2 deletions library/_azure_rm_deployment_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
- The identifier of the resource.
returned: always
type: str
sample: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/myD
eployment"
sample: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Resources/deployments/myDeployment"
resource_group:
description:
- Resource group name.
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_devtestlabvirtualmachine_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
- Virtual machine expiration date.
returned: always
type: str
sample: 2029-02-22T01:49:12.117974Z
sample: "2029-02-22T01:49:12.117974Z"
image:
description:
- Gallery image reference.
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_hdinsightcluster_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
description:
- The list of roles in the cluster.
type: list
suboptions:
contains:
name:
description:
- The name of the role.
Expand Down
4 changes: 2 additions & 2 deletions library/_azure_rm_lock_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
description:
- ID of the resource where need to manage the lock.
- Get this via facts module.
- Cannot be set mutal with I(resource_group).
- Cannot be set mutual with I(resource_group).
- Manage subscription if both I(managed_resource_id) and I(resource_group) not defined.
- "'/subscriptions/{subscriptionId}' for subscriptions."
- "'/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups."
Expand All @@ -41,7 +41,7 @@
description:
- Resource group name where need to manage the lock.
- The lock is in the resource group level.
- Cannot be set mutal with I(managed_resource_id).
- Cannot be set mutual with I(managed_resource_id).
- Query subscription if both I(managed_resource_id) and I(resource_group) not defined.
- Can get all locks with 'child scope' in this resource group, use the I(managed_resource_id) in response for further management.
type: str
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_managed_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
disk_size_gb: 4

- name: Delete managed disk
azure_rm_manage_disk:
azure_rm_manageddisk:
name: mymanageddisk
location: eastus
resource_group: myResourceGroup
Expand Down
10 changes: 5 additions & 5 deletions library/_azure_rm_resource_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
allowExtensionOperations:
description:
- Specifies whether extension operations should be allowed on the virtual machine.
- This may only be set to False when no extentions are present on the virtual machine.
- This may only be set to False when no extensions are present on the virtual machine.
type: bool
returned: always
sample: true
Expand All @@ -176,7 +176,7 @@
sample: myVM
requireGuestProvisionSignale:
description:
- Specifies the host require guest provision siganl or not.
- Specifies the host require guest provision signal or not.
type: bool
returned: always
sample: true
Expand All @@ -188,7 +188,7 @@
sample: []
linuxConfiguration:
description:
- Specifies the Linux operatiing system settings on the virtual machine.
- Specifies the Linux operating system settings on the virtual machine.
type: dict
returned: when OS type is Linux
sample: {
Expand All @@ -203,14 +203,14 @@
sample: Succeeded
vmID:
description:
- Specifies the VM unique ID whic is a 128-bits identifier that is encoded and stored in all Azure laaS VMs SMBIOS.
- Specifies the VM unique ID which is a 128-bits identifier that is encoded and stored in all Azure laaS VMs SMBIOS.
- It can be read using platform BIOS commands.
type: str
returned: always
sample: "eb86d9bb-6725-4787-a487-2e497d5b340c"
storageProfile:
description:
- Specifies the storae account type for the managed disk.
- Specifies the storage account type for the managed disk.
type: complex
returned: always
contains:
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_roleassignment_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
returned: always
sample: myRoleAssignment
type:
descripition:
description:
- Type of role assignment.
type: str
returned: always
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_roledefinition_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
options:
scope:
description:
- The scope of role defintion.
- The scope of role definition.
required: True
id:
description:
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_securitygroup_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
"securityRules": []
}
tags:
descripition:
description:
- Tags to assign to the security group.
returned: always
type: dict
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_servicebus_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
sample: 1
count_details:
description:
- Message count deatils.
- Message count details.
returned: always
type: complex
contains:
Expand Down
2 changes: 1 addition & 1 deletion library/_azure_rm_storageaccount_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def list_resource_group(self):
def list_all(self):
self.log('List all items')
try:
response = self.storage_client.storage_accounts.list_by_resource_group(self.resource_group)
response = self.storage_client.storage_accounts.list()
except Exception as exc:
self.fail("Error listing all items - {0}".format(str(exc)))

Expand Down
1 change: 0 additions & 1 deletion library/_azure_rm_subnet_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
- The type of the endpoint service.
returned: always
type: str
required: True
sample: Microsoft.Sql
locations:
description:
Expand Down
99 changes: 88 additions & 11 deletions library/_azure_rm_virtualmachine_scaleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@
type: bool
default: True
version_added: "2.9"
plan:
description:
- Third-party billing plan for the VM.
version_added: "2.10"
type: dict
suboptions:
name:
description:
- Billing plan name.
required: true
product:
description:
- Product name.
required: true
publisher:
description:
- Publisher offering the plan.
required: true
promotion_code:
description:
- Optional promotion code.
zones:
description:
- A list of Availability Zones for your virtual machine scale set.
Expand Down Expand Up @@ -257,6 +278,36 @@
caching: ReadWrite
managed_disk_type: Standard_LRS

- name: Create VMSS with an image that requires plan information
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 3
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: adminUser
ssh_password_enabled: false
ssh_public_keys:
- path: /home/adminUser/.ssh/authorized_keys
key_data: < insert yor ssh public key here... >
managed_disk_type: Standard_LRS
image:
offer: cis-ubuntu-linux-1804-l1
publisher: center-for-internet-security-inc
sku: Stable
version: latest
plan:
name: cis-ubuntu-linux-1804-l1
product: cis-ubuntu-linux-1804-l1
publisher: center-for-internet-security-inc
data_disks:
- lun: 0
disk_size_gb: 64
caching: ReadWrite
managed_disk_type: Standard_LRS

- name: Create a VMSS with a custom image
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
Expand Down Expand Up @@ -453,7 +504,10 @@ def __init__(self):
overprovision=dict(type='bool', default=True),
single_placement_group=dict(type='bool', default=True),
zones=dict(type='list'),
custom_data=dict(type='str')
custom_data=dict(type='str'),
plan=dict(type='dict', options=dict(publisher=dict(type='str', required=True),
product=dict(type='str', required=True), name=dict(type='str', required=True),
promotion_code=dict(type='str'))),
)

self.resource_group = None
Expand Down Expand Up @@ -487,6 +541,7 @@ def __init__(self):
self.single_placement_group = None
self.zones = None
self.custom_data = None
self.plan = None

required_if = [
('state', 'present', [
Expand Down Expand Up @@ -733,10 +788,6 @@ def exec_module(self, **kwargs):
self.log("Create virtual machine scale set {0}".format(self.name))
self.results['actions'].append('Created VMSS {0}'.format(self.name))

# Validate parameters
if not self.admin_username:
self.fail("Parameter error: admin_username required when creating a virtual machine scale set.")

if self.os_type == 'Linux':
if disable_ssh_password and not self.ssh_public_keys:
self.fail("Parameter error: ssh_public_keys required when disabling SSH password.")
Expand All @@ -762,6 +813,20 @@ def exec_module(self, **kwargs):
if nsg:
self.security_group = self.network_models.NetworkSecurityGroup(id=nsg.get('id'))

plan = None
if self.plan:
plan = self.compute_models.Plan(name=self.plan.get('name'), product=self.plan.get('product'),
publisher=self.plan.get('publisher'),
promotion_code=self.plan.get('promotion_code'))

os_profile = None
if self.admin_username or self.custom_data or self.ssh_public_keys:
os_profile = self.compute_models.VirtualMachineScaleSetOSProfile(
admin_username=self.admin_username,
computer_name_prefix=self.short_hostname,
custom_data=self.custom_data
)

vmss_resource = self.compute_models.VirtualMachineScaleSet(
location=self.location,
overprovision=self.overprovision,
Expand All @@ -775,12 +840,9 @@ def exec_module(self, **kwargs):
capacity=self.capacity,
tier=self.tier,
),
plan=plan,
virtual_machine_profile=self.compute_models.VirtualMachineScaleSetVMProfile(
os_profile=self.compute_models.VirtualMachineScaleSetOSProfile(
admin_username=self.admin_username,
computer_name_prefix=self.short_hostname,
custom_data=self.custom_data
),
os_profile=os_profile,
storage_profile=self.compute_models.VirtualMachineScaleSetStorageProfile(
os_disk=self.compute_models.VirtualMachineScaleSetOSDisk(
managed_disk=managed_disk,
Expand Down Expand Up @@ -818,7 +880,7 @@ def exec_module(self, **kwargs):
if self.admin_password:
vmss_resource.virtual_machine_profile.os_profile.admin_password = self.admin_password

if self.os_type == 'Linux':
if self.os_type == 'Linux' and os_profile:
vmss_resource.virtual_machine_profile.os_profile.linux_configuration = self.compute_models.LinuxConfiguration(
disable_password_authentication=disable_ssh_password
)
Expand Down Expand Up @@ -852,6 +914,21 @@ def exec_module(self, **kwargs):

vmss_resource.virtual_machine_profile.storage_profile.data_disks = data_disks

if self.plan:
try:
plan_name = self.plan.get('name')
plan_product = self.plan.get('product')
plan_publisher = self.plan.get('publisher')
term = self.marketplace_client.marketplace_agreements.get(
publisher_id=plan_publisher, offer_id=plan_product, plan_id=plan_name)
term.accepted = True
self.marketplace_client.marketplace_agreements.create(
publisher_id=plan_publisher, offer_id=plan_product, plan_id=plan_name, parameters=term)
except Exception as exc:
self.fail(("Error accepting terms for virtual machine {0} with plan {1}. " +
"Only service admin/account admin users can purchase images " +
"from the marketplace. - {2}").format(self.name, self.plan, str(exc)))

self.log("Create virtual machine with parameters:")
self.create_or_update_vmss(vmss_resource)

Expand Down
13 changes: 11 additions & 2 deletions library/_azure_rm_virtualmachinescalesetinstance_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

EXAMPLES = '''
- name: List VM instances in Virtual Machine ScaleSet
azure_rm_computevirtualmachinescalesetinstance_info:
azure_rm_virtualmachinescalesetinstance_info:
resource_group: myResourceGroup
vmss_name: myVMSS
'''
Expand Down Expand Up @@ -108,6 +108,13 @@
returned: always
type: str
sample: 94a141a9-4530-46ac-b151-2c7ff09aa823
image_reference:
description:
- Image reference
returned: always
type: dict
sample: { "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myGroup/providers/Microsoft.Compute/galleries/
myGallery/images/myImage/versions/10.1.3"}
'''

from ansible.module_utils.azure_rm_common import AzureRMModuleBase
Expand Down Expand Up @@ -221,7 +228,9 @@ def format_response(self, item):
'name': d.get('name', None),
'provisioning_state': d.get('provisioning_state', None),
'power_state': power_state,
'vm_id': d.get('vm_id', None)
'vm_id': d.get('vm_id', None),
'image_reference': d.get('storage_profile').get('image_reference', None),
'computer_name': d.get('os_profile').get('computer_name', None)
}
return d

Expand Down
Loading