summaryrefslogtreecommitdiffstats
path: root/roles/ssh/tasks/main.yml
diff options
context:
space:
mode:
authorAhmed AbdelHalim <[email protected]>2025-08-11 00:32:04 +0200
committerAhmed AbdelHalim <[email protected]>2025-08-11 00:32:04 +0200
commite29ccfa18e51059897da5657f3b577ea28617f53 (patch)
treee3f1656e50060064da5b3b062fef33263fd90072 /roles/ssh/tasks/main.yml
parent4c469b480da9767d6e7cacda9cfb332dec85a07c (diff)
Simplify playbook by requiring the required_for_boot tag on roles
Instead of optimizing for task execution for boot, it's simpler and almost as equally safe (if not even more) to require the role for boot instead of requiring each of it's needed tasks. This will also prevent having internal bugs because a set fact wasn't required for boot and didn't add the info (similar to the fix in commit: 9f72c58)
Diffstat (limited to 'roles/ssh/tasks/main.yml')
-rw-r--r--roles/ssh/tasks/main.yml10
1 files changed, 0 insertions, 10 deletions
diff --git a/roles/ssh/tasks/main.yml b/roles/ssh/tasks/main.yml
index f88b9be4..c09d00e1 100644
--- a/roles/ssh/tasks/main.yml
+++ b/roles/ssh/tasks/main.yml
@@ -1,11 +1,9 @@
---
- name: "Include OS-specific variables"
ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml"
- tags: [required_for_boot]
- name: "Install OS-specific packages"
ansible.builtin.include_tasks: "install-{{ ansible_os_family | lower }}.yml"
- tags: [required_for_boot]
- name: "Ensure ssh_service is enabled"
become: true
@@ -14,7 +12,6 @@
state: "started"
enabled: true
when: not ansible_is_chroot
- tags: [required_for_boot]
- name: "(chroot): Ensure ssh_service enabled"
# noqa: command-instead-of-module intentional isnide chroot
@@ -22,28 +19,24 @@
cmd: "systemctl enable {{ ssh_service_name }}"
when: ansible_is_chroot
changed_when: true
- tags: [required_for_boot]
- name: "Generate /etc/ssh/ RSA host key"
become: true
ansible.builtin.command:
cmd: "ssh-keygen -q -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -C '' -N ''"
creates: "/etc/ssh/ssh_host_rsa_key"
- tags: [required_for_boot]
- name: "Generate /etc/ssh/ ECDSA host key"
become: true
ansible.builtin.command:
cmd: "ssh-keygen -q -t ecdsa -b 521 -f /etc/ssh/ssh_host_ecdsa_key -C '' -N ''"
creates: "/etc/ssh/ssh_host_ecdsa_key"
- tags: [required_for_boot]
- name: "Generate /etc/ssh/ Ed25519 host key"
become: true
ansible.builtin.command:
cmd: "ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -C '' -N ''"
creates: "/etc/ssh/ssh_host_ed25519_key"
- tags: [required_for_boot]
- name: "Configure sshd_config"
become: true
@@ -68,7 +61,6 @@
notify:
- "Reload systemd"
- "Restart ssh"
- tags: [required_for_boot]
- name: "Configure ssh authentication policy"
become: true
@@ -87,7 +79,6 @@
X11Forwarding no
notify:
- "Restart ssh"
- tags: [required_for_boot]
- name: "Add arg.username to allowed users"
become: true
@@ -99,4 +90,3 @@
AllowUsers {{ username }}
notify:
- "Restart ssh"
- tags: [required_for_boot]