provision_password.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. - name: Set random phrase
  55. set_fact:
  56. random_phrase: "{{ prompt_random_phrase.stdout }}"
  57. tags: install
  58. - name: Login password
  59. command: openssl passwd -1 -salt {{ random_phrase }} {{ cobbler_password }}
  60. no_log: true
  61. changed_when: false
  62. register: login_pass
  63. tags: install
  64. - name: Configure kickstart file- Password
  65. replace:
  66. path: "{{ role_path }}/files/centos7.ks"
  67. regexp: '^rootpw --iscrypted password'
  68. replace: 'rootpw --iscrypted {{ login_pass.stdout }}'
  69. no_log: true
  70. tags: install
  71. - name: Configure kickstart file- nic
  72. replace:
  73. path: "{{ role_path }}/files/centos7.ks"
  74. regexp: '^network --bootproto=dhcp --device=nic --onboot=on'
  75. replace: 'network --bootproto=dhcp --device={{ nic }} --onboot=on'
  76. tags: install