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

Added new module for Azure API management service. #333

Merged
merged 5 commits into from
Apr 12, 2021

Conversation

nikhilpatne
Copy link
Contributor

Added new module for Azure API management service

Fixes #332

https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2020-06-01-preview/service

SUMMARY
An Ansible module that allows for create, delete and update azure api management service.

ISSUE TYPE
New Module request

COMPONENT NAME
azure_rm_apimanagementservice
azure_rm_apimanagementservice_info

ADDITIONAL INFORMATION
Would be able to create, update and delete Azure API Management service.

  • name: ApiManagementCreateService
    azure_rm_apimanagementservice:
    resource_group: myResourceGroup
    name: myService
    publisher_email: user@example.com
    publisher_name: Publisher Name
    sku_name: Developer
    sku_capacity: 1

@nikhilpatne nikhilpatne changed the title Added new module for Azure API management service - Fixes #332 Added new module for Azure API management service. Nov 24, 2020
@nikhilpatne
Copy link
Contributor Author

Hi @Fred-sun could you please review this PR ?

1 similar comment
@nikhilpatne
Copy link
Contributor Author

Hi @Fred-sun could you please review this PR ?

- name: To update API Management service publisher details
azure_rm_apimanagementservice:
resource_group: "{{ resource_group }}"
name: myService
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
name: myService
name: "{{ name }}"

@Fred-sun
Copy link
Collaborator

ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'No module named 'ansible.module_utils.azure_rm_common_ext''
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'No module named 'ansible.module_utils.azure_rm_common''
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: return-syntax-error: RETURN.api_management_service.contains.apimanagementservice_name.contains.identity.contains.principal_id.type: not a valid value for dictionary value @ data['api_management_service']['contains']['apimanagementservice_name']['contains']['identity']['contains']['principal_id']['type']. Got 'unknown-primary[uuid]'
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: return-syntax-error: RETURN.api_management_service.contains.apimanagementservice_name.contains.identity.contains.tenant_id.type: not a valid value for dictionary value @ data['api_management_service']['contains']['apimanagementservice_name']['contains']['identity']['contains']['tenant_id']['type']. Got 'unknown-primary[uuid]'
ERROR: tests/sanity/ignore-2.10.txt:16:1: A100: Ignoring 'invalid-ansiblemodule-schema' on 'plugins/modules/azure_rm_apimanagementservice.py' is unnecessary
ERROR: tests/sanity/ignore-2.10.txt:17:1: A100: Ignoring 'required_if-requirements-unknown' on 'plugins/modules/azure_rm_apimanagementservice.py' is unnecessary
ERROR: tests/sanity/ignore-2.10.txt:18:1: A100: Ignoring 'required_if-unknown-key' on 'plugins/modules/azure_rm_apimanagementservice.py' is unnecessary
ERROR: tests/sanity/ignore-2.10.txt:19:1: A100: Ignoring 'parameter-type-not-in-doc' on 'plugins/modules/azure_rm_apimanagementservice.py' is unnecessary
ERROR: tests/sanity/ignore-2.10.txt:20:1: A100: Ignoring 'required_if-requirements-unknown' on 'plugins/modules/azure_rm_apimanagementservice_info.py' is unnecessary
ERROR: tests/sanity/ignore-2.10.txt:21:1: A100: Ignoring 'required_if-unknown-key' on 'plugins/modules/azure_rm_apimanagementservice_info.py' is unnecessary
ERROR: tests/sanity/ignore-2.10.txt:22:1: A100: Ignoring 'parameter-type-not-in-doc' on 'plugins/modules/azure_rm_apimanagementservice_info.py' is unnecessary
ERROR: plugins/modules/azure_rm_apimanagementservice.py:340:0: missing-final-newline: Final newline missing
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:299:0: missing-final-newline: Final newline missing

@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 Nov 30, 2020
@nikhilpatne
Copy link
Contributor Author

Hi @Fred-sun I have made necessary changes as you mentioned.

@nikhilpatne
Copy link
Contributor Author

@Fred-sun Could you please review my changes

plugins/modules/azure_rm_apimanagementservice_info.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_apimanagementservice.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_apimanagementservice.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_apimanagementservice.py validate-modules:required_if-requirements-unknown
plugins/modules/azure_rm_apimanagementservice.py validate-modules:required_if-unknown-key
plugins/modules/azure_rm_apimanagementservice.py validate-modules:parameter-type-not-in-doc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
plugins/modules/azure_rm_apimanagementservice.py validate-modules:parameter-type-not-in-doc

