Merge lp:~sergiusens/cloud-init/snappy into lp:~smoser/cloud-init/snappy

Proposed by Sergio Schvezov
Status: Merged
Merged at revision: 1040
Proposed branch: lp:~sergiusens/cloud-init/snappy
Merge into: lp:~smoser/cloud-init/snappy
Diff against target: 13 lines (+4/-0)
1 file modified
cloudinit/config/cc_snappy.py (+4/-0)
To merge this branch: bzr merge lp:~sergiusens/cloud-init/snappy
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+243420@code.launchpad.net

This proposal supersedes a proposal from 2014-12-02.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

some questions
a.) why 'status' after 'start' ?
   the output of that command wont go anywhere where you could see it
b.) will 'start' fail if already started ?
    will 'stop' fail if not started ?

we dont want to raise exception in the event of either of 'b' erroring out if the end result is correct.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

> some questions
> a.) why 'status' after 'start' ?
> the output of that command wont go anywhere where you could see it
> b.) will 'start' fail if already started ?
> will 'stop' fail if not started ?
>
> we dont want to raise exception in the event of either of 'b' erroring out if
> the end result is correct.

Given 'a' and 'b' I'll remove status; I thought we wanted to error if it failed to start for whatever reason and status returns '3' if the service is stopped;

wrt 'b' specifically, it's idempotent

ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ echo $?
0
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ echo $?
0
ubuntu@localhost:~$ sudo systemctl start ssh
ubuntu@localhost:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
   Active: active (running) since Tue 2014-12-02 16:32:39 UTC; 34s ago
 Main PID: 759 (sshd)
   CGroup: /system.slice/ssh.service
           └─759 /usr/sbin/sshd -D

Dec 02 16:32:39 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:32:39 localhost.localdomain sshd[759]: Could not load host key: /e...y
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on 0.0.0.0....
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on :: port 22.
Dec 02 16:32:44 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:33:08 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Hint: Some lines were ellipsized, use -l to show in full.
ubuntu@localhost:~$ sudo systemctl stop ssh
ubuntu@localhost:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
   Active: inactive (dead) since Tue 2014-12-02 16:33:17 UTC; 2s ago
  Process: 759 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=0/SUCCESS)
 Main PID: 759 (code=exited, status=0/SUCCESS)

Dec 02 16:32:39 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:32:39 localhost.localdomain sshd[759]: Could not load host key: /e...y
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on 0.0.0.0....
Dec 02 16:32:39 localhost.localdomain sshd[759]: Server listening on :: port 22.
Dec 02 16:32:44 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:33:08 localhost.localdomain systemd[1]: Started OpenBSD Secure Shel...
Dec 02 16:33:17 localhost.localdomain systemd[1]: Stopping OpenBSD Secure She...
Dec 02 16:33:17 localhost.localdomain systemd[1]: Stopped OpenBSD Secure Shel...
Hint: Some lines were ellipsized, use -l to show in full.
ubuntu@localhost:~$ echo $?
3
ubuntu@localhost:~$ sudo systemctl stop ssh
ubuntu@localhost:~$ echo $?
0

lp:~sergiusens/cloud-init/snappy updated
1040. By Scott Moser

start or stop ssh based on enable_ssh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/config/cc_snappy.py'
2--- cloudinit/config/cc_snappy.py 2014-12-01 20:28:37 +0000
3+++ cloudinit/config/cc_snappy.py 2014-12-02 16:40:46 +0000
4@@ -89,7 +89,11 @@
5 not_to_be_run = "/etc/ssh/sshd_not_to_be_run"
6 if enabled:
7 util.write_file(not_to_be_run, "cloud-init\n")
8+ # this is an indempotent operation
9+ util.subp(["systemctl", "start", "ssh"])
10 else:
11+ # this is an indempotent operation
12+ util.subp(["systemctl", "stop", "ssh"])
13 util.del_file(not_to_be_run)
14
15

Subscribers

People subscribed via source and target branches

to all changes: