Skip to content

Commit

Permalink
old python, no f''
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoca committed Oct 24, 2024
1 parent c1f3a2a commit 8716aed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/ansible/modules/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ def ssh_key_gen(self):
overwrite = None
try:
ssh_key_file = self.get_ssh_key_path()
pub_file = f'{ssh_key_file}.pub'
pub_file = '%s.pub' % ssh_key_file
except Exception as e:
return (1, '', to_native(e))
ssh_dir = os.path.dirname(ssh_key_file)
Expand All @@ -1164,18 +1164,18 @@ def ssh_key_gen(self):

if os.path.exists(ssh_key_file):
if self.force:
self.module.warn(f'Overwriting existing ssh key private file "{ssh_key_file}"')
self.module.warn('Overwriting existing ssh key private file "%s"' % ssh_key_file)
overwrite = 'y'
else:
self.module.warn(f'Found existing ssh key private file "{ssh_key_file}", no force, so skipping ssh-keygen generation')
self.module.warn('Found existing ssh key private file "%s", no force, so skipping ssh-keygen generation' % ssh_key_file)
return (None, 'Key already exists, use "force: yes" to overwrite', '')

if os.path.exists(pub_file):
if self.force:
self.module.warn(f'Overwriting existing ssh key public file "{pub_file}"')
self.module.warn('Overwriting existing ssh key public file "%s"' % pub_file)
os.unlink(pub_file)
else:
self.module.warn(f'Found existing ssh key public file "{pub_file}", no force, so skipping ssh-keygen generation')
self.module.warn('Found existing ssh key public file "%s", no force, so skipping ssh-keygen generation' % pub_file)
return (None, 'Public key already exists, use "force: yes" to overwrite', '')

cmd = [self.module.get_bin_path('ssh-keygen', True)]
Expand Down

0 comments on commit 8716aed

Please sign in to comment.