edit_iso_config.yml 3.4 KB

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