Debian Codegraph @

ansible_collections/pcg/alpaca_operator/docs/alpaca_system.md

raw
1 # ALPACA System Module
2
3 ## Overview
4
5 The `pcg.alpaca_operator.alpaca_system` module allows you to create, update, or delete [ALPACA Operator](https://alpaca.pcg.io/) systems using the REST API. In addition to general system properties, it supports assigning agents and variables. Communication is handled using token-based authentication.
6
7 ## Module Information
8
9 - **Module Name**: `pcg.alpaca_operator.alpaca_system`
10 - **Short Description**: Manage ALPACA Operator systems via REST API
11 - **Version Added**: 1.0.0
12 - **Requirements**:
13 - Python >= 3.9
14 - ansible-core >= 2.12
15 - ALPACA Operator >= 5.6.0
16
17 ## Parameters
18
19 ### Required Parameters
20
21 | Parameter | Type | Required | Description |
22 | ---------------- | ---- | -------- | -------------------------------------------------------- |
23 | `name` | str | Yes | Unique name (hostname) of the system |
24 | `api_connection` | dict | Yes | Connection details for accessing the ALPACA Operator API |
25
26 ### Optional Parameters
27
28 | Parameter | Type | Required | Default | Description |
29 | ----------------- | ---- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30 | `new_name` | str | No | - | Optional new name for the system. If the system specified in `name` exists, it will be renamed to this value. If the system does not exist, a new system will be created using this value. |
31 | `description` | str | No | - | Description of the system |
32 | `magic_number` | int | No | - | Custom numeric field between 0 and 59. Can be used for arbitrary logic in your setup |
33 | `checks_disabled` | bool | No | - | Disable automatic system health checks |
34 | `group_name` | str | No | - | Name of the group to which the system should belong |
35 | `group_id` | int | No | - | ID of the group (used if `group_name` is not provided) |
36 | `rfc_connection` | dict | No | - | Connection details for RFC communication |
37 | `agents` | list | No | - | A list of agents to assign to the system |
38 | `variables` | list | No | - | A list of variables to assign to the system |
39 | `variables_mode` | str | No | update | Controls how variables are handled when updating the system (update, replace). The value `update` adds missing variables and updates existing ones. The value `replace` adds missing variables, updates existing ones, and removes variables not defined in the playbook. |
40 | `state` | str | No | present | Desired state of the system (present, absent) |
41
42 ### Magic Number Choices
43
44 The `magic_number` parameter accepts values from 0 to 59.
45
46 ### RFC Connection Configuration
47
48 The `rfc_connection` parameter accepts a dictionary with the following sub-options:
49
50 | Parameter | Type | Required | Description |
51 | ------------------- | ---- | -------- | --------------------------------------------------------------------------------- |
52 | `type` | str | No | Type of RFC connection (none, instance, messageServer) |
53 | `host` | str | No | Hostname or IP address of the RFC target system |
54 | `instance_number` | int | No | Instance number of the RFC connection (0-99) |
55 | `sid` | str | No | SAP system ID (SID), consisting of 3 uppercase alphanumeric characters (A-Z, 0-9) |
56 | `logon_group` | str | No | Logon group (used with message server type) |
57 | `username` | str | No | Username for RFC connection |
58 | `password` | str | No | Password for the RFC connection |
59 | `client` | str | No | Client for RFC connection |
60 | `sap_router_string` | str | No | SAProuter string used to establish the RFC connection |
61 | `snc_enabled` | bool | No | Enable or disable SNC |
62
63 **Type Choices**: none, instance, messageServer
64
65 **Instance Number Choices**: 0-99
66
67 #### ⚠️ Important Note About RFC Password
68
69 **IMPORTANT**: If you specify the `password` parameter in the `rfc_connection` block in your playbook, the module will **ALWAYS** report a change (`changed=true`) on every playbook run, even if nothing has actually changed.
70
71 **Why does this happen?**
72 - The ALPACA Operator API does not return the current RFC password for security reasons
73 - The module cannot compare the desired password with the current password
74 - Therefore, it cannot determine if the password actually needs to be updated
75 - This breaks the idempotency of the module
76
77 **Best Practice:**
78 1. **Initial Setup**: Include the password when creating the system for the first time
79 2. **After Setup**: Comment out or remove the `password` parameter from your playbook
80 3. **Password Changes**: Only uncomment the password when you actually need to change it
81 ```
82
83 This approach maintains idempotency while still allowing you to manage RFC passwords when needed.
84
85 ### Agent Assignment
86
87 The `agents` parameter accepts a list of dictionaries, where each dictionary must include:
88
89 | Parameter | Type | Required | Description |
90 | --------- | ---- | -------- | ----------------- |
91 | `name` | str | Yes | Name of the agent |
92
93 ### Variable Assignment
94
95 The `variables` parameter accepts a list of dictionaries, where each dictionary must include:
96
97 | Parameter | Type | Required | Description |
98 | --------- | ---- | -------- | ------------------------------- |
99 | `name` | str | Yes | Name of the variable |
100 | `value` | raw | Yes | Value to assign to the variable |
101
102 ### API Connection Configuration
103
104 The `api_connection` parameter requires a dictionary with the following sub-options:
105
106 | Parameter | Type | Required | Default | Description |
107 | ------------ | ---- | -------- | --------- | ----------------------------------------------------------- |
108 | `username` | str | Yes | - | Username for authentication against the ALPACA Operator API |
109 | `password` | str | Yes | - | Password for authentication against the ALPACA Operator API |
110 | `protocol` | str | No | https | Protocol to use (http or https) |
111 | `host` | str | No | localhost | Hostname of the ALPACA Operator server |
112 | `port` | int | No | 8443 | Port of the ALPACA Operator API |
113 | `tls_verify` | bool | No | true | Validate SSL certificates |
114
115 ## Examples
116
117 ### Create a System with Full Configuration
118
119 ```yaml
120 - name: Ensure system exists
121 hosts: local
122 gather_facts: false
123
124 vars:
125 api_connection:
126 host: "{{ ALPACA_Operator_API_Host }}"
127 protocol: "{{ ALPACA_Operator_API_Protocol }}"
128 port: "{{ ALPACA_Operator_API_Port }}"
129 username: "{{ ALPACA_Operator_API_Username }}"
130 password: "{{ ALPACA_Operator_API_Password }}"
131 tls_verify: "{{ ALPACA_Operator_API_Validate_Certs }}"
132
133 tasks:
134 - name: Create system
135 pcg.alpaca_operator.alpaca_system:
136 name: system01
137 description: My Test System
138 magic_number: 42
139 checks_disabled: false
140 group_name: test-group
141 rfc_connection:
142 type: instance
143 host: test-host
144 instance_number: 30
145 sid: ABC
146 logon_group: my-logon-group
147 username: rfc_myUser
148 password: rfc_myPasswd
149 client: 123
150 sap_router_string: rfc_SAPRouter
151 snc_enabled: false
152 agents:
153 - name: localhost
154 - name: testjan01-agent
155 variables:
156 - name: "<BKP_DATA_CLEANUP_INT>"
157 value: "19"
158 - name: "<BKP_DATA_CLEANUP_INT2>"
159 value: "this is a string"
160 - name: "<BKP_DATA_DEST2>"
161 value: "11"
162 state: present
163 api_connection: "{{ api_connection }}"
164 ```
165
166 ### Delete a System
167
168 ```yaml
169 - name: Ensure system is absent
170 hosts: local
171 gather_facts: false
172
173 vars:
174 api_connection:
175 host: "{{ ALPACA_Operator_API_Host }}"
176 protocol: "{{ ALPACA_Operator_API_Protocol }}"
177 port: "{{ ALPACA_Operator_API_Port }}"
178 username: "{{ ALPACA_Operator_API_Username }}"
179 password: "{{ ALPACA_Operator_API_Password }}"
180 tls_verify: "{{ ALPACA_Operator_API_Validate_Certs }}"
181
182 tasks:
183 - name: Delete system
184 pcg.alpaca_operator.alpaca_system:
185 name: system01
186 state: absent
187 api_connection: "{{ api_connection }}"
188 ```
189
190 ### Rename a System
191
192 ```yaml
193 - name: Rename an existing system
194 hosts: local
195 gather_facts: false
196
197 vars:
198 api_connection:
199 host: "{{ ALPACA_Operator_API_Host }}"
200 protocol: "{{ ALPACA_Operator_API_Protocol }}"
201 port: "{{ ALPACA_Operator_API_Port }}"
202 username: "{{ ALPACA_Operator_API_Username }}"
203 password: "{{ ALPACA_Operator_API_Password }}"
204 tls_verify: "{{ ALPACA_Operator_API_Validate_Certs }}"
205
206 tasks:
207 - name: Rename system
208 pcg.alpaca_operator.alpaca_system:
209 name: system01
210 new_name: system_renamed
211 api_connection: "{{ api_connection }}"
212 ```
213
214 ### Create a System with RFC Connection Only
215
216 ```yaml
217 - name: Create system with RFC connection
218 hosts: local
219 gather_facts: false
220
221 vars:
222 api_connection:
223 host: "{{ ALPACA_Operator_API_Host }}"
224 protocol: "{{ ALPACA_Operator_API_Protocol }}"
225 port: "{{ ALPACA_Operator_API_Port }}"
226 username: "{{ ALPACA_Operator_API_Username }}"
227 password: "{{ ALPACA_Operator_API_Password }}"
228 tls_verify: "{{ ALPACA_Operator_API_Validate_Certs }}"
229
230 tasks:
231 - name: Create SAP system
232 pcg.alpaca_operator.alpaca_system:
233 name: sap-system-01
234 description: SAP Production System
235 rfc_connection:
236 type: instance
237 host: sap-prod-server
238 instance_number: 00
239 sid: PRD
240 username: rfc_user
241 password: rfc_password
242 client: 100
243 state: present
244 api_connection: "{{ api_connection }}"
245 ```
246
247 ### Create a System with Variables Only
248
249 ```yaml
250 - name: Create system with variables
251 hosts: local
252 gather_facts: false
253
254 vars:
255 api_connection:
256 host: "{{ ALPACA_Operator_API_Host }}"
257 protocol: "{{ ALPACA_Operator_API_Protocol }}"
258 port: "{{ ALPACA_Operator_API_Port }}"
259 username: "{{ ALPACA_Operator_API_Username }}"
260 password: "{{ ALPACA_Operator_API_Password }}"
261 tls_verify: "{{ ALPACA_Operator_API_Validate_Certs }}"
262
263 tasks:
264 - name: Create configuration system
265 pcg.alpaca_operator.alpaca_system:
266 name: config-system-01
267 description: Configuration System
268 variables:
269 - name: "BACKUP_PATH"
270 value: "/backup/data"
271 - name: "RETENTION_DAYS"
272 value: "30"
273 - name: "ENVIRONMENT"
274 value: "production"
275 state: present
276 api_connection: "{{ api_connection }}"
277 ```
278
279 ## Return Values
280
281 | Parameter | Type | Returned | Description |
282 | --------- | ---- | --------------------- | ------------------------------------- |
283 | `system` | dict | when state is present | System details |
284 | `msg` | str | always | Status message describing the outcome |
285 | `changed` | bool | always | Whether any changes were made |
286
287 ### Return Value Examples
288
289 #### Successful System Creation
290
291 ```json
292 {
293 "system": {
294 "id": 42,
295 "name": "system01",
296 "description": "My Test System",
297 "magic_number": 42,
298 "checks_disabled": false,
299 "group_name": "test-group",
300 "rfc_connection": {
301 "type": "instance",
302 "host": "test-host",
303 "instance_number": 30,
304 "sid": "ABC"
305 },
306 "agents": [
307 {"name": "localhost"},
308 {"name": "testjan01-agent"}
309 ],
310 "variables": [
311 {"name": "<BKP_DATA_CLEANUP_INT>", "value": "19"},
312 {"name": "<BKP_DATA_CLEANUP_INT2>", "value": "this is a string"}
313 ]
314 },
315 "msg": "System created successfully",
316 "changed": true
317 }
318 ```
319
320 ## Notes
321
322 - The module supports check mode for previewing changes without applying them
323 - System names must be unique within the ALPACA Operator environment
324 - When renaming a system, the new name must not conflict with existing system names
325 - The `magic_number` field can be used for custom logic in your setup
326 - RFC connections support both instance and message server types
327 - Agent assignments and variable assignments are optional
328 - The currently configured RFC password cannot be retrieved or compared via the API
329 - To ensure a new RFC password is applied, you must change at least one additional attribute
330 - Variables can be of any type (string, integer, boolean, etc.)
331 - The module uses token-based authentication for API communication
332 - API connection variables should be stored in the inventory file and referenced via `api_connection: "{{ api_connection }}"` in playbooks
333
334 ## Author
335
336 - Jan-Karsten Hansmeyer (@pcg)