-
Notifications
You must be signed in to change notification settings - Fork 13
Playbooks & tasks to verify environment and confirm installation #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
steven-schattenberg-itential
merged 8 commits into
itential:feature/v4
from
steven-schattenberg-itential:feature/v4-certify
Feb 21, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
31c2455
remove os_compatibility.py
steven-schattenberg-itential 75c228d
Merge branch 'itential:feature/v4' into feature/v4
steven-schattenberg-itential 6915fe2
Merge branch 'itential:feature/v4' into feature/v4
steven-schattenberg-itential fa85f55
Consolidate common code
steven-schattenberg-itential 612de48
Consolidate common code
steven-schattenberg-itential 5cccd70
Check for proxy
steven-schattenberg-itential 89d0bf2
Add Proxy detection
steven-schattenberg-itential e59c12b
Make task names more descriptive
steven-schattenberg-itential File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| # Copyright (c) 2026, Itential, Inc | ||
| # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
| --- | ||
| # Common host verification tasks | ||
| # This task file expects the following variables to be set: | ||
| # - component_name: Name of the component being verified (e.g., "Redis", "Platform", "MongoDB") | ||
| # - hw_specs_var_name: Name of the hardware specs variable (e.g., "redis_hw_specs", "platform_hw_specs") | ||
|
|
||
| - name: Assert that required platform_release variable is defined | ||
| ansible.builtin.assert: | ||
| that: platform_release is defined | ||
| fail_msg: "platform_release must be defined in the inventory" | ||
|
|
||
| - name: Assert that required env variable is defined | ||
| ansible.builtin.assert: | ||
| that: env is defined | ||
| fail_msg: "platform_release must be defined in the inventory" | ||
|
|
||
| - name: Announce Intention | ||
| ansible.builtin.debug: | ||
| msg: "Validating {{ env }} host {{ inventory_hostname }} for {{ component_name }} installation..." | ||
|
|
||
| - name: Gather host information | ||
| itential.deployer.gather_host_information: | ||
| register: host_info | ||
|
|
||
| - name: Extract OS information | ||
| ansible.builtin.set_fact: | ||
| os: "{{ host_info.os }}" | ||
|
|
||
| # OS and Architecture validation | ||
| - name: Check OS compatibility | ||
| ansible.builtin.set_fact: | ||
| os_valid: >- | ||
| {{ | ||
| (os.distribution == 'RedHat' and ansible_distribution_major_version in ['8', '9']) or | ||
| (os.distribution == 'Rocky' and ansible_distribution_major_version in ['8', '9']) or | ||
| (os.distribution == 'OracleLinux' and ansible_distribution_major_version in ['8', '9']) or | ||
| (os.distribution == 'Amazon' and ansible_distribution_major_version == '2023') | ||
| }} | ||
|
|
||
| - name: Assert that this is a supported OS | ||
| ansible.builtin.assert: | ||
| that: "{{ os_valid }} == true" | ||
| fail_msg: "{{ os.distribution }} {{ os.distribution_version }} is not a supported OS!" | ||
| success_msg: "OS validation passed!" | ||
| quiet: true | ||
|
|
||
| - name: Check architecture compatibility | ||
| ansible.builtin.set_fact: | ||
| arch_valid: "{{ os.architecture in ['x86_64', 'aarch64'] }}" | ||
|
|
||
| - name: Assert that this is a supported Architecture | ||
| ansible.builtin.assert: | ||
| that: "{{ arch_valid }} == true" | ||
| fail_msg: "{{ os.architecture }} is not a supported architecture!" | ||
| success_msg: "Architecture validation passed!" | ||
| quiet: true | ||
|
|
||
| - name: Initialize validation errors list | ||
| ansible.builtin.set_fact: | ||
| validation_errors: [] | ||
|
|
||
| - name: Get root partition size | ||
| ansible.builtin.set_fact: | ||
| root_disk_size_gb: "{{ (ansible_mounts | selectattr('mount', 'equalto', '/') | map(attribute='size_total') | first / 1024 / 1024 / 1024) | round(2) }}" | ||
| when: ansible_mounts | selectattr('mount', 'equalto', '/') | list | length > 0 | ||
|
|
||
| - name: Validate hardware specs against requirements | ||
| ansible.builtin.set_fact: | ||
| hardware_validation: | ||
| required: | ||
| cpu_count: "{{ vars[hw_specs_var_name][env].cpu_count if vars[hw_specs_var_name] != 'none' else 'N/A' }}" | ||
| ram_size_gb: "{{ vars[hw_specs_var_name][env].ram_size if vars[hw_specs_var_name] != 'none' else 'N/A' }}" | ||
| disk_size_gb: "{{ vars[hw_specs_var_name][env].disk_size if vars[hw_specs_var_name] != 'none' else 'N/A' }}" | ||
| actual: | ||
| cpu_count: "{{ ansible_processor_vcpus }}" | ||
| ram_size_gb: "{{ (ansible_memtotal_mb / 1024) | round(2) }}" | ||
| disk_size_gb: "{{ root_disk_size_gb | default('N/A') }}" | ||
| validation: | ||
| cpu_valid: "{{ (env == 'none') or (ansible_processor_vcpus >= vars[hw_specs_var_name][env].cpu_count) }}" | ||
| ram_valid: "{{ (env == 'none') or ((ansible_memtotal_mb / 1024) >= vars[hw_specs_var_name][env].ram_size) }}" | ||
| disk_valid: "{{ (env == 'none') or ((root_disk_size_gb | default(0) | float) >= vars[hw_specs_var_name][env].disk_size) }}" | ||
| all_valid: "{{ (env == 'none') or ((ansible_processor_vcpus >= vars[hw_specs_var_name][env].cpu_count) and ((ansible_memtotal_mb / 1024) >= vars[hw_specs_var_name][env].ram_size) and ((root_disk_size_gb | default(0) | float) >= vars[hw_specs_var_name][env].disk_size)) }}" | ||
|
|
||
| - name: Validate CPU Count | ||
| ansible.builtin.assert: | ||
| that: hardware_validation.validation.cpu_valid | bool | ||
| fail_msg: "CPU validation failed!" | ||
| quiet: true | ||
| ignore_errors: true | ||
| register: cpu_validation | ||
|
|
||
| - name: Add CPU error to list | ||
| ansible.builtin.set_fact: | ||
| validation_errors: "{{ validation_errors + ['CPU: ' ~ hardware_validation.required.cpu_count ~ ' required, ' ~ hardware_validation.actual.cpu_count ~ ' found'] }}" | ||
| when: cpu_validation is failed | ||
|
|
||
| - name: Validate memory amount | ||
| ansible.builtin.assert: | ||
| that: hardware_validation.validation.ram_valid | bool | ||
| fail_msg: "Memory validation failed!" | ||
| quiet: true | ||
| ignore_errors: true | ||
| register: memory_validation | ||
|
|
||
| - name: Add memory error to list | ||
| ansible.builtin.set_fact: | ||
| validation_errors: "{{ validation_errors + ['RAM: ' ~ hardware_validation.required.ram_size_gb ~ 'GB required, ' ~ hardware_validation.actual.ram_size_gb ~ 'GB found'] }}" | ||
| when: memory_validation is failed | ||
|
|
||
| - name: Validate disk size | ||
| ansible.builtin.assert: | ||
| that: hardware_validation.validation.disk_valid | bool | ||
| fail_msg: "Disk validation failed!" | ||
| quiet: true | ||
| ignore_errors: true | ||
| register: disk_validation | ||
|
|
||
| - name: Add disk error to list | ||
| ansible.builtin.set_fact: | ||
| validation_errors: "{{ validation_errors + ['Disk: ' ~ hardware_validation.required.disk_size_gb ~ 'GB required, ' ~ hardware_validation.actual.disk_size_gb ~ 'GB found'] }}" | ||
| when: disk_validation is failed | ||
|
|
||
| - name: Print host information | ||
| ansible.builtin.debug: | ||
| msg: "{{ host_info }}" | ||
|
|
||
| # Check for proxy | ||
| - name: Check for proxy settings in environment variables | ||
| ansible.builtin.shell: set -o pipefail && env | grep -i proxy | ||
| register: env_proxy | ||
| failed_when: false | ||
| changed_when: false | ||
|
|
||
| - name: Check for proxy settings in /etc/environment | ||
| ansible.builtin.shell: set -o pipefail && grep -i proxy /etc/environment | ||
| register: etc_env_proxy | ||
| failed_when: false | ||
| changed_when: false | ||
|
|
||
| - name: Check for proxy settings in /etc/profile.d | ||
| ansible.builtin.shell: set -o pipefail && grep -ri proxy /etc/profile.d/ | ||
| register: profiled_proxy | ||
| failed_when: false | ||
| changed_when: false | ||
|
|
||
| - name: Display all proxy findings | ||
| ansible.builtin.debug: | ||
| msg: | ||
| - "Environment variables: {{ env_proxy.stdout_lines | default([]) }}" | ||
| - "/etc/environment: {{ etc_env_proxy.stdout_lines | default([]) }}" | ||
| - "/etc/profile.d: {{ profiled_proxy.stdout_lines | default([]) }}" | ||
|
|
||
| - name: Assert that there are no proxy settings | ||
| ansible.builtin.assert: | ||
| that: | ||
| - env_proxy.stdout_lines | length == 0 | ||
| - etc_env_proxy.stdout_lines | length == 0 | ||
| - profiled_proxy.stdout_lines | length == 0 | ||
| fail_msg: "A Proxy was detected!" | ||
| quiet: true | ||
| ignore_errors: true | ||
| register: proxy_validation | ||
kvelarde-itential marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Display results | ||
| - name: Display failed validation results | ||
| ansible.builtin.debug: | ||
| msg: "{{ validation_errors }}" | ||
| when: cpu_validation is failed or memory_validation is failed or disk_validation is failed | ||
|
|
||
| # Assert that none of the tests failed | ||
| - name: Verify that all tests passed | ||
| ansible.builtin.assert: | ||
| that: | ||
| - "cpu_validation is not failed" | ||
| - "memory_validation is not failed" | ||
| - "disk_validation is not failed" | ||
| - "proxy_validation is not failed" | ||
| fail_msg: "See above, assertions not passed! ✗" | ||
| success_msg: "All assertions passed! ✓" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.