# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: Remove old user file: path: "{{ role_path }}/files/.users.digest" state: absent tags: install - name: Create a new user file: path: "{{ role_path }}/files/.users.digest" state: touch mode: 0644 tags: install - name: Encrypt cobbler password shell: printf "%s:%s:%s" {{ username }} "Cobbler" "{{ cobbler_password }}" | md5sum | awk '{print $1}' changed_when: false register: encrypt_password no_log: true tags: install - name: Copy cobbler password to cobbler config file shell: printf "%s:%s:%s\n" "{{ username }}" "Cobbler" "{{ encrypt_password.stdout }}" > "{{ role_path }}/files/.users.digest" changed_when: false no_log: true tags: install - name: Create the kickstart file copy: src: "{{ role_path }}/files/temp_centos7.ks" dest: "{{ role_path }}/files/centos7.ks" mode: 0775 tags: install - name: Configure kickstart file- IP replace: path: "{{ role_path }}/files/centos7.ks" regexp: '^url --url http://ip/cblr/links/CentOS7-x86_64/' replace: url --url http://{{ hpc_ip }}/cblr/links/CentOS7-x86_64/ tags: install - name: Random phrase generation command: openssl rand -base64 12 changed_when: false register: prompt_random_phrase tags: install no_log: true - name: Set random phrase set_fact: random_phrase: "{{ prompt_random_phrase.stdout }}" tags: install no_log: true - name: Login password command: openssl passwd -1 -salt {{ random_phrase }} {{ cobbler_password }} no_log: true changed_when: false register: login_pass tags: install - name: Configure kickstart file- Password replace: path: "{{ role_path }}/files/centos7.ks" regexp: '^rootpw --iscrypted password' replace: 'rootpw --iscrypted {{ login_pass.stdout }}' no_log: true tags: install - name: Configure kickstart file- nic replace: path: "{{ role_path }}/files/centos7.ks" regexp: '^network --bootproto=dhcp --device=nic --onboot=on' replace: 'network --bootproto=dhcp --device={{ nic }} --onboot=on' tags: install - name: Configure kickstart file- timezone replace: path: "{{ role_path }}/files/centos7.ks" regexp: '^timezone --utc ks_timezone' replace: 'timezone --utc {{ ks_timezone }}' tags: install