Debian Codegraph @

ansible_collections/azure/azcollection/plugins/modules/azure_rm_arcssh.py

raw symbols SCIP
1 # Copyright (c) 2024 Bill Peck <[email protected]>
2 #
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import absolute_import, division, print_function
6 __metaclass__ = type
7
8 DOCUMENTATION = '''
9 ---
10 module: azure_rm_arcssh
11 version_added: "3.1.0"
12 short_description: Configure SSH proxy for ARC hosts
13 description:
14 - Configure SSH proxy for ARC hosts. Use this in combination with the
15 azure_rm inventory plugin with include_arc_resource_groups to dynamically
16 generate the list of hosts.
17
18 options:
19 resource_group:
20 description:
21 - The name of the Resource Group to which the server belongs.
22 required: True
23 type: str
24 resource_type:
25 description:
26 - The name of the Resource Type to which the server belongs.
27 required: True
28 type: str
29 inventory_hostname:
30 description:
31 - The inventory configured hostname.
32 type: str
33 ansible_host:
34 description:
35 - The discovered hostname that is generated by the inventory config.
36 - Please see the examples on how this can be set based on the resource_type.
37 type: str
38 private_key_file:
39 description:
40 - The Private key that matches the public key that you have already added to your authorized_hosts
41 of local_user.
42 default: ~/.ssh/id_rsa
43 type: str
44 local_user:
45 description:
46 - The local user that you use to log into your server.
47 type: str
48 port:
49 description:
50 - The port that your ssh server is listening on.
51 default: '22'
52 type: str
53 ssh_config_file:
54 description:
55 - Host specific file location for ssh config. It must match the -F argument passed to
56 ansible_ssh_common_args. This will be overwritten and should be different for each host.
57 - See the Examples for how to set this variable to match both the task and inventory plugin.
58 required: True
59 type: str
60 ssh_relay_file:
61 description:
62 - Host specific file location for the relay file.
63 required: True
64 type: str
65 ssh_proxy_folder:
66 description:
67 - The folder which will store the client ssh proxy.
68 default: ~/.clientsshproxy
69 type: str
70
71 extends_documentation_fragment:
72 - azure.azcollection.azure
73
74 author:
75 - Bill Peck (@p3ck)
76 '''
77
78 EXAMPLES = '''
79 # Inventory plugin:
80 # ---
81 # plugin: azure.azcollection.azure_rm
82 # plain_host_names: yes
83 # include_arc_resource_groups: ['*']
84 #
85 #
86 # hostvar_expressions:
87 # ansible_host: "resource_group + '-' + name if 'Microsoft.HybridCompute/machines' == resource_type else (public_dns_hostnames + public_ipv4_address) | first"
88 # ansible_ssh_common_args: "'-F /tmp/' + resource_group + '-' + name + '/ssh_config' if 'Microsoft.HybridCompute/machines' == resource_type"
89 #
90 # keyed_groups:
91 # # places each host in a group named 'tag_(tag name)_(tag value)' for each tag on a VM.
92 # - prefix: "type"
93 # key: resource_type
94 # trailing_separator: false
95
96 - name: Configure ARC SSH Proxy
97 hosts: localhost
98 connection: local
99 tasks:
100 - name: Setup Proxy
101 azure.azcollection.azure_rm_arcssh:
102 inventory_hostname: "{{ item }}"
103 ansible_host: "{{ hostvars[item].ansible_host }}"
104 local_user: admin
105 resource_group: "{{ hostvars[item].resource_group }}"
106 resource_type: "{{ hostvars[item].resource_type }}"
107 private_key_file: "~/.ssh/id_rsa"
108 ssh_config_file: "/tmp/{{ hostvars[item].resource_group }}-{{ item }}/ssh_config"
109 ssh_relay_file: "/tmp/{{ hostvars[item].resource_group }}-{{ item }}/relay_info"
110 ssh_proxy_folder: "~/.clientsshproxy"
111 loop: "{{ groups['type_Microsoft_HybridCompute_machines'] }}"
112
113 - name: Ping ARC Hosts
114 hosts: type_Microsoft_HybridCompute_machines
115 tasks:
116 - name: Ping
117 ansible.builtin.ping:
118 '''