Debian Codegraph @

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

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # (c) 2016, Eric D Helms <[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: product
25 version_added: 1.0.0
26 short_description: Manage Products
27 description:
28 - Create and manage products
29 author:
30 - "Eric D Helms (@ehelms)"
31 - "Matthias Dellweg (@mdellweg) ATIX AG"
32 options:
33 name:
34 description:
35 - Name of the product
36 required: true
37 type: str
38 label:
39 description:
40 - Label to show the user
41 required: false
42 type: str
43 gpg_key:
44 description:
45 - Content GPG key name attached to this product
46 required: false
47 type: str
48 ssl_ca_cert:
49 description:
50 - Content SSL CA certificate name attached to this product
51 required: false
52 type: str
53 ssl_client_cert:
54 description:
55 - Content SSL client certificate name attached to this product
56 required: false
57 type: str
58 ssl_client_key:
59 description:
60 - Content SSL client private key name attached to this product
61 required: false
62 type: str
63 sync_plan:
64 description:
65 - Sync plan name attached to this product
66 required: false
67 type: str
68 description:
69 description:
70 - Possibly long description to show the user in detail view
71 required: false
72 type: str
73 extends_documentation_fragment:
74 - theforeman.foreman.foreman
75 - theforeman.foreman.foreman.entity_state_with_defaults
76 - theforeman.foreman.foreman.organization
77 '''
78
79 EXAMPLES = '''
80 - name: "Create Fedora product with a sync plan"
81 theforeman.foreman.product:
82 username: "admin"
83 password: "changeme"
84 server_url: "https://foreman.example.com"
85 name: "Fedora"
86 organization: "My Cool new Organization"
87 sync_plan: "Fedora repos sync"
88 state: present
89
90 - name: "Create CentOS 7 product with content credentials"
91 theforeman.foreman.product:
92 username: "admin"
93 password: "changeme"
94 server_url: "https://foreman.example.com"
95 name: "CentOS 7"
96 gpg_key: "RPM-GPG-KEY-CentOS7"
97 organization: "My Cool new Organization"
98 state: present
99 '''
100
101 RETURN = '''
102 entity:
103 description: Final state of the affected entities grouped by their type.
104 returned: success
105 type: dict
106 contains:
107 products:
108 description: List of products.
109 type: list
110 elements: dict
111 '''
112
113
114 from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import KatelloEntityAnsibleModule
115
116
117 class KatelloProductModule(KatelloEntityAnsibleModule):
118 pass
119
120
121 def main():
122 module = KatelloProductModule(
123 foreman_spec=dict(
124 name=dict(required=True),
125 label=dict(),
126 gpg_key=dict(type='entity', resource_type='content_credentials', scope=['organization'], no_log=False),
127 ssl_ca_cert=dict(type='entity', resource_type='content_credentials', scope=['organization']),
128 ssl_client_cert=dict(type='entity', resource_type='content_credentials', scope=['organization']),
129 ssl_client_key=dict(type='entity', resource_type='content_credentials', scope=['organization'], no_log=False),
130 sync_plan=dict(type='entity', scope=['organization']),
131 description=dict(),
132 ),
133 argument_spec=dict(
134 state=dict(default='present', choices=['present_with_defaults', 'present', 'absent']),
135 ),
136 )
137
138 with module.api_connection():
139 module.run()
140
141
142 if __name__ == '__main__':
143 main()