Commit ae70313
authored
Fix race condition causing sshd start failure during provisioning (#460)
* Fix race condition causing sshd start failure during provisioning
* Run first-boot tasks via systemd so sshd never races with host-key
regeneration. The old `rc.local` script ran after network.target, but
in parallel with other regular system services, like ssh.service.
Therefore, ssh.service often started (and restarted) while
`/root/firstboot.sh` was deleting keys. cloud-init’s set-passwords
module made this worse by restarting ssh mid-run.
* Replace `rc.local` with a oneshot firstboot.service (delete keys,
create new keys, reconfigure sysstat) that runs Before=ssh.service
and leaves the `/root/firstboot_done` file as a marker.
* Add a cloud-config.service drop-in so cloud-init's config stage waits
for firstboot.service, and
* Update walinuxagent.service to wait for firstboot.service, ensuring
ssh keys have been regenerated. This guarantees sshd, cloud-init, and
WALinuxAgent all start only after the first-boot tasks succeed.
* Invoke firstboot script in firstboot.service
* Move multiple firstboot commands back into a firstboot script in case
we need to extend this in the future.
* Use systemd's `ConditionFirstBoot` native option to ensure the script
is only run on firstboot, which allows us to get rid of the
file-based approach.1 parent d7fe17e commit ae70313
8 files changed
Lines changed: 36 additions & 34 deletions
File tree
- stemcell_builder/stages
- base_ssh/assets
- base_ubuntu_firstboot
- assets
- etc
- systemd/system
- root
- system_azure_init
- assets/etc
- systemd/system/cloud-config.service.d
- waagent
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
4 | 6 | | |
5 | | - | |
6 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
0 commit comments