Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_ssh_policy_info.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import absolute_import, division, print_function
7 __metaclass__ = type
8
9 ANSIBLE_METADATA = {'metadata_version': '1.1',
10 'status': ['preview'],
11 'supported_by': 'community'}
12
13 DOCUMENTATION = r'''
14 ---
15 module: intersight_ssh_policy_info
16 short_description: Gather information about SSH Policies in Cisco Intersight
17 description:
18 - Gather information about SSH Policies in L(Cisco Intersight,https://intersight.com).
19 - Information can be filtered by O(organization) and O(name).
20 - If no filters are passed, all SSH Policies will be returned.
21 - SSH Policies are applicable only for UCS Servers (Standalone).
22 extends_documentation_fragment: intersight
23 options:
24 organization:
25 description:
26 - The name of the organization the SSH Policy belongs to.
27 type: str
28 name:
29 description:
30 - The name of the SSH Policy to gather information from.
31 type: str
32 author:
33 - Ron Gershburg (@rgershbu)
34 '''
35
36 EXAMPLES = r'''
37 - name: Fetch a specific SSH Policy by name
38 cisco.intersight.intersight_ssh_policy_info:
39 api_private_key: "{{ api_private_key }}"
40 api_key_id: "{{ api_key_id }}"
41 name: "SSH-Policy-Default"
42
43 - name: Fetch all SSH Policies in a specific Organization
44 cisco.intersight.intersight_ssh_policy_info:
45 api_private_key: "{{ api_private_key }}"
46 api_key_id: "{{ api_key_id }}"
47 organization: "default"
48
49 - name: Fetch all SSH Policies
50 cisco.intersight.intersight_ssh_policy_info:
51 api_private_key: "{{ api_private_key }}"
52 api_key_id: "{{ api_key_id }}"
53 '''
54
55 RETURN = r'''
56 api_response:
57 description: The API response output returned by the specified resource.
58 returned: always
59 type: dict
60 sample:
61 "api_response": [
62 {
63 "Name": "SSH-Policy-Default",
64 "ObjectType": "ssh.Policy",
65 "Enabled": true,
66 "Port": 22,
67 "Timeout": 1800,
68 "Description": "SSH policy with default settings",
69 "Tags": [
70 {
71 "Key": "Environment",
72 "Value": "Production"
73 }
74 ]
75 },
76 {
77 "Name": "SSH-Policy-Custom",
78 "ObjectType": "ssh.Policy",
79 "Enabled": true,
80 "Port": 2222,
81 "Timeout": 3600,
82 "Description": "SSH policy with custom port and timeout",
83 "Tags": [
84 {
85 "Key": "Site",
86 "Value": "DataCenter-A"
87 }
88 ]
89 }
90 ]
91 '''
92
93
94 from ansible.module_utils.basic import AnsibleModule
95 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
96
97
98 def main():
99 argument_spec = intersight_argument_spec.copy()
100 argument_spec.update(
101 organization=dict(type='str'),
102 name=dict(type='str')
103 )
104 module = AnsibleModule(
105 argument_spec,
106 supports_check_mode=True,
107 )
108
109 intersight = IntersightModule(module)
110 intersight.result['api_response'] = {}
111 intersight.result['trace_id'] = ''
112
113 # Resource path used to fetch info
114 resource_path = '/ssh/Policies'
115
116 query_params = intersight.set_query_params()
117
118 intersight.get_resource(
119 resource_path=resource_path,
120 query_params=query_params,
121 return_list=True
122 )
123
124 module.exit_json(**intersight.result)
125
126
127 if __name__ == '__main__':
128 main()