import_scp.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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: Remove the SCP file if exists
  16. file:
  17. path: "{{ role_path }}/files/{{ scp_filename }}"
  18. state: absent
  19. run_once: true
  20. - name: Create SCP file
  21. copy:
  22. src: "{{ role_path }}/files/temp_scp.xml"
  23. dest: "{{ role_path }}/files/{{ scp_filename }}"
  24. mode: preserve
  25. run_once: true
  26. - name: Add system profile value to SCP file
  27. lineinfile:
  28. path: "{{ role_path }}/files/{{ scp_filename }}"
  29. line: "{{ item.line }}"
  30. insertafter: '^(.*)BootSeqRetry'
  31. when: idrac_system_profile == item.name
  32. with_items:
  33. - { name: "Performance", line: " <Attribute Name=\"SysProfile\">PerfOptimized</Attribute>" }
  34. - { name: "PerformancePerWatt(OS)", line: " <Attribute Name=\"SysProfile\">PerfPerWattOptimizedOs</Attribute>" }
  35. - { name: "PerformancePerWatt(DAPC)", line: " <Attribute Name=\"SysProfile\">PerfPerWattOptimizedDapc</Attribute>" }
  36. - { name: "WorkstationPerformance", line: " <Attribute Name=\"SysProfile\">PerfWorkStationOptimized</Attribute>" }
  37. run_once: true
  38. - name: Add PXE attributes to SCP file
  39. lineinfile:
  40. path: "{{ role_path }}/files/{{ scp_filename }}"
  41. line: "{{ item }}"
  42. insertafter: '^(.*)SysProfile'
  43. with_items:
  44. - ' <Attribute Name="PxeDev1EnDis">Enabled</Attribute>'
  45. - ' <Attribute Name="PxeDev2EnDis">Enabled</Attribute>'
  46. - ' <Attribute Name="PxeDev3EnDis">Enabled</Attribute>'
  47. - ' <Attribute Name="PxeDev4EnDis">Enabled</Attribute>'
  48. - ' <Attribute Name="HttpDev1EnDis">Disabled</Attribute>'
  49. - ' <Attribute Name="HttpDev2EnDis">Disabled</Attribute>'
  50. - ' <Attribute Name="HttpDev3EnDis">Disabled</Attribute>'
  51. - ' <Attribute Name="HttpDev4EnDis">Disabled</Attribute>'
  52. when: provision_method == "pxe"
  53. run_once: true
  54. - name: Disable PXE attributes to SCP file
  55. lineinfile:
  56. path: "{{ role_path }}/files/{{ scp_filename }}"
  57. line: "{{ item }}"
  58. insertafter: '^(.*)SysProfile'
  59. with_items:
  60. - ' <Attribute Name="PxeDev1EnDis">Disabled</Attribute>'
  61. - ' <Attribute Name="PxeDev2EnDis">Disabled</Attribute>'
  62. - ' <Attribute Name="PxeDev3EnDis">Disabled</Attribute>'
  63. - ' <Attribute Name="PxeDev4EnDis">Disabled</Attribute>'
  64. when: provision_method == "idrac"
  65. run_once: true
  66. - name: Add SNMP community name attribute to SCP file
  67. lineinfile:
  68. path: "{{ role_path }}/files/{{ scp_filename }}"
  69. line: ' <Attribute Name="SNMP.1#AgentCommunity">{{ snmp_community_name }}</Attribute>'
  70. insertafter: '^(.*)SNMP.1#AgentEnable'
  71. run_once: true
  72. - name: Add SNMP trap destination attributes to SCP file
  73. lineinfile:
  74. path: "{{ role_path }}/files/{{ scp_filename }}"
  75. line: "{{ item }}"
  76. insertafter: '^(.*)SNMP.1#AlertPort'
  77. with_items:
  78. - ' <Attribute Name="SNMPAlert.1#Destination">{{ snmp_trap_destination }}</Attribute>'
  79. - ' <Attribute Name="SNMPAlert.1#State">Enabled</Attribute>'
  80. when: snmp_trap_status
  81. run_once: true
  82. - name: Import SCP from a local path and wait for this job to get completed
  83. dellemc.openmanage.idrac_server_config_profile:
  84. idrac_ip: "{{ inventory_hostname }}"
  85. idrac_user: "{{ idrac_username }}"
  86. idrac_password: "{{ idrac_password }}"
  87. share_name: "{{ role_path }}/files/"
  88. command: "import"
  89. scp_file: "{{ scp_filename }}"
  90. scp_components: "ALL"
  91. shutdown_type: "Forced"
  92. job_wait: "True"
  93. register: import_scp_status
  94. until: not import_scp_status.failed
  95. retries: "{{ retries_count }}"
  96. - name: Remove the SCP file
  97. file:
  98. path: "{{ role_path }}/files/{{ scp_filename }}"
  99. state: absent
  100. run_once: true