plugins/modules/azure_rm_apimanagementservice.py validate-modules:required_if-requirements-unknown
plugins/modules/azure_rm_apimanagementservice.py validate-modules:required_if-unknown-key
plugins/modules/azure_rm_apimanagementservice.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-requirements-unknown
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-requirements-unknown

plugins/modules/azure_rm_apimanagementservice.py validate-modules:required_if-unknown-key
plugins/modules/azure_rm_apimanagementservice.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-requirements-unknown
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-unknown-key
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-unknown-key

plugins/modules/azure_rm_apimanagementservice.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-requirements-unknown
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:required_if-unknown-key
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:parameter-type-not-in-doc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
plugins/modules/azure_rm_apimanagementservice_info.py validate-modules:parameter-type-not-in-doc

plugins/modules/azure_rm_apimanagementservice.py Outdated Show resolved Hide resolved
@nikhilpatne
Copy link
Contributor Author

Hello @Fred-sun I made all changes that you mentioned, please take look on this.

Thanks

@Fred-sun
Copy link
Collaborator

@nikhilpatne Thanks for the update! Have you executed task/main.yml locally? An error occurred during the update. Please modify the playbook and modules and add idempotent tests to the use cases. thank you very much!

@Fred-sun
Copy link
Collaborator

@nikhilpatne In addition, you can refer to the link ---https://docs.ansible.com/ansible/devel/dev_guide/testing_sanity.html#testing-sanity to check the documentation. Thank you!

@nikhilpatne
Copy link
Contributor Author

Hi @Fred-sun I made all changes that you suggested, please take a look on this.

@nikhilpatne
Copy link
Contributor Author

Hi @Fred-sun could you please review my changes

@Fred-sun
Copy link
Collaborator

Fred-sun commented Jan 6, 2021

@nikhilpatne

ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.name.disposition: extra keys not allowed @ data['argument_spec']['name']['disposition']. Got 'serviceName'
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.name.updatable: extra keys not allowed @ data['argument_spec']['name']['updatable']. Got False
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.publisher_email.disposition: extra keys not allowed @ data['argument_spec']['publisher_email']['disposition']. Got '/properties/publisherEmail'
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.publisher_name.disposition: extra keys not allowed @ data['argument_spec']['publisher_name']['disposition']. Got '/properties/publisherName'
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.resource_group.disposition: extra keys not allowed @ data['argument_spec']['resource_group']['disposition']. Got 'resourceGroupName'
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.resource_group.updatable: extra keys not allowed @ data['argument_spec']['resource_group']['updatable']. Got False
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.sku_capacity.disposition: extra keys not allowed @ data['argument_spec']['sku_capacity']['disposition']. Got '/sku/capacity'
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.sku_name.disposition: extra keys not allowed @ data['argument_spec']['sku_name']['disposition']. Got '/sku/name'
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: required_if-requirements-unknown: required_if contains terms in requirements which are not part of argument_spec: log_path
ERROR: plugins/modules/azure_rm_apimanagementservice.py:0:0: required_if-unknown-key: required_if must have its key log_mode in argument_spec
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: doc-default-does-not-match-spec: Argument 'append_tags' in argument_spec defines default as (True) but documentation defines default as (None)
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: parameter-type-not-in-doc: Argument 'append_tags' in argument_spec defines type as 'bool' but documentation doesn't define type
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: parameter-type-not-in-doc: Argument 'tags' in argument_spec defines type as 'dict' but documentation doesn't define type
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: required_if-requirements-unknown: required_if contains terms in requirements which are not part of argument_spec: log_path
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: required_if-unknown-key: required_if must have its key log_mode in argument_spec
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: undocumented-parameter: Argument 'append_tags' is listed in the argument_spec, but not documented in the module documentation
ERROR: plugins/modules/azure_rm_apimanagementservice_info.py:0:0: undocumented-parameter: Argument 'tags' is listed in the argument_spec, but not documented in the module documentation
ERROR: plugins/modules/azure_rm_appgateway.py:0:0: doc-choices-do-not-match-spec: Argument 'cipher_suites' in argument_spec found in ssl_policy defines choices as ([]) but documentation defines choices as ([['tls_ecdhe_rsa_with_aes_256_gcm_sha384'], ['tls_ecdhe_rsa_with_aes_128_gcm_sha256'], ['tls_ecdhe_rsa_with_aes_256_cbc_sha384'], ['tls_ecdhe_rsa_with_aes_128_cbc_sha256'], ['tls_ecdhe_rsa_with_aes_256_cbc_sha'], ['tls_ecdhe_rsa_with_aes_128_cbc_sha'], ['tls_dhe_rsa_with_aes_256_gcm_sha384'], ['tls_dhe_rsa_with_aes_128_gcm_sha256'], ['tls_dhe_rsa_with_aes_256_cbc_sha'], ['tls_dhe_rsa_with_aes_128_cbc_sha'], ['tls_rsa_with_aes_256_gcm_sha384'], ['tls_rsa_with_aes_128_gcm_sha256'], ['tls_rsa_with_aes_256_cbc_sha256'], ['tls_rsa_with_aes_128_cbc_sha256'], ['tls_rsa_with_aes_256_cbc_sha'], ['tls_rsa_with_aes_128_cbc_sha'], ['tls_ecdhe_ecdsa_with_aes_256_gcm_sha384'], ['tls_ecdhe_ecdsa_with_aes_128_gcm_sha256'], ['tls_ecdhe_ecdsa_with_aes_256_cbc_sha384'], ['tls_ecdhe_ecdsa_with_aes_128_cbc_sha256'], ['tls_ecdhe_ecdsa_with_aes_256_cbc_sha'], ['tls_ecdhe_ecdsa_with_aes_128_cbc_sha'], ['tls_dhe_dss_with_aes_256_cbc_sha256'], ['tls_dhe_dss_with_aes_128_cbc_sha256'], ['tls_dhe_dss_with_aes_256_cbc_sha'], ['tls_dhe_dss_with_aes_128_cbc_sha'], ['tls_rsa_with_3des_ede_cbc_sha'], ['tls_dhe_dss_with_3des_ede_cbc_sha']])
ERROR: plugins/modules/azure_rm_appgateway.py:0:0: doc-choices-do-not-match-spec: Argument 'disabled_ssl_protocols' in argument_spec found in ssl_policy defines choices as ([]) but documentation defines choices as ([['tls_v1_0'], ['tls_v1_1'], ['tls_v1_2']])

