ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
238 stars 317 forks source link

Add new module `azure_rm_afdorigin` to support Azure Frontdoor Standard and Premium #1591

Open jartoo opened 3 weeks ago

jartoo commented 3 weeks ago
SUMMARY

This module manages Frontdoor Origins for the Standard and Premium services. I propose building this as a separate module in lieu of complicating the azure_cdn_profile module so as to make the management of each of the elements easier. Azure Frontdoor is quite complex, so matching the modules with the Python SDK APIs seems to be the prudent design choice.

Continues to work on https://github.com/ansible-collections/azure/issues/1041 This does not complete this issue, yet.

ISSUE TYPE
COMPONENT NAME

Module: azure_rm_afdorigin

ADDITIONAL INFORMATION

Provides the ability to manage Origins, per the Python SDK here: https://learn.microsoft.com/en-us/python/api/azure-mgmt-cdn/azure.mgmt.cdn.operations.afdoriginsoperations?view=azure-python

Fred-sun commented 3 weeks ago

@jartoo Please help fix below errors:


ERROR: plugins/modules/azure_rm_afdorigin_info.py:21:161: E501: line too long (207 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:64:14: W291: trailing whitespace
ERROR: plugins/modules/azure_rm_afdorigin_info.py:76:161: E501: line too long (210 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:83:161: E501: line too long (165 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:99:161: E501: line too long (183 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:111:161: E501: line too long (355 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:115:161: E501: line too long (198 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin_info.py:231:52: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin_info.py:232:52: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin_info.py:325:1: E305: expected 2 blank lines after class or function definition, found 1
ERROR: plugins/modules/azure_rm_afdorigin.py:33:161: E501: line too long (214 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:40:161: E501: line too long (169 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:54:161: E501: line too long (359 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:58:161: E501: line too long (202 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:157:161: E501: line too long (187 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:177:1: E302: expected 2 blank lines, found 1
ERROR: plugins/modules/azure_rm_afdorigin.py:181:22: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:181:24: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:183:18: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:183:20: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:184:18: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:184:20: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:185:19: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:185:21: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:186:11: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:186:13: E251: unexpected spaces around keyword / parameter equals
ERROR: plugins/modules/azure_rm_afdorigin.py:213:46: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:214:47: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:224:51: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:224:70: E231: missing whitespace after ','
ERROR: plugins/modules/azure_rm_afdorigin.py:265:49: E127: continuation line over-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:266:49: E127: continuation line over-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:267:49: E127: continuation line over-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:312:161: E501: line too long (163 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:315:161: E501: line too long (195 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:317:161: E501: line too long (207 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:319:161: E501: line too long (234 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:321:161: E501: line too long (216 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:323:161: E501: line too long (189 > 160 characters)
ERROR: plugins/modules/azure_rm_afdorigin.py:325:1: W293: blank line contains whitespace
ERROR: plugins/modules/azure_rm_afdorigin.py:384:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:385:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:386:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:387:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:423:1: W293: blank line contains whitespace
ERROR: plugins/modules/azure_rm_afdorigin.py:426:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:427:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:428:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:429:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:445:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:446:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:447:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:465:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:466:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:467:17: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:478:56: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:479:56: E128: continuation line under-indented for visual indent
ERROR: plugins/modules/azure_rm_afdorigin.py:487:1: E305: expected 2 blank lines after class or function definition, found 1
jartoo commented 3 weeks ago

In looking at this further, I am wondering if i should flatten the input parameters and resubmit this... Looking for architectural guidance on this. In working thru the Route module, it seems to be much cleaner when I do this and not nest the parameters under unnecessary suboptions. For example, move all of the origin suboptions, like azure_origin to the root level, reducing the nesting complexity.

jartoo commented 3 weeks ago

Doing this would also help with the required_if and the attribute setting sections, which do not work well with nested layers of inputs.

jartoo commented 3 weeks ago

Looking at this again after working the AFDRoute module, I think it makes sense to flatten the inputs if not in a list structure to reduce complexity and take advantage of the built-in functionality which only works at the root level, such as the required_if and required_together functions. I will rework this and submit further changes...sorry, figuring this out as I go it seems.

jartoo commented 3 weeks ago

@Fred-sun Please let me know if you prefer flattened inputs, per the above comment, or hierarchical ones. I have not found yet any guidance on the approach for this. It would be helpful if I had this before I rework the other pull requests. With hierarchical you lose the ability to use required_if and required_together functions as well as setting defaults as those functions currently only run on the first level in the inputs. I can rework the other module pull requests to align...Thanks!

Fred-sun commented 3 weeks ago

@jartoo Thank you very much for your reply, because we will create and delete two states。 The delete states, those are not required parameters can be None, so we need to make a judgment first. Also, regarding the new module, please add it to pr-pipeline.yml and meta/runtime.yml. Thank you!

jartoo commented 2 weeks ago

Let me refactor this. Put this on hold until I submit the flattened parameters...will try to get this done ASAP.

Fred-sun commented 2 weeks ago

@jartoo Ok, you can also add me to this branch of yours and I will work with you to solve the repo problem. Thank you!

Fred-sun commented 5 days ago

@xuzhang3 This PR relies on #1588 and #1590, Please merge #1588 and #1590 at first!Thanks!

xuzhang3 commented 2 days ago

@jartoo can you help resolve the file conflict.

xuzhang3 commented 9 hours ago

test failed:

running playbook inside collection azure.azcollection
ERROR! couldn't resolve module/action 'azure_rm_afdorigingroup'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/cloudtest/.ansible/ansible_collections/azure/azcollection/tests/output/.tmp/integration/azure_rm_afdorigin-wl2ok8p5-ÅÑŚÌβŁÈ/tests/integration/targets/azure_rm_afdorigin/tasks/main.yml': line 16, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Create Origin Group
  ^ here
Command exited with status 4 after 0.5188372135162354 seconds.
NOTICE: To resume at this test target, use the option: --start-at azure_rm_afdorigin
FATAL: Command "ansible-playbook azure_rm_afdorigin-nqi94ery.yml -i inventory -vvvvvv" returned exit status 4.