-
Notifications
You must be signed in to change notification settings - Fork 332
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
Builds on HCI inventory and adds ARC support as well #1735
base: dev
Are you sure you want to change the base?
Conversation
4fb6293
to
39dc14a
Compare
39dc14a
to
4521348
Compare
By default ARC hosts will not show up in inventory, but you can use the following inventory config to get them. plugin: azure.azcollection.azure_rm include_arc_resource_groups: ['*'] Use hostvar_expressions to modify the default ansible ssh config hostvar_expressions: ansible_host: "resource_group + '-' + name if 'Microsoft.HybridCompute/machines' == resource_type else (public_dns_hostnames + public_ipv4_address) | first" ansible_ssh_common_args: "'-F /tmp/' + resource_group + '-' + name + '/ssh_config' if 'Microsoft.HybridCompute/machines' == resource_type" Use keyed_groups to organize them or tags keyed_groups: - prefix: "type" key: resource_type trailing_separator: false Use the azure_rm_arcssh action plugin to configure the dynamic inventory hosts with ssh proxy settings: - name: Configure ARC SSH Proxy hosts: localhost connection: local tasks: - name: Setup Proxy azure.azcollection.azure_rm_arcssh: inventory_hostname: "{{ item }}" ansible_host: "{{ hostvars[item].ansible_host }}" local_user: admin resource_group: "{{ hostvars[item].resource_group }}" resource_type: "{{ hostvars[item].resource_type }}" private_key_file: "~/.ssh/id_rsa" ssh_config_file: "/tmp/{{ hostvars[item].resource_group }}-{{ item }}/ssh_config" ssh_relay_file: "/tmp/{{ hostvars[item].resource_group }}-{{ item }}/relay_info" ssh_proxy_folder: "~/.clientsshproxy" loop: "{{ groups['type_Microsoft_HybridCompute_machines'] }}" - name: Ping ARC Hosts hosts: type_Microsoft_HybridCompute_machines tasks: - name: Ping ansible.builtin.ping:
4521348
to
aeeee10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did not test azure_rm_arcssh.py
for arc inventory, see my inline comments
plugins/inventory/azure_rm.py
Outdated
for ipaddr in nic.get('ipAddresses', []): | ||
ipAddressVersion = ipaddr.get('ipAddressVersion') | ||
if ipAddressVersion == 'IPv4': | ||
new_hostvars['ansible_all_ipv4_addresses'].append(ipaddr.get('address')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also fill private_ipv4_addresses ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assume all IPv4 addresses are private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included the netaddr package and use is_global() to determine
remark, if I do:
I notice that it gives me the arc objects, but also the stack hci vms (because they are arc objects). We currently have no way to only list arc objects which are non-stack hci vms. I'm not saying this needs to be fixed, this is just a remark. |
SUMMARY
Adds support for listing ARC machines in inventory.
ISSUE TYPE
COMPONENT NAME
plugins/action/azure_rm_arcssh.py
plugins/doc_fragments/azure_rm.py
plugins/inventory/azure_rm.py
plugins/modules/azure_rm_arcssh.py
plugins/plugin_utils/connectivity_utils.py
plugins/plugin_utils/constants.py
plugins/plugin_utils/file_utils.py
plugins/plugin_utils/ssh_info.py
requirements.txt
ADDITIONAL INFORMATION
SSH proxy setup is done via an action plugin. This provides the most flexibility for the user to configure the hosts the way they need to. They can group hosts based on tags and have different ssh permissions or keys depending on the group.