configure_smtp.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: Configure DNS
  16. community.general.idrac_redfish_config:
  17. category: Manager
  18. command: SetManagerAttributes
  19. resource_id: iDRAC.Embedded.1
  20. manager_attributes:
  21. NIC.1.DNSRegister: "Enabled"
  22. NIC.1.DNSDomainName: "{{ dns_domain_name }}"
  23. IPv4Static.1.DNS1: "{{ ipv4_static_dns1 }}"
  24. IPv4Static.1.DNS2: "{{ ipv4_static_dns2 }}"
  25. baseuri: "{{ inventory_hostname }}"
  26. username: "{{ idrac_username }}"
  27. password: "{{ idrac_password }}"
  28. - name: Configure SMTP
  29. community.general.idrac_redfish_config:
  30. category: Manager
  31. command: SetManagerAttributes
  32. resource_id: iDRAC.Embedded.1
  33. manager_attributes:
  34. RemoteHosts.1.SMTPServerIPAddress: "{{ smtp_server_ip }}"
  35. RemoteHosts.1.SMTPPort: 25
  36. RemoteHosts.1.SMTPAuthentication: "{{ smtp_authentication }}"
  37. RemoteHosts.1.SMTPUserName: "{{ smtp_username }}"
  38. RemoteHosts.1.SMTPPassword: "{{ smtp_password }}"
  39. EmailAlert.1.Address: "{{ use_email_address_2fa }}"
  40. EmailAlert.1.Enable: "Enabled"
  41. baseuri: "{{ inventory_hostname }}"
  42. username: "{{ idrac_username }}"
  43. password: "{{ idrac_password }}"
  44. - name: Wait for one minute
  45. pause:
  46. minutes: 1
  47. run_once: true
  48. - name: Sent SMTP test email
  49. command: sshpass -p {{ idrac_password }} ssh -o "StrictHostKeyChecking no" {{ idrac_username }}@{{ inventory_hostname }} 'racadm testemail -i 1'
  50. changed_when: false
  51. register: test_email_check
  52. retries: 5
  53. no_log: true
  54. failed_when: false
  55. until: not test_email_check.failed
  56. - name: Check test email status
  57. assert:
  58. that: test_email_success_msg in test_email_check.stdout
  59. fail_msg: "{{ test_email_check_fail_msg }}"
  60. success_msg: "{{ test_email_check_success_msg }}"
  61. - name: Disable email alert
  62. community.general.idrac_redfish_config:
  63. category: Manager
  64. command: SetManagerAttributes
  65. resource_id: iDRAC.Embedded.1
  66. manager_attributes:
  67. EmailAlert.1.Address: ""
  68. EmailAlert.1.Enable: "Disabled"
  69. baseuri: "{{ inventory_hostname }}"
  70. username: "{{ idrac_username }}"
  71. password: "{{ idrac_password }}"