diff ssh.py @ 289:65e28d2e0cd8

move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
author drewp@bigasterisk.com
date Sun, 21 Apr 2024 17:07:23 -0700
parents 4e424a144183
children 5b88b38f2471
line wrap: on
line diff
--- a/ssh.py	Sun Apr 21 17:01:13 2024 -0700
+++ b/ssh.py	Sun Apr 21 17:07:23 2024 -0700
@@ -2,7 +2,6 @@
 from pyinfra.facts.server import LinuxDistribution
 from pyinfra.operations import files, systemd
 
-is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux']
 
 systemd.service(
     service='ssh',
@@ -12,7 +11,7 @@
 
 files.line(path='/etc/ssh/ssh_config', line="HashKnownHosts", replace="HashKnownHosts no")
 
-if not is_pi:
+if 'pi' not in host.groups:
     files.line(path='/etc/ssh/sshd_config', line="^UseDNS\b", replace="UseDNS no")
     # MAYBE plus needs this fix: adding ListenAddress 0.0.0.0 to /etc/ssh/sshd_config
     systemd.service(service='sshd', reloaded=True)