Skip to content

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 -rhtl on 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.properties or a specific backup file provided in inputs.

  • Filtering Logic:

    • IfDISPLAY_ONLY_UNCOMMENTED_SETTINGSis True: Uses grep -v ^# and grep -v ^$ to strip out all comments and empty lines. This provides a clean view of the active configuration.

    • If False: Uses cat to output the raw file content, including comments.

3. Action: update / delete

This block modifies specific Key-Value pairs.

  • Validation: Asserts that PROPERTY_KEY and PROPERTY_VALUE are defined.

  • Mechanism: Uses the Ansible lineinfile module.

    • 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: true flag 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_FROM actually exists on the filesystem.

  • Execution (Shell Command Chain):

    1. Safety Backup: Copies the current (potentially broken) rhapsody.properties to a new timestamped file (e.g., ~YYYY-MM-DD...). This ensures that "restoring" never destroys the current state irreversibly.

    2. Overwrite: Copies the selected backup file over rhapsody.properties.

    3. Permissions: Runs chown rhapsody:rhapsody to ensure the engine can read the restored file.

6. Service Restart

  • Trigger: If the input restart_engine is set to true.

  • Handler: Notifies the generic "restart rhapsody" handler to bounce the service, loading the new configurations.

⚠️ Technical Notes & Constraints

  • Regex Limitations: The update action uses regex to find keys. If the property file has duplicate keys (which is invalid but possible), lineinfile typically only modifies the last occurrence.

  • Backup Accumulation: Both update and restore actions 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 rhapsody user to prevent permission lockouts.