Skip to content

Commit 30ee708

Browse files
committed
Generate SSH Keys for tests via Systemd
Signed-off-by: Martin Schurz <[email protected]>
1 parent 77a2681 commit 30ee708

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

molecule/ssh_hardening/prepare.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@
7575
update_cache: true
7676
when: ansible_facts.os_family == 'Archlinux'
7777

78-
- name: Create ssh host keys # noqa ignore-errors
79-
ansible.builtin.command: ssh-keygen -A
80-
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat'])
81-
and (ansible_facts.distribution_major_version < '7'
82-
or ansible_facts.distribution_major_version > '9' ))
83-
or ansible_facts.distribution == "Fedora"
84-
or ansible_facts.distribution == "Amazon"
85-
or ansible_facts.os_family == "Suse"
86-
changed_when: false
78+
- name: Create ssh host keys via Systemd service start # noqa ignore-errors
79+
ansible.builtin.service:
80+
name: "sshd"
81+
state: started
82+
when: ansible_facts.service_mgr == 'systemd'
8783
ignore_errors: true

molecule/ssh_hardening_custom_tests/prepare.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@
7575
update_cache: true
7676
when: ansible_facts.os_family == 'Alpine'
7777

78-
- name: Create ssh host keys # noqa ignore-errors
79-
ansible.builtin.command: ssh-keygen -A
80-
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat'])
81-
and (ansible_facts.distribution_major_version < '7'
82-
or ansible_facts.distribution_major_version > '9' ))
83-
or ansible_facts.distribution == "Fedora"
84-
or ansible_facts.distribution == "Amazon"
85-
or ansible_facts.os_family == "Suse"
86-
changed_when: false
78+
- name: Create ssh host keys via Systemd service start # noqa ignore-errors
79+
ansible.builtin.service:
80+
name: "sshd"
81+
state: started
82+
when: ansible_facts.service_mgr == 'systemd'
8783
ignore_errors: true

0 commit comments

Comments
 (0)