|
@@ -1,4 +1,4 @@
|
|
|
-# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
|
|
|
+# Copyright 2022 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.
|
|
@@ -25,7 +25,7 @@
|
|
|
when: "'manager' in group_names"
|
|
|
|
|
|
- name: Verify whether passwordless ssh is set on the remote host
|
|
|
- shell: sshpass ssh -o "PasswordAuthentication=no" root@{{ current_host }} 'hostname'
|
|
|
+ command: sshpass ssh -o "PasswordAuthentication=no" root@{{ current_host }} 'hostname'
|
|
|
register: ssh_output
|
|
|
async: 30
|
|
|
poll: 5
|
|
@@ -45,12 +45,28 @@
|
|
|
register: verify_rsa_id_file
|
|
|
when: not ssh_status
|
|
|
|
|
|
-- name: Generate ssh key pair
|
|
|
- command: ssh-keygen -t rsa -b 4096 -f "{{ rsa_id_file }}" -q -N "{{ passphrase }}"
|
|
|
+- name: Create rsa_id file if it doesn't exist
|
|
|
+ ansible.builtin.file:
|
|
|
+ path: "{{ rsa_id_file }}"
|
|
|
+ state: touch
|
|
|
+ mode: "{{ file_mode }}"
|
|
|
when:
|
|
|
- not ssh_status
|
|
|
- not verify_rsa_id_file.stat.exists
|
|
|
|
|
|
+- name: Generate ssh key pair
|
|
|
+ shell: ssh-keygen -t rsa -b 4096 -f "{{ rsa_id_file }}" -q -N "{{ passphrase }}" <<<y >/dev/null 2>&1
|
|
|
+ when:
|
|
|
+ - not ssh_status
|
|
|
+
|
|
|
+- name: Creating ssh config file with IdentifyFile value
|
|
|
+ copy:
|
|
|
+ dest: "{{ config_file }}"
|
|
|
+ content: |
|
|
|
+ Host *
|
|
|
+ IdentityFile "{{ rsa_id_file }}"
|
|
|
+ mode: "{{ file_mode }}"
|
|
|
+
|
|
|
- name: Add the key identity
|
|
|
shell: |
|
|
|
eval `ssh-agent -s`
|
|
@@ -85,4 +101,4 @@
|
|
|
rescue:
|
|
|
- name: Passwordless ssh failed
|
|
|
fail:
|
|
|
- msg: "{{ register_error.stderr | regex_replace(hostvars['127.0.0.1']['cobbler_password']) | regex_replace(auth_key_path) }}"
|
|
|
+ msg: "{{ register_error.stderr | regex_replace(hostvars['127.0.0.1']['cobbler_password']) | regex_replace(auth_key_path) }}"
|