diff --git a/system/known_hosts.py b/system/known_hosts.py index 7592574d4e7..b68e85e0e77 100644 --- a/system/known_hosts.py +++ b/system/known_hosts.py @@ -92,8 +92,8 @@ def enforce_state(module, params): #Find the ssh-keygen binary sshkeygen = module.get_bin_path("ssh-keygen",True) - #trailing newline in files gets lost, so re-add if necessary - if key is not None and key[-1]!='\n': + # Trailing newline in files gets lost, so re-add if necessary + if key and key[-1] != '\n': key+='\n' if key is None and state != "absent":