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

New module: azure_rm_eventhub #519

Merged
merged 44 commits into from
May 28, 2021

Conversation

saurabh3796
Copy link
Contributor

SUMMARY

This module introduces a wide variety of configurations for creating a Event Hub Namespace and Event Hub on Azure.
Create Event Hub Namespace on Azure.
Create Event Hub on Azure.
Update Event Hub Namespace on Azure.
Update Event Hub on Azure.
Delete Event Hub Namespace on Azure.
Delete Event Hub on Azure.
Get Event Hub Namespace on Azure.
Get Event Hub on Azure.

ISSUE TYPE

New Module Pull Request

COMPONENT NAME

azure_rm_eventhub

ADDITIONAL INFORMATION

This module allows users to create/update or delete the Event Hub Namespace and Event Hub on Azure.
It also provides all the parameters given by:
https://docs.microsoft.com/en-us/azure/templates/microsoft.eventhub/namespaces?tabs=json
https://docs.microsoft.com/en-us/azure/templates/microsoft.eventhub/namespaces/eventhubs?tabs=json

Example,
azure_rm_eventhub:
    resource_group: testgroupans
    location: eastus
    namespace_name: myNamespace
    tags:
        a: b
    sku: Basic

@saurabh3796
Copy link
Contributor Author

@Fred-sun Can you please review this PR for new module, Thanks.

@Fred-sun
Copy link
Collaborator

@Fred-sun Can you please review this PR for new module, Thanks.

Thank you for your contribution, under review!

@Fred-sun Fred-sun added medium_priority Medium priority new_module_pr Add new modules work in In trying to solve, or in working with contributors labels Apr 29, 2021
plugins/modules/azure_rm_eventhub.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Show resolved Hide resolved
tests/integration/targets/azure_rm_eventhub/tasks/main.yml Outdated Show resolved Hide resolved
@Fred-sun

This comment has been minimized.

@haiyuazhang haiyuazhang changed the title Eventhub CRUD operations New module: azure_rm_eventhub May 17, 2021
@Fred-sun
Copy link
Collaborator

@saurabh3796 Please help resolve these confilict files! Thank you very much!

@saurabh3796
Copy link
Contributor Author

@Fred-sun Resolved the conflicts, thanks for review.

@saurabh3796
Copy link
Contributor Author

@Fred-sun Can you please review this PR whenever you are available. Thanks.

Copy link
Collaborator

@Fred-sun Fred-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saurabh3796 Please help to delete these ignores on ignore2.11.txt, 2.9.txt, 2.10.txt and 2.12.txt. It has been fixed by #540!

plugins/modules/azure_rm_eventhub.py Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Show resolved Hide resolved
plugins/modules/azure_rm_eventhub_info.py Show resolved Hide resolved
@saurabh3796
Copy link
Contributor Author

I have run them manually in playbook.
`- name: Delete Namespace
azure_rm_eventhub:
location: eastus2
namespace_name: "nsCreateTest"
resource_group: "newctvm"
state: absent

changed: [localhost] => {
"changed": true,
"invocation": {
"module_args": {
"ad_user": null,
"adfs_authority_url": null,
"api_profile": "latest",
"append_tags": true,
"auth_source": "auto",
"cert_validation_mode": null,
"client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"cloud_environment": "AzureCloud",
"location": "eastus2",
"message_retention_in_days": null,
"name": null,
"namespace_name": "nsCreateTest",
"partition_count": null,
"password": null,
"profile": null,
"resource_group": "newctvm",
"secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"sku": "Basic",
"state": "absent",
"status": "Active",
"subscription_id": "xxxxx",
"tags": null,
"tenant": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
}
},
"state": {
"additional_properties": {},
"created_at": "2021-05-27T05:01:06.873Z",
"critical": null,
"data_center": null,
"enabled": null,
"is_auto_inflate_enabled": false,
"location": "eastus2",
"maximum_throughput_units": 0,
"metric_id": "xxxxx",
"name": "nsCreateTest",
"namespace_type": null,
"provisioning_state": "Succeeded",
"region": null,
"scale_unit": null,
"service_bus_endpoint": "xxxx",
"sku": "Basic",
"status": "Deleted",
"tags": {
"test": "modified"
},
"type": "Microsoft.EventHub/Namespaces",
"updated_at": "2021-05-27T05:06:35.170Z"
}
}
`

