Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_passwordpolicy.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_user_passwordpolicy
15 short_description: Configure user password policy.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 user_passwordpolicy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 expire_days:
34 aliases: ['expire-days']
35 type: int
36 description: Time in days before the users password expires.
37 name:
38 type: str
39 description: Password policy name.
40 required: true
41 warn_days:
42 aliases: ['warn-days']
43 type: int
44 description: Time in days before a password expiration warning message is displayed to the user upon login.
45 expired_password_renewal:
46 aliases: ['expired-password-renewal']
47 type: str
48 description: Enable/disable renewal of a password that already is expired.
49 choices: ['disable', 'enable']
50 expire_status:
51 aliases: ['expire-status']
52 type: str
53 description: Enable/disable password expiration.
54 choices: ['disable', 'enable']
55 min_change_characters:
56 aliases: ['min-change-characters']
57 type: int
58 description: Minimum number of unique characters in new password which do not exist in old password
59 min_lower_case_letter:
60 aliases: ['min-lower-case-letter']
61 type: int
62 description: Minimum number of lowercase characters in password
63 min_non_alphanumeric:
64 aliases: ['min-non-alphanumeric']
65 type: int
66 description: Minimum number of non-alphanumeric characters in password
67 min_number:
68 aliases: ['min-number']
69 type: int
70 description: Minimum number of numeric characters in password
71 min_upper_case_letter:
72 aliases: ['min-upper-case-letter']
73 type: int
74 description: Minimum number of uppercase characters in password
75 minimum_length:
76 aliases: ['minimum-length']
77 type: int
78 description: Minimum password length
79 reuse_password:
80 aliases: ['reuse-password']
81 type: str
82 description: Enable/disable reuse of password.
83 choices: ['disable', 'enable']
84 reuse_password_limit:
85 aliases: ['reuse-password-limit']
86 type: int
87 description: Number of times passwords can be reused
88 '''
89
90 EXAMPLES = '''
91 - name: Example playbook (generated based on argument schema)
92 hosts: fortimanagers
93 connection: httpapi
94 gather_facts: false
95 tasks:
96 - name: Configure user password policy.
97 fortinet.fortimanager.fmgr_user_passwordpolicy:
98 # workspace_locking_adom: <global or your adom name>
99 adom: <your own value>
100 state: present # <value in [present, absent]>
101 user_passwordpolicy:
102 name: "your value" # Required variable, string
103 # expire_days: <integer>
104 # warn_days: <integer>
105 # expired_password_renewal: <value in [disable, enable]>
106 # expire_status: <value in [disable, enable]>
107 # min_change_characters: <integer>
108 # min_lower_case_letter: <integer>
109 # min_non_alphanumeric: <integer>
110 # min_number: <integer>
111 # min_upper_case_letter: <integer>
112 # minimum_length: <integer>
113 # reuse_password: <value in [disable, enable]>
114 # reuse_password_limit: <integer>
115 '''
116
117 RETURN = '''
118 meta:
119 description: The result of the request.
120 type: dict
121 returned: always
122 contains:
123 request_url:
124 description: The full url requested.
125 returned: always
126 type: str
127 sample: /sys/login/user
128 response_code:
129 description: The status of api request.
130 returned: always
131 type: int
132 sample: 0
133 response_data:
134 description: The api response.
135 type: list
136 returned: always
137 response_message:
138 description: The descriptive message of the api response.
139 type: str
140 returned: always
141 sample: OK.
142 system_information:
143 description: The information of the target system.
144 type: dict
145 returned: always
146 rc:
147 description: The status the request.
148 type: int
149 returned: always
150 sample: 0
151 version_check_warning:
152 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
153 type: list
154 returned: complex
155 '''
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible.module_utils.connection import Connection
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
160
161
162 def main():
163 urls_list = [
164 '/pm/config/adom/{adom}/obj/user/password-policy',
165 '/pm/config/global/obj/user/password-policy'
166 ]
167 module_arg_spec = {
168 'adom': {'required': True, 'type': 'str'},
169 'revision_note': {'type': 'str'},
170 'user_passwordpolicy': {
171 'type': 'dict', 'v_range': [['6.0.0', '']], 'no_log': False,
172 'options': {
173 'expire-days': {'type': 'int'},
174 'name': {'required': True, 'type': 'str'},
175 'warn-days': {'type': 'int'},
176 'expired-password-renewal': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
177 'expire-status': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
178 'min-change-characters': {'v_range': [['7.4.1', '']], 'type': 'int'},
179 'min-lower-case-letter': {'v_range': [['7.4.1', '']], 'type': 'int'},
180 'min-non-alphanumeric': {'v_range': [['7.4.1', '']], 'type': 'int'},
181 'min-number': {'v_range': [['7.4.1', '']], 'type': 'int'},
182 'min-upper-case-letter': {'v_range': [['7.4.1', '']], 'type': 'int'},
183 'minimum-length': {'v_range': [['7.4.1', '']], 'type': 'int'},
184 'reuse-password': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
185 'reuse-password-limit': {'v_range': [['7.6.0', '']], 'no_log': True, 'type': 'int'}
186 }
187 }
188 }
189
190 module_option_spec = get_module_arg_spec('full crud')
191 module_arg_spec.update(module_option_spec)
192 check_galaxy_version(module_arg_spec)
193 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_passwordpolicy'),
194 supports_check_mode=True)
195 if not module._socket_path:
196 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
197 connection = Connection(module._socket_path)
198 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
199 'name', 'data', module, connection)
200 fmgr.process_crud()
201 module.exit_json(meta=module.params)
202
203
204 if __name__ == '__main__':
205 main()