validate_idrac_vars.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. provision_status: false
  25. run_once: true
  26. - name: Validate input parameters are not empty
  27. fail:
  28. msg: "{{ idrac_input_fail_msg }}"
  29. register: idrac_config_check
  30. when:
  31. - idrac_system_profile | length < 1
  32. - name: Assert idrac_system_profile value
  33. assert:
  34. that:
  35. - idrac_system_profile == "Performance" or idrac_system_profile == "PerformancePerWatt(DAPC)" or idrac_system_profile == "PerformancePerWatt(OS)" or idrac_system_profile == "WorkstationPerformance"
  36. success_msg: "{{ idrac_system_profile_success_msg }}"
  37. fail_msg: "{{ idrac_system_profile_fail_msg }}"
  38. - name: Assert firmware_update_required value
  39. assert:
  40. that:
  41. - firmware_update_required == true or firmware_update_required == false
  42. success_msg: "{{ firmware_update_success_msg }}"
  43. fail_msg: "{{ firmware_update_fail_msg }}"
  44. - name: Assert snmp_community_name value
  45. assert:
  46. that:
  47. - snmp_community_name | length > 1
  48. success_msg: "{{ snmp_community_success_msg }}"
  49. fail_msg: "{{ snmp_community_fail_msg }}"
  50. - name: Set snmp trap destination status
  51. set_fact:
  52. snmp_trap_status: true
  53. when: snmp_trap_destination | length > 1
  54. run_once: true
  55. - name: Assert snmp_trap_destination value
  56. assert:
  57. that:
  58. - snmp_trap_destination | length > 6
  59. success_msg: "{{ snmp_trap_dest_success_msg }}"
  60. fail_msg: "{{ snmp_trap_dest_fail_msg }}"
  61. when: snmp_trap_status
  62. - name: Check hostname
  63. command: hostname
  64. changed_when: false
  65. register: hostname
  66. run_once: true
  67. - name: Fetch idrac credentials
  68. include_tasks: fetch_idrac_credentials.yml
  69. when: awx_search_key not in hostname.stdout
  70. - name: Set idrac credentials
  71. set_fact:
  72. idrac_username: "{{ lookup('env','ANSIBLE_NET_USERNAME') }}"
  73. idrac_password: "{{ lookup('env','ANSIBLE_NET_PASSWORD') }}"
  74. no_log: true
  75. when: awx_search_key in hostname.stdout
  76. run_once: true