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 missing hostvars properties in azure_rm.py inventory #53046
Conversation
HI @AlanCoding , could you pls help to look at if all those information added? I've compared output with old inventory output, except for public_ip_alloc_method and private_ip_alloc_method, all info there. old |
ready_for_review |
Testing the reported keys:
The only other things that the script had which are not covered by this PR are:
The However, security group looks important, that's the 1 thing that's probably important to get in, but this PR doesn't yet cover. With that said, I give a big 👍 to this PR for adding the above enumerated fields. This is a big improvement. |
@zikalino @yungezz what is the status of this PR now? Are you going to expand it to cover the security groups or handle that as a separate patch? On a fairly basic level I can poke at it and see if I can discover this data anywhere. The change here is a clear improvement. I would support merging as-is, if nobody has any code quality concerns. |
@yungezz this obtains the security group hostvars as desired diff --git a/lib/ansible/plugins/inventory/azure_rm.py b/lib/ansible/plugins/inventory/azure_rm.py
index 226bd7e68c..dfffa30cc4 100644
--- a/lib/ansible/plugins/inventory/azure_rm.py
+++ b/lib/ansible/plugins/inventory/azure_rm.py
@@ -527,6 +527,8 @@ class AzureHost(object):
new_hostvars['mac_address'] = nic._nic_model['properties'].get('macAddress')
new_hostvars['network_interface'] = nic._nic_model['name']
new_hostvars['network_interface_id'] = nic._nic_model['id']
+ new_hostvars['security_group_id'] = nic._nic_model['properties'].get('networkSecurityGroup')['id']
+ new_hostvars['security_group'] = parse_resource_id(new_hostvars['security_group_id'])['resource_name'].lower()
# set image and os_disk
new_hostvars['image'] = {} Could you please consider if this diff can be added to your current PR? Let me know if there is anything I can do to help move this forward. |
a branch in case that helps: https://github.com/ansible/ansible/compare/devel...AlanCoding:azure_security_group?expand=1 |
🎉 Yes if there is anything I can do to help get this in, ping me |
Thanks @AlanCoding for the code snippet. I'll take the suggestion. @nitzmahone mentioned he'd like to review and test before merging. some concern on multiple network interfaces. |
security_group id and name was added. @nitzmahone for multiple nic, currently both contrib/inventory/azure_rm.py and lib/ansible/plugin/inventory/azure_rm.py shows primary nic. are you planning to change to show multiple nics? if yes, output in new inventory will be out of sync with old one. |
Ran my script again, confirmed keys and values match for list in prior comment, plus security group. shipit |
HI @AlanCoding , I have question on Ansible Tower, not related to this PR. Would like to take this opportunity to ask the expert. Could you pls help to have a look? Thanks in advance. I want to configure github webhook hook to ansible tower job template launch, like https://xxxxx/api/v2/job_templates/8/launch/, how to pass the ansible tower authentication token then? I always get 401. Thanks. |
https://github.com/ansible/awx/blob/devel/docs/auth/oauth.md I think that you want the pattern like
tower-cli built its login command to be a role model for using this, so you can login and then make requests and see what headers are used. This assumes that you will use token auth for webhooks. That's the only good option, and might be the only workable option for your situation. |
@nitzmahone there was one unresolved question for you, which AFAIK is the only merge blocker right now. For what it's worth, I am only concerned with parity with the old script for the 2.8 release. Listing multiple nics (aside from the primary) may be an okay feature at some later time, but would complicate current efforts. |
thank you @AlanCoding for sharing the knowledge! I've tried and it works well. |
* add missing hostvars properties * fix lint * fix lint * add security group * fix lint (cherry picked from commit 71042e1)
SUMMARY
fixing issue #51864.
adding missed hostvars from azure_rm.py inventory. properties added:
sample hostvars after fixing
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION