edit_iso_config.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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: Create iso directory
  16. file:
  17. path: "{{ tmp_iso_dir }}"
  18. state: directory
  19. mode: "{{ file_permission }}"
  20. tags: install
  21. - name: Copy files to tmpiso folder
  22. copy:
  23. src: "{{ iso_mount_path }}"
  24. dest: "{{ tmp_iso_dir }}"
  25. mode: preserve
  26. tags: install
  27. - name: Edit isolinux.cfg
  28. replace:
  29. path: "{{ tmp_iso_dir }}{{ isolinux_cfg_path }}"
  30. regexp: "{{ item.regexp }}"
  31. replace: "{{ item.replace }}"
  32. with_items:
  33. - { regexp: "append initrd=initrd.img", replace: "append initrd=initrd.img ks=cdrom:/{{ kickstart_file }}" }
  34. - { regexp: "rd.live.check quiet", replace: "" }
  35. tags: install
  36. - name: Edit grub.cfg
  37. replace:
  38. path: "{{ tmp_iso_dir }}{{ grub_cfg_path }}"
  39. regexp: "{{ item.regexp }}"
  40. replace: "{{ item.replace }}"
  41. with_items:
  42. - { regexp: "kernel /images/pxeboot/vmlinuz", replace: "kernel /images/pxeboot/vmlinuz ks=cdrom:/{{ kickstart_file }}" }
  43. - { regexp: "linuxefi /images/pxeboot/vmlinuz", replace: "linuxefi /images/pxeboot/vmlinuz ks=cdrom:/{{ kickstart_file }}" }
  44. - { regexp: "rd.live.check quiet", replace: "" }
  45. tags: install
  46. - name: Remove the kickstart file if exists
  47. file:
  48. path: "{{ role_path }}/files/{{ kickstart_file }}"
  49. state: absent
  50. tags: install
  51. - name: Create the kickstart file
  52. copy:
  53. src: "{{ role_path }}/files/temp_centos7.cfg"
  54. dest: "{{ role_path }}/files/{{ kickstart_file }}"
  55. mode: "{{ file_permission }}"
  56. tags: install
  57. - name: Random phrase generation
  58. command: openssl rand -base64 12
  59. changed_when: false
  60. register: generate_random_phrase
  61. tags: install
  62. no_log: true
  63. - name: Encrypt login password
  64. command: openssl passwd -1 -salt {{ generate_random_phrase.stdout }} {{ provision_password }}
  65. no_log: true
  66. changed_when: false
  67. register: encrypt_login_pass
  68. tags: install
  69. - name: Configure kickstart file - Password
  70. replace:
  71. path: "{{ role_path }}/files/{{ kickstart_file }}"
  72. regexp: '^rootpw --iscrypted ks_password'
  73. replace: 'rootpw --iscrypted {{ encrypt_login_pass.stdout }}'
  74. no_log: true
  75. tags: install
  76. - name: Configure kickstart file - nic
  77. replace:
  78. path: "{{ role_path }}/files/{{ kickstart_file }}"
  79. regexp: '^network --bootproto=dhcp --device=ks_nic --onboot=on'
  80. replace: 'network --bootproto=dhcp --device={{ host_network_nic }} --onboot=on'
  81. tags: install
  82. - name: Configure kickstart file - timezone
  83. replace:
  84. path: "{{ role_path }}/files/{{ kickstart_file }}"
  85. regexp: '^timezone --utc ks_timezone'
  86. replace: 'timezone --utc {{ timezone }}'
  87. tags: install
  88. - name: Configure kickstart file - language
  89. replace:
  90. path: "{{ role_path }}/files/{{ kickstart_file }}"
  91. regexp: '^lang ks_language'
  92. replace: 'lang {{ language }}'
  93. tags: install
  94. - name: Copy kickstart file to iso mount path
  95. copy:
  96. src: "{{ role_path }}/files/{{ kickstart_file }}"
  97. dest: "/tmp/tmpiso/{{ kickstart_file }}"
  98. mode: preserve
  99. tags: install