Added directory validation to offline installs#307
Added directory validation to offline installs#307Nick-Andreano wants to merge 3 commits intoitential:devfrom
Conversation
| - 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| - 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. |
roles/redis/tasks/validate-vars.yml
Outdated
| - 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. |
| - 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I see, that makes sense. I will remove these two tasks.
Added directory validation to offline installs