Skip to content

fix: fix added for moneo install path#59

Merged
spetrosi merged 1 commit intolinux-system-roles:mainfrom
ggoklani:fix_moneo_path
Feb 3, 2026
Merged

fix: fix added for moneo install path#59
spetrosi merged 1 commit intolinux-system-roles:mainfrom
ggoklani:fix_moneo_path

Conversation

@ggoklani
Copy link
Copy Markdown
Collaborator

@ggoklani ggoklani commented Feb 2, 2026

Enhancement: Change installation path for moneo monitoring tool

Reason:
The structure we want to use for static files follows this template:
{{/opt/hpc//bin/ # one-off binaries and scripts
/opt/hpc//lib/... # resources and libraries
/opt/hpc//tools/... # standalone tools
/opt/hpc//tests/ # test scripts for local/CI testing}}

For runtime files (e.g. configuration files set up by boot services), we will store them in:

/var/hpc//....

These common directories will be defined by the following set of variables:
{{_hpc_resource_dir # /opt/hpc//
_hpc_tools_dir # /opt/hpc//tools/
_hpc_tests_dir # /opt/hpc//tests/
_hpc_runtime_dir # /var/hpc//}}
Result: NA

Issue Tracker Tickets (Jira or BZ if any): https://issues.redhat.com/browse/RHELHPC-140

Summary by Sourcery

Update Moneo installation handling to support the new install path while preserving compatibility with existing service configuration scripts.

Enhancements:

  • Define the Moneo installation directory variable alongside other Azure directory variables for consistency.
  • Introduce a legacy symlink from the old Moneo path to the new installation location to keep existing configure_service.sh usage working.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 2, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the Moneo installation handling so it continues to reside under the Azure tools directory variable while adding a backward-compatible symlink from the legacy /opt/azurehpc/tools path when needed, ensuring configure_service.sh keeps working with the new directory layout.

Sequence diagram for Moneo installation and legacy symlink handling

sequenceDiagram
    participant AnsibleTask as Ansible_play
    participant Vars as Ansible_vars
    participant FS as Filesystem
    participant MoneoService as configure_service_sh

    AnsibleTask->>Vars: Read __hpc_install_prefix
    AnsibleTask->>Vars: Resolve __hpc_azure_resource_dir
    AnsibleTask->>Vars: Resolve __hpc_azure_tools_dir
    AnsibleTask->>Vars: Resolve __hpc_moneo_install_dir from __hpc_azure_tools_dir

    AnsibleTask->>FS: Ensure Moneo is installed at __hpc_moneo_install_dir/Moneo

    alt __hpc_moneo_install_dir != /opt/azurehpc/tools
        AnsibleTask->>FS: Create directory /opt/azurehpc/tools
        AnsibleTask->>FS: Create symlink /opt/azurehpc/tools/Moneo -> __hpc_moneo_install_dir/Moneo
    else __hpc_moneo_install_dir == /opt/azurehpc/tools
        AnsibleTask-->>FS: Skip legacy symlink creation
    end

    AnsibleTask->>MoneoService: Execute __hpc_moneo_install_dir/Moneo/linux_service/configure_service_sh
    MoneoService-->>FS: Use resolved Moneo path (direct or via symlink)
Loading

File-Level Changes

Change Details Files
Add a backward-compatible symlink from the legacy Moneo install path to the new install directory when they differ.
  • Gate the compatibility logic on __hpc_moneo_install_dir not being '/opt/azurehpc/tools' to avoid unnecessary changes when using the legacy path.
  • Ensure the legacy parent directory /opt/azurehpc/tools exists with root ownership and 0755 permissions.
  • Create a symlink /opt/azurehpc/tools/Moneo pointing to {{ __hpc_moneo_install_dir }}/Moneo so existing scripts using the old path keep functioning.
tasks/main.yml
Clarify and re-order the definition of the Moneo installation directory variable while keeping it aligned with the Azure tools directory.
  • Keep __hpc_install_prefix as /opt and continue deriving Azure resource, tools, and tests directories from it.
  • Move the __hpc_moneo_install_dir definition to follow the Azure directory variables for clearer structure while still pointing it at __hpc_azure_tools_dir.
vars/main.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The legacy Moneo path /opt/azurehpc/tools is hardcoded in both the when condition and dest; consider defining a dedicated variable for the legacy path and using it consistently so future path changes only need to be updated in one place.
  • The current symlink creation does not specify behavior if /opt/azurehpc/tools/Moneo already exists as a directory or incorrect link; consider explicitly handling that case (e.g., with force or a guard) to ensure idempotent and predictable behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The legacy Moneo path `/opt/azurehpc/tools` is hardcoded in both the `when` condition and `dest`; consider defining a dedicated variable for the legacy path and using it consistently so future path changes only need to be updated in one place.
- The current symlink creation does not specify behavior if `/opt/azurehpc/tools/Moneo` already exists as a directory or incorrect link; consider explicitly handling that case (e.g., with `force` or a guard) to ensure idempotent and predictable behavior.

## Individual Comments

### Comment 1
<location> `tasks/main.yml:841-845` </location>
<code_context>
+                owner: root
+                group: root
+
+            - name: Create symlink from legacy path to actual installation
+              file:
+                src: "{{ __hpc_moneo_install_dir }}/Moneo"
+                dest: /opt/azurehpc/tools/Moneo
+                state: link

         - name: Configure Moneo service
</code_context>

<issue_to_address>
**suggestion:** Clarify behavior when /opt/azurehpc/tools/Moneo already exists (e.g., force or fail-fast)

If that path already exists (as a dir or different link), this task can fail or leave an inconsistent state. Consider either adding `force: yes` to always replace it, or gating the task with a `when`/`creates`-style check to preserve an existing install. This will keep reruns and upgrades predictable.

```suggestion
            - name: Create symlink from legacy path to actual installation
              file:
                src: "{{ __hpc_moneo_install_dir }}/Moneo"
                dest: /opt/azurehpc/tools/Moneo
                state: link
                force: true
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ggoklani ggoklani changed the title fix added for moneo install path fix: fix added for moneo install path Feb 2, 2026
vars/main.yml Outdated
__hpc_azure_resource_dir: "{{ __hpc_install_prefix }}/hpc/azure"
__hpc_azure_tools_dir: "{{ __hpc_azure_resource_dir }}/tools"
__hpc_azure_tests_dir: "{{ __hpc_azure_resource_dir }}/tests"
__hpc_moneo_install_dir: "{{ __hpc_azure_tools_dir }}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to have two variables with the same value? __hpc_azure_tools_dir and __hpc_moneo_install_dir. Why not just use __hpc_moneo_install_dir?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__hpc_azure_tools_dir is generic for all the tools which will be installed.
__hpc_moneo_install_dir: is specifically for monoe it path will be "/opt/hpc/azure/tools/moneo"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently their values are the same. I'd say in this case the code should use the original __hpc_azure_tools_dir variable for moneo.

__hpc_moneo_install_dir: is specifically for monoe it path will be "/opt/hpc/azure/tools/moneo"

Did you want to do this?
__hpc_moneo_install_dir: "{{ __hpc_azure_tools_dir }}/moneo"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is auto creating moneo directory instead tools.

  • name: Copy Moneo files to install directory
    copy:
    src: "{{ __hpc_pkg_extracted.path }}/"
    remote_src: true
    dest: "{{ __hpc_moneo_install_dir }}/Moneo"
    mode: '0755'
    owner: root
    group: root

tasks/main.yml Outdated
group: root

- name: Create legacy Moneo symlink for configure_service.sh compatibility
block:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not need a block now that there is no condition

tasks/main.yml Outdated
block:
- name: Ensure legacy Moneo parent directory exists
file:
path: /opt/azurehpc/tools
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be "{{ __hpc_azure_tools_dir }}"

tasks/main.yml Outdated
- name: Create symlink from legacy path to actual installation
file:
src: "{{ __hpc_moneo_install_dir }}/Moneo"
dest: /opt/azurehpc/tools/Moneo
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dest: /opt/azurehpc/tools/Moneo
dest: "{{ __hpc_azure_tools_dir }}/Moneo"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes done, Testing in Progress with new changes

tasks/main.yml Outdated
file:
src: "{{ __hpc_azure_tools_dir }}/Moneo"
dest: /opt/azurehpc/tools/Moneo
state: link
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I already commented on this - we should not be creating this /opt/azurehpc directory or using symlinks to point to the installation directory. If there are hard coded paths in the installed scripts (or the install script) then they need to be converted to a template and have /opt/azurehpc replaced with {{ __hpc_azure_tools_dir }} so they refer directly to the installed location in the installed scripts.

As a last resort, if we have to support /opt/azurehpc, then it needs to be defined by a variable similar to __hpc_azure_resource_dir rather than being hardcoded everywhere that needs it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgchinner I have added the patch to change the default install location to custom one.. and tested it works well.
please check and suggest if these method works or else we can do

" support /opt/azurehpc, then it needs to be defined by a variable similar to __hpc_azure_resource_dir rather than being hardcoded everywhere that needs it"

@dgchinner
Copy link
Copy Markdown
Collaborator

Looks good to me now. Thanks!

@ggoklani ggoklani requested a review from spetrosi February 3, 2026 08:30
@spetrosi spetrosi merged commit 6174a78 into linux-system-roles:main Feb 3, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants