-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
known-hosts: revisit the role (#610)
* remove README.rst * avoid duplicate entries in the destination file * avoid comments in the destination file * make use of static entries possible It's now possible to add a known_hosts parameter to the host_vars to set static known hosts entries for a specific host. When this parameter is set ssh-keygen will not be used to generate the known hosts entries on the fly. ``` known_hosts: - ssh-rsa AAAAB3NzaC1y... - ecdsa-sha2-nistp256 AAAAE2VjZHN... - ssh-ed25519 AAAAC3NzaC1... ``` * make use of extra entries possible It's now possible to add a known_hosts_extra parameter as extra var e.g. in environments/configuration.yml to add additional entries. ``` known_hosts_extra: - testbed-node-1.testbed.osism.xyz ssh-rsa AAAAB3Nza... ``` Signed-off-by: Christian Berendt <[email protected]>
- Loading branch information
Showing
5 changed files
with
80 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Write scanned known_hosts entries | ||
ansible.builtin.known_hosts: | ||
path: "{{ known_hosts_destination }}/known_hosts" | ||
name: "{{ inner_item.split(' ') | first }}" | ||
key: "{{ inner_item }}" | ||
loop: "{{ item['stdout_lines'] }}" | ||
loop_control: | ||
loop_var: inner_item | ||
when: | ||
- item['stdout_lines'] is defined | ||
- item['stdout_lines'] | length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
- name: Write static known_hosts entries with hostname | ||
ansible.builtin.known_hosts: | ||
path: "{{ known_hosts_destination }}/known_hosts" | ||
name: "{{ item }}" | ||
key: "{{ item }} {{ inner_item }}" | ||
loop_control: | ||
loop_var: inner_item | ||
loop: "{{ hostvars[item]['known_hosts'] }}" | ||
|
||
- name: Write static known_hosts entries with ansible_host | ||
ansible.builtin.known_hosts: | ||
path: "{{ known_hosts_destination }}/known_hosts" | ||
name: "{{ hostvars[item]['ansible_host'] }}" | ||
key: "{{ hostvars[item]['ansible_host'] }} {{ inner_item }}" | ||
loop_control: | ||
loop_var: inner_item | ||
loop: "{{ hostvars[item]['known_hosts'] }}" |