Debian Codegraph @

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

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # (c) 2021 William Bradford Clark
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: repository_set_info
25 version_added: 2.1.0
26 short_description: Fetch information about Red Hat Repositories
27 description:
28 - Fetch information about Red Hat Repositories
29 author: "William Bradford Clark (@wbclark)"
30 options:
31 product:
32 description:
33 - Name of the parent product
34 required: false
35 type: str
36 extends_documentation_fragment:
37 - theforeman.foreman.foreman
38 - theforeman.foreman.foreman.katelloinfomodule
39 - theforeman.foreman.foreman.infomodule
40 '''
41
42 EXAMPLES = '''
43 - name: "Find repository set by name and product."
44 theforeman.foreman.repository_set_info:
45 username: "admin"
46 password: "changeme"
47 server_url: "https://foreman.example.com"
48 organization: "Default Organization"
49 name: "Red Hat Enterprise Linux 7 Server (RPMs)"
50 product: "Red Hat Enterprise Linux Server"
51
52 - name: "Find repository set by label."
53 theforeman.foreman.repository_set_info:
54 username: "admin"
55 password: "changeme"
56 server_url: "https://foreman.example.com"
57 organization: "Default Organization"
58 search: 'label = "rhel-7-server-rpms"'
59 '''
60
61 RETURN = '''
62 repository_set:
63 description: Details about the found Red Hat Repository.
64 returned: success and I(name) was passed
65 type: dict
66 repository_sets:
67 description: List of all found Red Hat Repositories and their details.
68 returned: success and I(search) was passed
69 type: list
70 elements: dict
71 '''
72
73
74 from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import KatelloInfoAnsibleModule
75
76
77 class KatelloRepositorySetInfo(KatelloInfoAnsibleModule):
78 pass
79
80
81 def main():
82 module = KatelloRepositorySetInfo(
83 foreman_spec=dict(
84 product=dict(type='entity', scope=['organization']),
85 ),
86 entity_opts={'scope': ['product']},
87 required_together=[
88 ['name', 'product'],
89 ],
90 )
91
92 # KatelloInfoAnsibleModule automatically adds organization to the entity scope
93 # but repository sets are scoped by product (and these are org scoped)
94 module.foreman_spec['entity']['scope'].remove('organization')
95
96 with module.api_connection():
97 module.run()
98
99
100 if __name__ == '__main__':
101 main()