Server IP : 85.214.239.14 / Your IP : 3.145.65.133 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/ |
Upload File : |
#!/usr/bin/python # (c) 2021, NetApp, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type DOCUMENTATION = """ module: na_ontap_fdsp short_description: NetApp ONTAP create or delete a file directory security policy extends_documentation_fragment: - netapp.ontap.netapp.na_ontap version_added: 21.8.0 author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> description: - Create or delete a file directory security policy. options: state: description: - Whether the specified policy should exist or not. choices: ['present', 'absent'] default: present type: str name: description: - Specifies the name of the policy. required: true type: str vserver: description: - Specifies the vserver for the security policy. required: true type: str """ EXAMPLES = """ - name: Create File Directory Security Policy netapp.ontap.na_ontap_fdsp: state: present name: "ansible_security_policyl" vserver: "svm1" hostname: "{{ hostname }}" username: "{{ username }}" password: "{{ password }}" - name: Delete File Directory Security Policy netapp.ontap.na_ontap_fdsp: state: absent vserver: "svm1" name: "ansible_security_policyl" hostname: "{{ hostname }}" username: "{{ username }}" password: "{{ password }}" """ RETURN = """ """ from ansible.module_utils.basic import AnsibleModule import ansible_collections.netapp.ontap.plugins.module_utils.netapp as netapp_utils from ansible_collections.netapp.ontap.plugins.module_utils.netapp_module import NetAppModule from ansible_collections.netapp.ontap.plugins.module_utils.netapp import OntapRestAPI import ansible_collections.netapp.ontap.plugins.module_utils.rest_response_helpers as rrh class NetAppOntapFDSP(): """ Creates or Destroys a File Directory Security Policy """ def __init__(self): """ Initialize the ONTAP File Directory Security Policy class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, choices=['present', 'absent'], default='present'), vserver=dict(required=True, type='str'), name=dict(required=True, type='str') )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) # set up variables self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = OntapRestAPI(self.module) self.use_rest = self.rest_api.is_rest() if not self.use_rest: self.module.fail_json(msg=self.rest_api.requires_ontap_version('na_ontap_fdsp', '9.6')) def get_fdsp(self): """ Get File Directory Security Policy """ api = "private/cli/vserver/security/file-directory/policy" query = { 'policy-name': self.parameters['name'], 'vserver': self.parameters['vserver'] } message, error = self.rest_api.get(api, query) records, error = rrh.check_for_0_or_more_records(api, message, error) if error: self.module.fail_json(msg=error) return records if records else None def add_fdsp(self): """ Adds a new File Directory Security Policy """ api = "private/cli/vserver/security/file-directory/policy" body = { 'policy-name': self.parameters['name'], 'vserver': self.parameters['vserver'] } dummy, error = self.rest_api.post(api, body) if error: self.module.fail_json(msg=error) def remove_fdsp(self): """ Deletes a File Directory Security Policy """ api = "private/cli/vserver/security/file-directory/policy" body = { 'policy-name': self.parameters['name'], 'vserver': self.parameters['vserver'] } dummy, error = self.rest_api.delete(api, body) if error: self.module.fail_json(msg=error) def apply(self): current = self.get_fdsp() cd_action = self.na_helper.get_cd_action(current, self.parameters) if self.na_helper.changed: if not self.module.check_mode: if cd_action == 'create': self.add_fdsp() elif cd_action == 'delete': self.remove_fdsp() result = netapp_utils.generate_result(self.na_helper.changed, cd_action) self.module.exit_json(**result) def main(): """ Creates or removes File Directory Security Policy """ obj = NetAppOntapFDSP() obj.apply() if __name__ == '__main__': main()