@nikhilpatne
Copy link
Contributor Author

Hi, @Fred-sun I am following https://docs.ansible.com/ansible/devel/dev_guide/testing_sanity.html#testing-sanity for sanity checking.
but I cannot see any error in it ( on my machine ), Functionality wise code is working fine. could you please help me with sanity checking. because
sanity errors that you sent cannot debug at my side.

This module is stucked from long time, please help me.

@Fred-sun
Copy link
Collaborator

@nikhilpatne Yes, can you authorize me to make some updates in your branch? I will update to fixes these sanity error. Thank you very much!

@nikhilpatne
Copy link
Contributor Author

@Fred-sun I have given access to my branch. Kindly check, Thank you soo much..!!!!!

restore change-2

remove unuse file

fix sanity error

update for error
@Fred-sun
Copy link
Collaborator

@nikhilpatne Some changes have been made to solve the current problems. ApiManagement has not been updated and deleted yet. If you have any questions about the above changes, please inform us or make relevant changes. Thank you very much!

@nikhilpatne
Copy link
Contributor Author

Okay Thanks @Fred-sun Will look into it...

@Ompragash
Copy link
Member

@nikhilpatne Is there anything that we can help you with?

@nikhilpatne
Copy link
Contributor Author

nikhilpatne commented Apr 6, 2021

Yes thanks, @Ompragash and @Fred-sun , Problem is, To create and activate an Azure API Management service takes nearly 30 - 40 minutes.
When service is created via playbook I am exiting the playbook with changed(True). but it doesn't mean its activated, bcz, Azure takes 30-40 minutes to activate it, So without activation, you cannot perform the update, Delete operations on it.

I think Thats why it fails during the integration test. because we have to wait 40 minutes or more sometimes to activate it.

So what can I do in that case ???

https://docs.microsoft.com/en-us/azure/api-management/get-started-create-service-instance

@Fred-sun
Copy link
Collaborator

Fred-sun commented Apr 8, 2021

Yes thanks, @Ompragash and @Fred-sun , Problem is, To create and activate an Azure API Management service takes nearly 30 - 40 minutes.
When service is created via playbook I am exiting the playbook with changed(True). but it doesn't mean its activated, bcz, Azure takes 30-40 minutes to activate it, So without activation, you cannot perform the update, Delete operations on it.

I think Thats why it fails during the integration test. because we have to wait 40 minutes or more sometimes to activate it.

So what can I do in that case ???

https://docs.microsoft.com/en-us/azure/api-management/get-started-create-service-instance

@nikhilpatne yes, I agree. After create the API Services , The API Services is transitioning need 30 minutes. Other function is OK. So I'll disable its test cases and push this PR forward to merge. Thank you very much!

@nikhilpatne
Copy link
Contributor Author

@Fred-sun Thank you very much..!!!

@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 Apr 8, 2021
@haiyuazhang haiyuazhang merged commit d4c06b1 into ansible-collections:dev Apr 12, 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.

New Module for Azure API Management Service
4 participants