Переглянути джерело

adjust to new structure

master
Markus Katharina Brechtel 3 роки тому
джерело
коміт
3d1f2cdac5
5 змінених файлів з 12 додано та 14 видалено
  1. +0
    -1
      defaults/main.yml
  2. +3
    -4
      tasks/local.yml
  3. +6
    -5
      tasks/save.yml
  4. +0
    -1
      templates/host_vars.j2
  5. +3
    -3
      templates/ssh_host_key.j2

+ 0
- 1
defaults/main.yml Переглянути файл

@@ -2,7 +2,6 @@ ssh_host_key_types:
- ed25519
- ecdsa
- rsa
ssh_ip: "{{ansible_host}}"
ssh_host_key_state: configured
ssh_scan_host: "{% if ssh_ip is defined %}{{ ssh_ip }}{% else %}{{inventory_hostname}}{% endif %}"



+ 3
- 4
tasks/local.yml Переглянути файл

@@ -4,8 +4,7 @@
local_action: known_hosts
args:
path: "{{ lookup('env','HOME') }}/.ssh/known_hosts"
name: "{{ item }}"
name: "{{ inventory_hostname }}"
key: "{{ lookup('template','ssh_host_key.j2') }}"
with_items: "{{play_hosts}}"
when: hostvars[item].ssh_host_key_ed25519_public is defined
run_once: true
when: ssh_host_key_ed25519_public is defined
throttle: 1

+ 6
- 5
tasks/save.yml Переглянути файл

@@ -1,13 +1,14 @@
---

- name: host_vars directory
- name: make sure host_vars directory is present for host
local_action: file
args:
path: "{{inventory_dir}}/host_vars/{{inventory_hostname}}"
state: directory

- name: host_vars file
local_action: template
- name: record ssh host key in host_vars
local_action: copy
args:
src: host_vars.j2
dest: "{{inventory_dir}}/host_vars/{{inventory_hostname}}/ssh_host_key.yaml"
content:
ssh_host_key_ed25519_public: "{{ ssh_host_key_ed25519_public }}"
dest: "{{inventory_dir}}/host_vars/{{inventory_hostname}}/ssh_host_key.auto.json"

+ 0
- 1
templates/host_vars.j2 Переглянути файл

@@ -1 +0,0 @@
ssh_host_key_ed25519_public: {{ ssh_host_key_ed25519_public }}

+ 3
- 3
templates/ssh_host_key.j2 Переглянути файл

@@ -1,5 +1,5 @@
{% if hostvars[item].ssh_ip is defined %}
{{ item }},{{ ansible_host }},{{ hostvars[item].ssh_ip }} ssh-ed25519 {{ hostvars[item].ssh_host_key_ed25519_public }}
{% if ssh_ip is defined %}
{{ inventory_hostname }},{{ ssh_ip }} ssh-ed25519 {{ ssh_host_key_ed25519_public }}
{% else %}
{{ item }},{{ ansible_host }} ssh-ed25519 {{ hostvars[item].ssh_host_key_ed25519_public }}
{{ inventory_hostname }},{{ ansible_host }} ssh-ed25519 {{ ssh_host_key_ed25519_public }}
{% endif %}

Завантаження…
Відмінити
Зберегти