Skip to content

Allow registering replica-first-boot scripts#448

Open
petrutlucian94 wants to merge 3 commits into
cloudbase:masterfrom
petrutlucian94:firstboot_phase
Open

Allow registering replica-first-boot scripts#448
petrutlucian94 wants to merge 3 commits into
cloudbase:masterfrom
petrutlucian94:firstboot_phase

Conversation

@petrutlucian94
Copy link
Copy Markdown
Member

@petrutlucian94 petrutlucian94 commented May 29, 2026

We've recently extended the Coriolis API to allow specifying when a given user script should be executed. We currently support the following phases:

  • osmorphing_pre_os_mount
  • osmorphing_post_os_mount

For convenience, we'll also add the following phase:

  • replica_first_boot

Sample:

coriolis deployment create fc85dc97-8e6d-40bf-8f44-1884b0b4251f  \
    --user-script-global windows=/root/user_scripts/bitlocker/suspend_using_pwd.ps1,phase=osmorphing_pre_os_mount
    --user-script-global windows=/root/user_scripts/resume_bitlocker.ps1,phase=replica_first_boot

These scripts will be executed when the replica VM boots for the first time. We'll inject them during os-morphing. As you may have noticed, the user can already do this but it's quite inconvenient to pass a script that injects another first-boot script.

We'll rely on systemd on Linux and cloudbase-init on Windows. All the Linux distributions that we support have switched to Systemd about 10 years ago. Also, as per this commit [1], we rely on the fact that cloudbase-init will be available all the time and that we can use it to run first-boot scripts.

Note that we did consider using scheduled tasks on Windows (as opposed to Cloudbase-init). We'd need to use an xml task definition and register it using registry keys, however it seems like we lack the privileges to create entries such as the following:

$HIVE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\$TaskGUID"

[1] b5f93fd

We've recently extended the Coriolis API to allow specifying *when*
a given user script should be executed. We currently support the
following phases:

* osmorphing_pre_os_mount
* osmorphing_post_os_mount

For convenience, we'll also add the following phase:

* replica_first_boot

These scripts will be executed when the replica VM boots for the
first time. We'll inject them during os-morphing. As you may have
noticed, the user can already do this but it's quite inconvenient
to pass a script that injects another first-boot script.

We'll rely on systemd on Linux and cloudbase-init on Windows.
All the Linux distributions that we support have switched to Systemd
about 10 years ago. Also, as per this commit [1], we rely on the
fact that cloudbase-init will be available all the time and that
we can use it to run first-boot scripts.

Note that we did consider using scheduled tasks on Windows
(as opposed to Cloudbase-init). We'd need to use an xml task definition
and register it using registry keys, however it seems like we lack the
privileges to create entries such as the following:

```
$HIVE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\$TaskGUID"
```

[1] cloudbase@b5f93fd
@petrutlucian94
Copy link
Copy Markdown
Member Author

Client PR: cloudbase/python-coriolisclient#101

Comment thread coriolis/osmorphing/base.py
Comment thread coriolis/osmorphing/base.py Outdated
Comment thread coriolis/osmorphing/base.py
Comment thread coriolis/osmorphing/base.py
Comment thread coriolis/osmorphing/base.py
Comment thread coriolis/osmorphing/base.py Outdated
index: int = 0,
user_provided=True,
):
if len(script) == 0:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In what scenario is this true?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The user may provide an empty script. I thought that a sanity check wouldn't hurt.

Comment thread coriolis/osmorphing/base.py Outdated
Comment thread coriolis/tests/integration/deployments/test_osmorphing.py
Comment thread coriolis/tests/osmorphing/test_manager.py Outdated
* propagate errors and avoid creating /var/lib/coriolis/firstboot-complete
  if any of the scripts fails
* log a warning if a script isn't executable
* use journal+console logging
@petrutlucian94 petrutlucian94 force-pushed the firstboot_phase branch 2 times, most recently from 11c4f05 to 48c009a Compare June 3, 2026 07:02
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