provision_password.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 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: "{{ user_mode }}"
  25. tags: install
  26. - name: Cobbler UI password
  27. set_fact:
  28. encrypt_password: "{{ cobbler_password | hash('sha3_256') }}"
  29. no_log: true
  30. tags: install
  31. - name: Copy cobbler password to cobbler config file
  32. shell: printf "%s:%s:%s\n" "{{ username }}" "Cobbler" "{{ encrypt_password }}" > "{{ role_path }}/files/.users.digest"
  33. changed_when: false
  34. no_log: true
  35. tags: install
  36. - name: Create the kickstart file
  37. copy:
  38. src: "{{ role_path }}/files/temp_centos7.ks"
  39. dest: "{{ role_path }}/files/centos7.ks"
  40. mode: 0775
  41. tags: install
  42. - name: Configure kickstart file- IP
  43. replace:
  44. path: "{{ role_path }}/files/centos7.ks"
  45. regexp: '^url --url http://ip/cblr/links/CentOS7-x86_64/'
  46. replace: url --url http://{{ hpc_ip }}/cblr/links/CentOS7-x86_64/
  47. tags: install
  48. - name: Random phrase generation
  49. command: openssl rand -base64 12
  50. changed_when: false
  51. register: prompt_random_phrase
  52. tags: install
  53. no_log: true
  54. - name: Set random phrase
  55. set_fact:
  56. random_phrase: "{{ prompt_random_phrase.stdout }}"
  57. tags: install
  58. no_log: true
  59. - name: Login password
  60. command: openssl passwd -1 -salt {{ random_phrase }} {{ provision_password }}
  61. no_log: true
  62. changed_when: false
  63. register: login_pass
  64. tags: install
  65. - name: Assign password
  66. replace:
  67. path: "{{ role_path }}/files/settings.yaml"
  68. regexp: '^default_password_crypted: password'
  69. replace: 'default_password_crypted: {{ login_pass.stdout }}'
  70. no_log: true
  71. tags: install
  72. - name: Configure kickstart file- Password
  73. replace:
  74. path: "{{ role_path }}/files/centos7.ks"
  75. regexp: '^rootpw --iscrypted password'
  76. replace: 'rootpw --iscrypted {{ login_pass.stdout }}'
  77. no_log: true
  78. tags: install
  79. - name: Configure kickstart file- nic
  80. lineinfile:
  81. path: "{{ role_path }}/files/centos7.ks"
  82. insertafter: '^network --bootproto=dhcp --device=link --onboot=on --activate'
  83. line: 'network --bootproto=dhcp --device={{ item }} --onboot=on --activate'
  84. tags: install
  85. with_items: "{{ host_nic }}"
  86. - name: Configure kickstart file- timezone
  87. replace:
  88. path: "{{ role_path }}/files/centos7.ks"
  89. regexp: '^timezone --utc ks_timezone'
  90. replace: 'timezone --utc {{ timezone }}'
  91. tags: install