@saurabh3796
Copy link
Contributor Author

`- name: Update Namespace
azure_rm_eventhub:
location: eastus2
namespace_name: "nsCreateTest"
resource_group: "newctvm"
tags:
test: modified
register: results

  • assert:
    that:
    - results.changed
    - results.state.tags.test == 'modified'

changed: [localhost] => {
"changed": true,
"invocation": {
"module_args": {
"ad_user": null,
"adfs_authority_url": null,
"api_profile": "latest",
"append_tags": true,
"auth_source": "auto",
"cert_validation_mode": null,
"client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"cloud_environment": "AzureCloud",
"location": "eastus2",
"message_retention_in_days": null,
"name": null,
"namespace_name": "nsCreateTest",
"partition_count": null,
"password": null,
"profile": null,
"resource_group": "newctvm",
"secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"sku": "Basic",
"state": "present",
"status": "Active",
"subscription_id": "xxxx",
"tags": {
"test": "modified"
},
"tenant": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
}
},
"state": {
"additional_properties": {},
"created_at": "2021-05-27T05:01:06.873Z",
"critical": null,
"data_center": null,
"enabled": null,
"is_auto_inflate_enabled": false,
"location": "eastus2",
"maximum_throughput_units": 0,
"metric_id": "xxx",
"name": "nsCreateTest",
"namespace_type": null,
"provisioning_state": "Succeeded",
"region": null,
"scale_unit": null,
"service_bus_endpoint": "xxx",
"sku": "Basic",
"tags": {
"test": "modified"
},
"type": "Microsoft.EventHub/Namespaces",
"updated_at": "2021-05-27T05:06:35.170Z"
}
}
`

@saurabh3796
Copy link
Contributor Author

saurabh3796 commented May 27, 2021

@Fred-sun All tests are running fine, attached results for couple of ones. Thanks

@Fred-sun
Copy link
Collaborator

@Fred-sun All tests are running fine, attached results for couple of ones. Thanks

@saurabh3796 Update event_hub fail! thanks!

@saurabh3796
Copy link
Contributor Author

Update event hub
playbook:
--- - hosts: localhost connection: local tasks: - name: Retrieve event hub azure.azcollection.azure_rm_eventhub: resource_group: newctvm state: present location: eastus2 status: "Active" message_retention_in_days: 2 sku: "Standard" namespace_name: nsCreateTest name: eventCreateTest register: results

