validate_idrac_vars.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 the system public IP
  67. set_fact:
  68. public_ip: "{{ lookup('vars','ansible_'+public_nic).ipv4.address }}"
  69. run_once: true
  70. when: '"awx-" not in hostname.stdout'
  71. - name: Assert public IP
  72. assert:
  73. that:
  74. - public_ip | length > 7
  75. - public_ip | ipv4
  76. success_msg: "{{ public_ip_success_msg }}"
  77. fail_msg: "{{ public_ip_fail_msg }}"
  78. when: '"awx-" not in hostname.stdout'
  79. - name: Fetch idrac credentials
  80. include_tasks: fetch_idrac_credentials.yml
  81. when: '"awx-" not in hostname.stdout'
  82. - name: Set idrac credentials
  83. set_fact:
  84. idrac_username: "{{ lookup('env','ANSIBLE_NET_USERNAME') }}"
  85. idrac_password: "{{ lookup('env','ANSIBLE_NET_PASSWORD') }}"
  86. no_log: true
  87. when: '"awx-" in hostname.stdout'
  88. run_once: true