Skip to content

Commit

Permalink
fix: order Ubuntu releases by name
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwillsher committed Jun 13, 2024
1 parent 34892fa commit 003a20a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ galaxy_info:
- bookworm
- name: Ubuntu
versions:
- precise
- trusty
- xenial
- bionic
- focal
- jammy
- noble
- precise
- trusty
- xenial
- name: FreeBSD
versions:
- "10.1"
Expand Down
6 changes: 3 additions & 3 deletions templates/sshd.socket.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Accept=yes
{% else %}
Accept=no
{% endif %}
{% if ansible_facts["distribution"]=="Ubuntu" and ansible_facts["distribution_version"] is version('24.04', '>=') %}
FreeBind=yes
{% if __sshd_socket_freebind %}
FreeBind={{ __sshd_socket_freebind }}
{% endif %}

[Install]
WantedBy=sockets.target
{% if ansible_facts["distribution"]=="Ubuntu" and ansible_facts["distribution_version"] is version('24.04', '>=') %}
{% if __ssh_socket_required_by %}
RequiredBy=ssh.service
{% endif %}
4 changes: 1 addition & 3 deletions tests/tests_systemd_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
# * I do not think the ConditionPathExists is much useful so skipping on Ubuntu
# * Before= does not make any sense in combination with Conflicts=
# * I do not think the Description needs to match verbatim either
# * Accept varies in the default file between Ubuntu versions and is explicit anyway
- name: Construct the options list from old socket file
ansible.builtin.set_fact:
__sshd_socket_list: "{{ __sshd_socket_list + [item] }}"
Expand All @@ -103,7 +102,6 @@
- not item.startswith("ConditionPathExists=")
- not item.startswith("Before=")
- not item.startswith("Description=")
- not item.startswith("Accept=")
loop:
"{{ socket_old.splitlines() }}"

Expand All @@ -120,7 +118,7 @@
- ansible_facts['service_mgr'] == 'systemd' or
(ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7')
- ansible_facts['distribution'] != "Debian" or ansible_facts['distribution_major_version'] | int < 12
- not (ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_version'] is version('24.04', '>=')) # 24.04 has no sshd@.socket in the package
- not (ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_version'] is version('24.04', '>=')) # 24.04 has no sshd@.service in the package
block:
- name: Read the distribution instantiated service file
ansible.builtin.slurp:
Expand Down
3 changes: 3 additions & 0 deletions vars/Ubuntu_24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ __sshd_environment_file: /etc/default/ssh
__sshd_environment_variable: $SSHD_OPTS
__sshd_service_after: auditd.service
__sshd_service_alias: sshd

__sshd_socket_freebind: "yes"
__sshd_socket_required_by: ssh.service
6 changes: 6 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ __sshd_service_restart_timeout: ~

# The systemd socket file does not accept the connection
__sshd_socket_accept: true

# Boolean to control if the systemd socket can be bound to non-local IP addresses
__sshd_socket_freebind: ~

# Space separated list of service names that this socket is required by
__sshd_socket_required_by: ~

0 comments on commit 003a20a

Please sign in to comment.