diff --git a/windows-agent/internal/proservices/proservices.go b/windows-agent/internal/proservices/proservices.go index 681bfc104..ceccbda4d 100644 --- a/windows-agent/internal/proservices/proservices.go +++ b/windows-agent/internal/proservices/proservices.go @@ -9,6 +9,7 @@ import ( agent_api "github.com/canonical/ubuntu-pro-for-windows/agentapi/go" "github.com/canonical/ubuntu-pro-for-windows/common" + "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/cloudinit" "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/config" "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/database" "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/interceptorschain" @@ -99,6 +100,16 @@ func New(ctx context.Context, args ...Option) (s Manager, err error) { conf := config.New(ctx, opts.cacheDir) + // Write cloud-init agent data, and do so again every time the config changes. + f := func() { + if err := cloudinit.WriteAgentData(ctx, conf); err != nil { + log.Error(ctx, err) + } + } + + f() + conf.Notify(f) + db, err := database.New(ctx, opts.cacheDir, conf) if err != nil { return s, err