Technical Reference: Rhapsody Properties Management Logic
Parent Page: [How-To: Rhapsody Configuration] Description: This document details the technical execution performed by the Ansible playbook (play-rhapsody-properties.yml) when the "Rhapsody Properties" workflow is triggered.
🔍 High-Level Overview
This automation acts as a safe, controlled interface for modifying the primary Rhapsody configuration file (rhapsody.properties). Instead of manual editing (which risks syntax errors or permissions issues), this playbook creates automatic backups, enforces permissions, and supports specific "CRUD" (Create, Read, Update, Delete) operations based on the selected Action.
🔄 Workflow Diagram
graph TD
A[Start] --> B{Select Action}
B -- list_backups --> C[List files in Conf Dir]
B -- display --> D[Cat/Grep Property File]
B -- update/delete --> E[LineInFile Operation]
B -- (S)FTP_auto_add --> F[Toggle Specific Key]
B -- restore --> G[Shell Copy/Restore]
E --> H{Restart Requested?}
F --> H
G --> H
H -- Yes --> I[Trigger Restart Handler]
H -- No --> J[Finish]
C --> J
D --> J
🛠️ Detailed Execution Steps
The playbook execution path diverges completely based on the PLAYBOOK_ACTION input.
1. Action: list_backups
-
Command:
ls -rhtlon the configuration directory. -
Filter: Matches files starting with the standard property filename.
-
Output: Displays a list of all backup files (generated by Ansible or manual copies), sorted by time, to help the user identify which file to restore or inspect.
2. Action: display / display_backup_property_file
-
Target: Reads either the live
rhapsody.propertiesor a specific backup file provided in inputs. -
Filtering Logic:
-
If
DISPLAY_ONLY_UNCOMMENTED_SETTINGSis True: Usesgrep -v ^#andgrep -v ^$to strip out all comments and empty lines. This provides a clean view of the active configuration. -
If False: Uses
catto output the raw file content, including comments.
-
3. Action: update / delete
This block modifies specific Key-Value pairs.
-
Validation: Asserts that
PROPERTY_KEYandPROPERTY_VALUEare defined. -
Mechanism: Uses the Ansible
lineinfilemodule.-
Update: searches for the key and replaces the line with
key=value. -
Delete: searches for the key and sets the state to
absent.
-
-
Safety: The
backup: trueflag is enabled. Ansible automatically creates a timestamped backup of the file before modifying it, ensuring a rollback path exists if the update breaks the engine.
4. Action: (S)FTP_auto_add_key
A shortcut action for a specific security setting commonly toggled during debugging.
-
Target Key:
FileTransferModule.allowAutoAddingCertificatesAndKeys -
Value:
enabled -
Logic:
-
If input is
on, ensure the line exists (present). -
If input is
off, remove the line (absent).
-
5. Action: restore
Reverts the configuration to a previous state.
-
Validation: Verifies the
PROPERTY_FILE_TO_RESTORE_FROMactually exists on the filesystem. -
Execution (Shell Command Chain):
-
Safety Backup: Copies the current (potentially broken)
rhapsody.propertiesto a new timestamped file (e.g.,~YYYY-MM-DD...). This ensures that "restoring" never destroys the current state irreversibly. -
Overwrite: Copies the selected backup file over
rhapsody.properties. -
Permissions: Runs
chown rhapsody:rhapsodyto ensure the engine can read the restored file.
-
6. Service Restart
-
Trigger: If the input
restart_engineis set totrue. -
Handler: Notifies the generic "restart rhapsody" handler to bounce the service, loading the new configurations.
⚠️ Technical Notes & Constraints
-
Regex Limitations: The
updateaction uses regex to find keys. If the property file has duplicate keys (which is invalid but possible),lineinfiletypically only modifies the last occurrence. -
Backup Accumulation: Both
updateandrestoreactions generate backup files. Over time, the configuration directory may accumulate many timestamped copies (rhapsody.properties.YYYY...). Periodic cleanup may be required. -
Permissions: All file operations run as the
rhapsodyuser to prevent permission lockouts.