Skip to content

Added directory validation to offline installs#307

Open
Nick-Andreano wants to merge 3 commits intoitential:devfrom
Nick-Andreano:main
Open

Added directory validation to offline installs#307
Nick-Andreano wants to merge 3 commits intoitential:devfrom
Nick-Andreano:main

Conversation

@Nick-Andreano
Copy link
Contributor

Added directory validation to offline installs

Comment on lines +75 to +88
- name: Extract OS directory name from mongodb_offline_packages_root
ansible.builtin.set_fact:
mongodb_offline_os_dir: "{{ mongodb_offline_packages_root.split('/')[1] }}"

- name: Assert offline packages directory matches target node OS
ansible.builtin.assert:
that: >-
mongodb_offline_os_dir ==
ansible_distribution | lower ~ '_' ~ ansible_distribution_major_version
fail_msg: >-
Offline packages directory '{{ mongodb_offline_os_dir }}' does not match
target node OS
'{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}'.
Ensure offline packages were built for the correct OS and version.
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the intent here, but I'm not sure we want to validate the actual path because the user can override the offline_itential_packages_path variable. The other option would be to move the offline_itential_packages_path to a vars file so that it can't be overridden.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also depending on what we decide, the fail_msg might have to change to something like:

Offline packages directory '{{ mongodb_offline_os_dir }}' does not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve update the PR to pull the dir from the common role. I should fix the problem if the user overrides offline_itential_packages_path.

Comment on lines +133 to +146
- name: Extract OS directory name from platform_offline_packages_root
ansible.builtin.set_fact:
platform_offline_os_dir: "{{ platform_offline_packages_root.split('/')[1] }}"

- name: Assert offline packages directory matches target node OS
ansible.builtin.assert:
that: >-
platform_offline_os_dir ==
ansible_distribution | lower ~ '_' ~ ansible_distribution_major_version
fail_msg: >-
Offline packages directory '{{ platform_offline_os_dir }}' does not match
target node OS
'{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}'.
Ensure offline packages were built for the correct OS and version.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Comment on lines +120 to +133
- name: Extract OS directory name from redis_offline_packages_root
ansible.builtin.set_fact:
redis_offline_os_dir: "{{ redis_offline_packages_root.split('/')[1] }}"

- name: Assert offline packages directory matches target node OS
ansible.builtin.assert:
that: >-
redis_offline_os_dir ==
ansible_distribution | lower ~ '_' ~ ansible_distribution_major_version
fail_msg: >-
Offline packages directory '{{ redis_offline_os_dir }}' does not match
target node OS
'{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}'.
Ensure offline packages were built for the correct OS and version.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Comment on lines +75 to +88
- name: Extract OS directory name from offline_itential_packages_path
ansible.builtin.set_fact:
mongodb_offline_os_dir: "{{ offline_itential_packages_path.split('/') | last }}"

- name: Assert offline packages directory matches target node OS
ansible.builtin.assert:
that: >-
mongodb_offline_os_dir ==
ansible_distribution | lower ~ '_' ~ ansible_distribution_major_version
fail_msg: >-
Offline packages directory '{{ mongodb_offline_os_dir }}' does not match
target node OS
'{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}'.
Ensure offline packages were built for the correct OS and version.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is still an issue with this check. TLDR - I think it should be removed.

Scenario 1: The user doesn't override offline_itential_packages_path in their inventory.
In this case, by definition the offline packages directory will match the target node OS. So this assertion will never fail.

Scenario 2: The user overrides the offline_itential_packages_path.
At this point we have no idea what they set the path to. So there is no way to validate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, that makes sense. I will remove these two tasks.

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.

2 participants