validate_idrac_vars.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Include variable file idrac_vars.yml
  16. include_vars: "{{ idrac_input_filename }}"
  17. run_once: true
  18. - name: Include variable file base_vars.yml
  19. include_vars: "{{ base_input_filename }}"
  20. run_once: true
  21. - name: Initialize variables
  22. set_fact:
  23. snmp_trap_status: false
  24. run_once: true
  25. - name: Validate input parameters are not empty
  26. fail:
  27. msg: "{{ idrac_input_fail_msg }}"
  28. register: idrac_config_check
  29. when:
  30. - idrac_system_profile | length < 1
  31. - name: Assert idrac_system_profile value
  32. assert:
  33. that:
  34. - idrac_system_profile == "Performance" or idrac_system_profile == "PerformancePerWatt(DAPC)" or idrac_system_profile == "PerformancePerWatt(OS)" or idrac_system_profile == "WorkstationPerformance"
  35. success_msg: "{{ idrac_system_profile_success_msg }}"
  36. fail_msg: "{{ idrac_system_profile_fail_msg }}"
  37. - name: Assert firmware_update_required value
  38. assert:
  39. that:
  40. - firmware_update_required == true or firmware_update_required == false
  41. success_msg: "{{ firmware_update_success_msg }}"
  42. fail_msg: "{{ firmware_update_fail_msg }}"
  43. - name: Assert snmp_community_name value
  44. assert:
  45. that:
  46. - snmp_community_name | length > 1
  47. success_msg: "{{ snmp_community_success_msg }}"
  48. fail_msg: "{{ snmp_community_fail_msg }}"
  49. - name: Set snmp trap destination status
  50. set_fact:
  51. snmp_trap_status: true
  52. when: snmp_trap_destination | length > 1
  53. run_once: true
  54. - name: Assert snmp_trap_destination value
  55. assert:
  56. that:
  57. - snmp_trap_destination | length > 6
  58. success_msg: "{{ snmp_trap_dest_success_msg }}"
  59. fail_msg: "{{ snmp_trap_dest_fail_msg }}"
  60. when: snmp_trap_status
  61. - name: Check hostname
  62. command: hostname
  63. changed_when: false
  64. register: hostname
  65. run_once: true
  66. - name: Fetch idrac credentials
  67. include_tasks: fetch_idrac_credentials.yml
  68. when: awx_search_key not in hostname.stdout
  69. - name: Set idrac credentials
  70. set_fact:
  71. idrac_username: "{{ lookup('env','ANSIBLE_NET_USERNAME') }}"
  72. idrac_password: "{{ lookup('env','ANSIBLE_NET_PASSWORD') }}"
  73. no_log: true
  74. when: awx_search_key in hostname.stdout
  75. run_once: true