Debian Codegraph @

ansible_collections/theforeman/foreman/plugins/modules/usergroup.py

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # (c) 2019 Baptiste AGASSE ([email protected])
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 from __future__ import absolute_import, division, print_function
19 __metaclass__ = type
20
21
22 DOCUMENTATION = '''
23 ---
24 module: usergroup
25 version_added: 1.0.0
26 short_description: Manage User Groups
27 description:
28 - Create, update, and delete user groups
29 author:
30 - "Baptiste Agasse (@bagasse)"
31 options:
32 name:
33 description:
34 - Name of the group
35 required: true
36 type: str
37 updated_name:
38 description:
39 - New user group name. When this parameter is set, the module will not be idempotent.
40 required: false
41 type: str
42 admin:
43 description:
44 - Whether or not the users in this group are administrators
45 required: false
46 default: false
47 type: bool
48 roles:
49 description:
50 - List of roles assigned to the group
51 required: false
52 type: list
53 elements: str
54 users:
55 description:
56 - List of users assigned to the group
57 required: false
58 type: list
59 elements: str
60 usergroups:
61 description:
62 - List of other groups assigned to the group
63 required: false
64 type: list
65 elements: str
66 extends_documentation_fragment:
67 - theforeman.foreman.foreman
68 - theforeman.foreman.foreman.entity_state
69 '''
70
71 EXAMPLES = '''
72 - name: Create a user group
73 theforeman.foreman.usergroup:
74 name: test
75 admin: false
76 roles:
77 - Manager
78 users:
79 - myuser1
80 - myuser2
81 usergroups:
82 - mynestedgroup
83 state: present
84 '''
85
86 RETURN = '''
87 entity:
88 description: Final state of the affected entities grouped by their type.
89 returned: success
90 type: dict
91 contains:
92 usergroups:
93 description: List of usergroups.
94 type: list
95 elements: dict
96 '''
97
98 from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import ForemanEntityAnsibleModule
99
100
101 class ForemanUsergroupModule(ForemanEntityAnsibleModule):
102 pass
103
104
105 def main():
106 module = ForemanUsergroupModule(
107 argument_spec=dict(
108 updated_name=dict(),
109 ),
110 foreman_spec=dict(
111 name=dict(required=True),
112 admin=dict(required=False, type='bool', default=False),
113 users=dict(required=False, type='entity_list'),
114 usergroups=dict(required=False, type='entity_list'),
115 roles=dict(required=False, type='entity_list'),
116 ),
117 )
118
119 with module.api_connection():
120 module.run()
121
122
123 if __name__ == '__main__':
124 main()