Ver código fonte

known hosts handling via template

master
pai
commit
a3f973111c
2 arquivos alterados com 7 adições e 3 exclusões
  1. +2
    -2
      tasks/file.yml
  2. +5
    -1
      templates/ssh_host_key.j2

+ 2
- 2
tasks/file.yml Ver arquivo

@@ -1,10 +1,10 @@
---
- name: write ssh_known_hosts file
local_action: known_hosts
args:
path: "{{ playbook_dir }}/ssh_known_hosts"
name: "{{ item }}"
key: "{{ item }},{{ hostvars[item].ssh_ip }} ssh-ed25519 {{ hostvars[item].ssh_host_key_ed25519_public }}"
key: "{{ lookup('template','ssh_host_key.j2') }}"
with_items: "{{play_hosts}}"
run_once: true

+ 5
- 1
templates/ssh_host_key.j2 Ver arquivo

@@ -1 +1,5 @@
{{ _ssh_key_type[ssh_host_key_type] }} {% if ssh_host_key_type == "ed25519" %}{{ ssh_host_key_ed25519_public }}{% endif %}
{% if hostvars[item].ssh_ip is defined %}
{{ item }},{{ hostvars[item].ssh_ip }} ssh-ed25519 {{ hostvars[item].ssh_host_key_ed25519_public }}
{% else %}
{{ item }} ssh-ed25519 {{ hostvars[item].ssh_host_key_ed25519_public }}
{% endif %}

Carregando…
Cancelar
Salvar