Skip to content

Commit 85ad72a

Browse files
committed
Fix known_hosts module issue on centos/rocky 10
The known_hosts module returns a failure on centos/rocky 10 when given a comment line from ssh-keyscan output. Fix by excluding them with grep. Change-Id: I29e7e8a7480009fd359b8aa8b867b11900109f00 Signed-off-by: Pierre Riteau <[email protected]> (cherry picked from commit e303339)
1 parent 7ff2db4 commit 85ad72a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ansible/roles/bootstrap/tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@
6161
user: "{{ ansible_facts.user_id }}"
6262
key: "{{ lookup('file', bootstrap_ssh_private_key_path ~ '.pub') }}"
6363

64+
# NOTE(priteau): Exclude comments from ssh-keyscan output because they break
65+
# known_hosts on centos/rocky 10.
6466
- name: Scan for SSH keys
65-
command: ssh-keyscan {{ item }}
67+
shell: ssh-keyscan {{ item }} | grep -v '^#'
6668
with_items:
6769
- localhost
6870
- 127.0.0.1

ansible/roles/ssh-known-host/tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
vm provision' and 'kayobe overcloud inventory discover'.
1414
when: not ansible_host | default(inventory_hostname)
1515

16+
# NOTE(priteau): Exclude comments from ssh-keyscan output because they break
17+
# known_hosts on centos/rocky 10.
1618
- name: Scan for SSH keys
1719
local_action:
18-
module: command ssh-keyscan {{ item }}
20+
module: shell ssh-keyscan {{ item }} | grep -v '^#'
1921
with_items:
2022
- "{{ ansible_host|default(inventory_hostname) }}"
2123
register: keyscan_result

0 commit comments

Comments
 (0)