Skip to content

Improve cc_set_passwords.#1456

Merged
blackboxsw merged 2 commits into
canonical:mainfrom
aciba90:improve_cc_set_passwords
May 17, 2022
Merged

Improve cc_set_passwords.#1456
blackboxsw merged 2 commits into
canonical:mainfrom
aciba90:improve_cc_set_passwords

Conversation

@aciba90
Copy link
Copy Markdown
Contributor

@aciba90 aciba90 commented May 16, 2022

  • If the system doesn't use systemd and the status of the ssh
    service is not 0, then apply the pw_auth config. As distros as
    Alpine could start the ssh service later in the boot sequence.

  • Change log level from warning to debug when ssh_pwauth is
    written but the ssh service is not restarted.

Proposed Commit Message

Improve cc_set_passwords.

- If the system doesn't use systemd and the status of the ssh
service is not 0, then apply the pw_auth config. As distros as
Alpine could start the ssh service later in the boot sequence.

- Change log level from warning to debug when ssh_pwauth is
written but the ssh service is not restarted.

Additional Context

SC-968
#1450 (comment)

Test Steps

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

@aciba90 aciba90 marked this pull request as draft May 16, 2022 17:25
- If the system doesn't use systemd and the status of the ssh
service is not 0, then apply the pw_auth config. As distros as
Alpine could start the ssh service later in the boot sequence.

- Change log level from warning to debug when ssh_pwauth is
written but the ssh service is not restarted.
@aciba90 aciba90 force-pushed the improve_cc_set_passwords branch from 5512cec to 38cedfa Compare May 16, 2022 17:56
@aciba90 aciba90 marked this pull request as ready for review May 16, 2022 18:11
@blackboxsw blackboxsw self-assigned this May 16, 2022
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this not uses_systemd conditional first so we can avoid compound conditionals for the uses_systemd exit_code 3 & 4 cases.

Comment thread cloudinit/config/cc_set_passwords.py Outdated
service,
)
return
elif not uses_systemd:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes sense to shuffle this condition up first so we can drop the if uses_systemd and ... in the other conditionals

if not distro.uses_systemd():
    <your new debug log>
elif e.exit_code == 3:
   <existing exit_code 3 behavior>
elif e.exid_code == 4:
   < existing exit_code 4 behavior>
else:
   LOG.warning(Ignoring...)
   return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified. Thanks for the suggestion @blackboxsw.

@aciba90
Copy link
Copy Markdown
Contributor Author

aciba90 commented May 17, 2022

This one is ready to review. Thanks @blackboxsw.

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Thanks for this work @aciba90

@blackboxsw blackboxsw merged commit 98388b5 into canonical:main May 17, 2022
@aciba90 aciba90 deleted the improve_cc_set_passwords branch May 23, 2022 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants