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

Add vmskus module - list available skus #1546

Merged
merged 1 commit into from
May 21, 2024

Conversation

nirarg
Copy link
Collaborator

@nirarg nirarg commented May 6, 2024

SUMMARY

Support for VM shape fact collection from available SKUs would allow for playbook idempotence as automators build out support for their automations based on what SKUs are available within a cloud region as opposed to being configured within a playbook.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

New module added:
azure_rm_vmskus.py

ADDITIONAL INFORMATION

In order to add this module, I used the following references:

You can run ansible with this module, using the following command:

ansible localhost -m azure.azcollection.azure_rm_computeskus -a '{"location": "WestUS3", "resource_type": "virtualMachines", "size": "Standard_B1", "zone": "True"}

@Fred-sun Fred-sun added new_module_pr Add new modules medium_priority Medium priority work in In trying to solve, or in working with contributors labels May 7, 2024
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.

@nirarg You can detect these errors with the command ansible-lint, which can be found by referring to the link: https://ansible.readthedocs.io/projects/lint/usage/

@Fred-sun
Copy link
Collaborator

Fred-sun commented May 7, 2024

@nirarg This module is like a module to get VMsku information, it would be better if it was named 'azure_rm_vmsku_info.py'! Thank you very much!

@Fred-sun Fred-sun added the question Further information is requested label May 7, 2024
@nirarg
Copy link
Collaborator Author

nirarg commented May 7, 2024

Hi @Fred-sun ,
Thank you for the review
I added fixes following your comments, please re-review

The module was renamed to azure_rm_vmsku_info.py

When I run ansible-lint on the yaml file I still get the following error types:

  • Action azure_rm_virtualmachine is not FQCN
  • Line too long (417 > 160 characters)

I also saw these errors exist in other files
Do you ignore these errors? is there any flag needed to be added to ansible-lint command in order to ignore?

@Fred-sun
Copy link
Collaborator

Fred-sun commented May 7, 2024

@nirarg Thank you for your feedback, I will re-check as soon as possible!

@Fred-sun
Copy link
Collaborator

Fred-sun commented May 7, 2024

@nirarg Yes, there are some other unavoidable errors that are temporarily ignored, such as the public key being too long! 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.

@nirarg The last request change!

plugins/modules/azure_rm_vmsku_info.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 question Further information is requested work in In trying to solve, or in working with contributors labels May 7, 2024
@xuzhang3
Copy link
Collaborator

@nirarg can you help resolve the file conflict? And there is a test failed, we need to run the VM tests since the compute API version updated.

The full traceback is:
Traceback (most recent call last):
  File "/home/cloudtest/.ansible/tmp/ansible-tmp-1715611799.900336-200380-158165065557721/AnsiballZ_azure_rm_diskencryptionset.py", line 121, in <module>
    _ansiballz_main()
  File "/home/cloudtest/.ansible/tmp/ansible-tmp-1715611799.900336-200380-158165065557721/AnsiballZ_azure_rm_diskencryptionset.py", line 113, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/cloudtest/.ansible/tmp/ansible-tmp-1715611799.900336-200380-158165065557721/AnsiballZ_azure_rm_diskencryptionset.py", line 61, in invoke_module
    runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_diskencryptionset', init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_diskencryptionset', _modlib_path=modlib_path),
  File "/usr/lib/python3.9/runpy.py", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py", line 318, in <module>
  File "/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py", line 314, in main
  File "/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py", line 199, in __init__
  File "/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 475, in __init__
  File "/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py", line 229, in exec_module
  File "/home/cloudtest/ansible-venv/lib/python3.9/site-packages/azure/mgmt/compute/_compute_management_client.py", line 892, in disk_encryption_sets
    raise ValueError("API version {} does not have operation group 'disk_encryption_sets'".format(api_version))
ValueError: API version 2021-07-01 does not have operation group 'disk_encryption_sets'
fatal: [azure_test_encrypted]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/cloudtest/.ansible/tmp/ansible-tmp-1715611799.900336-200380-158165065557721/AnsiballZ_azure_rm_diskencryptionset.py\", line 121, in <module>\n    _ansiballz_main()\n  File \"/home/cloudtest/.ansible/tmp/ansible-tmp-1715611799.900336-200380-158165065557721/AnsiballZ_azure_rm_diskencryptionset.py\", line 113, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/cloudtest/.ansible/tmp/ansible-tmp-1715611799.900336-200380-158165065557721/AnsiballZ_azure_rm_diskencryptionset.py\", line 61, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_diskencryptionset', init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_diskencryptionset', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.9/runpy.py\", line 225, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py\", line 318, in <module>\n  File \"/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py\", line 314, in main\n  File \"/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py\", line 199, in __init__\n  File \"/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py\", line 475, in __init__\n  File \"/tmp/ansible_azure_rm_diskencryptionset_payload_n5ug9ku7/ansible_azure_rm_diskencryptionset_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_diskencryptionset.py\", line 229, in exec_module\n  File \"/home/cloudtest/ansible-venv/lib/python3.9/site-packages/azure/mgmt/compute/_compute_management_client.py\", line 892, in disk_encryption_sets\n    raise ValueError(\"API version {} does not have operation group 'disk_encryption_sets'\".format(api_version))\nValueError: API version 2021-07-01 does not have operation group 'disk_encryption_sets'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@xuzhang3 xuzhang3 removed the ready_for_review The PR has been modified and can be reviewed and merged label May 15, 2024
Support for VM shape fact collection from available SKUs would allow for playbook idempotence
as automators build out support for their automations based on what SKUs are available within
a cloud region as opposed to being configured within a playbook.

This change includes:
* Adding new module: "azure_rm_vmsku_info" ("plugins/modules/azure_rm_vmsku_info.py")
* Adding new integration test: "tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_skus.yml"
@nirarg
Copy link
Collaborator Author

nirarg commented May 16, 2024

@nirarg can you help resolve the file conflict? And there is a test failed, we need to run the VM tests since the compute API version updated.

@xuzhang3 @Fred-sun I have change this new module to use its own client instance with its own version
Also rebased the branch on dev branch
Please verify again
Thanks

@Fred-sun
Copy link
Collaborator

@nirarg I am checking! Once finished review! I will push for merge! Thanks!

@Fred-sun Fred-sun added the ready_for_review The PR has been modified and can be reviewed and merged label May 16, 2024
@xuzhang3 xuzhang3 merged commit e9ce338 into ansible-collections:dev May 21, 2024
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

3 participants