Result -
ok: [localhost] => { "changed": false, "invocation": { "module_args": { "ad_user": null, "adfs_authority_url": null, "api_profile": "latest", "append_tags": true, "auth_source": "auto", "cert_validation_mode": null, "client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "cloud_environment": "AzureCloud", "location": "eastus2", "message_retention_in_days": 2, "name": "eventCreateTest", "namespace_name": "nsCreateTest", "partition_count": null, "password": null, "profile": null, "resource_group": "newctvm", "secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "sku": "Standard", "state": "present", "status": "Active", "subscription_id": "xxxxxxx", "tags": null, "tenant": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" } }, "state": { "additional_properties": { "location": "East US 2" }, "created_at": "2021-05-27T09:08:35.813Z", "message_retention_in_days": 2, "name": "eventCreateTest", "partition_count": 4, "partition_ids": [ "0", "1", "2", "3" ], "status": "Active", "tags": null, "updated_at": "2021-05-27T10:07:00.867Z" } }

@Fred-sun
Copy link
Collaborator

@saurabh3796 Failed when testing for idempotency! Thank you very much!

@saurabh3796
Copy link
Contributor Author

@Fred-sun Can you share the steps to run integration tests, I am trying to run same on local but not able to run.

@Fred-sun
Copy link
Collaborator

@Fred-sun Can you share the steps to run integration tests, I am trying to run same on local but not able to run.

Execute the tasks,

---
- name: Using Azure collection
  hosts: localhost
  connection: local
  collections:
    - azure.azcollection
  vars:
    resource_group: v-xisuRG
  tasks:
    - name: create resource gorup
      azure_rm_resourcegroup:
        name: v-xisuRG
        location: eastus
    - include: main.yml
~                       

@Fred-sun Fred-sun closed this May 27, 2021
@Fred-sun Fred-sun reopened this May 27, 2021
@saurabh3796
Copy link
Contributor Author

Result for integration tests --
`
PLAY [Using Azure collection] **************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [create resource gorup] ***************************************************
ok: [localhost]

TASK [Create random event hub and namespace] ***********************************
ok: [localhost]

TASK [Create Event Hub Namespace (check mode)] *********************************
changed: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Create Event Hub (check mode)] ******************************************
changed: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Create Event Hub Namespace] **********************************************
changed: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Create Event Hub] ********************************************************
changed: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Update Namespace] ********************************************************
changed: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Update Event Hub] ********************************************************
ok: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Retrieve Namespace] ******************************************************
ok: [localhost]

TASK [Test idempotent] *********************************************************
changed: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Delete Event Hub] ********************************************************
changed: [localhost]

TASK [Delete Event Hub (idempotent)] *******************************************
ok: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Delete Namespace] ********************************************************
changed: [localhost]

TASK [Pause for 5 minutes to check namespace deleted] **************************
Pausing for 60 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
ok: [localhost]

TASK [Delete Namespace (idempotent)] *******************************************
ok: [localhost]

TASK [assert] ******************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

PLAY RECAP *********************************************************************
localhost : ok=25 changed=8 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

`

@saurabh3796
Copy link
Contributor Author

@Fred-sun Ran all integration tests successfully, attached the result. Thanks.

@saurabh3796
Copy link
Contributor Author

New updated integration tests results -
`TASK [Gathering Facts] *************************************************************************************************************************************************************************************
ok: [localhost]

TASK [create resource gorup] *******************************************************************************************************************************************************************************
ok: [localhost]

TASK [Create random event hub and namespace] ***************************************************************************************************************************************************************
ok: [localhost]

TASK [Create Event Hub Namespace (check mode)] *************************************************************************************************************************************************************
changed: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Create Event Hub (check mode)] **********************************************************************************************************************************************************************
changed: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Create Event Hub Namespace] **************************************************************************************************************************************************************************
changed: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Create Event Hub] ************************************************************************************************************************************************************************************
changed: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Update Namespace] ************************************************************************************************************************************************************************************
changed: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Update Event Hub] ************************************************************************************************************************************************************************************
changed: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Retrieve Namespace] **********************************************************************************************************************************************************************************
ok: [localhost]

TASK [Test idempotent] *************************************************************************************************************************************************************************************
ok: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Delete Event Hub] ************************************************************************************************************************************************************************************
changed: [localhost]

TASK [Delete Event Hub (idempotent)] ***********************************************************************************************************************************************************************
ok: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

TASK [Delete Namespace] ************************************************************************************************************************************************************************************
changed: [localhost]

TASK [Pause for 1 minutes to check namespace deleted] ******************************************************************************************************************************************************
Pausing for 60 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
ok: [localhost]

TASK [Delete Namespace (idempotent)] ***********************************************************************************************************************************************************************
ok: [localhost]

TASK [assert] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"changed": false,
"msg": "All assertions passed"
}

PLAY RECAP *************************************************************************************************************************************************************************************************
localhost : ok=25 changed=8 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0`

plugins/modules/azure_rm_eventhub.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_eventhub.py Outdated Show resolved Hide resolved
@Fred-sun Fred-sun added ready_for_review The PR has been modified and can be reviewed and merged and removed work in In trying to solve, or in working with contributors labels May 27, 2021
@haiyuazhang haiyuazhang merged commit c2a7a1a into ansible-collections:dev May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority new_module_pr Add new modules ready_for_review The PR has been modified and can be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants