diff --git a/defaults/main.yml b/defaults/main.yml index f16df53..0be89ea 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1 +1,2 @@ -ssh_host_key_type: ed25519 \ No newline at end of file +ssh_host_key_type: ed25519 +ssh_ip: "{{ansible_host}}" diff --git a/tasks/main.yml b/tasks/main.yml index 18d600c..fb97291 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -23,7 +23,7 @@ args: path: "{{ playbook_dir }}/ssh_known_hosts" name: '{{ inventory_hostname }}' - key: "{{ inventory_hostname }},{{ ansible_host }} {{ _ssh_key_type[ssh_host_key_type] }} {{ _ssh_host_key[ssh_host_key_type] }}" + key: "{{ inventory_hostname }},{{ ssh_ip }} {{ _ssh_key_type[ssh_host_key_type] }} {{ _ssh_host_key[ssh_host_key_type] }}" when: not ssh_host_key_state is defined or ssh_host_key_state == 'configured' or