provision_password.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright 2020 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 old user
  16. file:
  17. path: "{{ role_path }}/files/.users.digest"
  18. state: absent
  19. tags: install
  20. - name: Create a new user
  21. file:
  22. path: "{{ role_path }}/files/.users.digest"
  23. state: touch
  24. mode: 0644
  25. tags: install
  26. - name: Encrypt cobbler password
  27. shell: printf "%s:%s:%s" {{ username }} "Cobbler" "{{ cobbler_password }}" | md5sum | awk '{print $1}'
  28. changed_when: false
  29. register: encrypt_password
  30. no_log: true
  31. tags: install
  32. - name: Copy cobbler password to cobbler config file
  33. shell: printf "%s:%s:%s\n" "{{ username }}" "Cobbler" "{{ encrypt_password.stdout }}" > "{{ role_path }}/files/.users.digest"
  34. changed_when: false
  35. no_log: true
  36. tags: install
  37. - name: Create the kickstart file
  38. copy:
  39. src: "{{ role_path }}/files/temp_centos7.ks"
  40. dest: "{{ role_path }}/files/centos7.ks"
  41. mode: 0775
  42. tags: install
  43. - name: Configure kickstart file- IP
  44. replace:
  45. path: "{{ role_path }}/files/centos7.ks"
  46. regexp: '^url --url http://ip/cblr/links/CentOS7-x86_64/'
  47. replace: url --url http://{{ hpc_ip }}/cblr/links/CentOS7-x86_64/
  48. tags: install
  49. - name: Random phrase generation
  50. command: openssl rand -base64 12
  51. changed_when: false
  52. register: prompt_random_phrase
  53. tags: install
  54. no_log: true
  55. - name: Set random phrase
  56. set_fact:
  57. random_phrase: "{{ prompt_random_phrase.stdout }}"
  58. tags: install
  59. no_log: true
  60. - name: Login password
  61. command: openssl passwd -1 -salt {{ random_phrase }} {{ cobbler_password }}
  62. no_log: true
  63. changed_when: false
  64. register: login_pass
  65. tags: install
  66. - name: Configure kickstart file- Password
  67. replace:
  68. path: "{{ role_path }}/files/centos7.ks"
  69. regexp: '^rootpw --iscrypted password'
  70. replace: 'rootpw --iscrypted {{ login_pass.stdout }}'
  71. no_log: true
  72. tags: install
  73. - name: Configure kickstart file- nic
  74. replace:
  75. path: "{{ role_path }}/files/centos7.ks"
  76. regexp: '^network --bootproto=dhcp --device=nic --onboot=on'
  77. replace: 'network --bootproto=dhcp --device={{ nic }} --onboot=on'
  78. tags: install
  79. - name: Configure kickstart file- timezone
  80. replace:
  81. path: "{{ role_path }}/files/centos7.ks"
  82. regexp: '^timezone --utc ks_timezone'
  83. replace: 'timezone --utc {{ ks_timezone }}'
  84. tags: install