Skip to content

Commit

Permalink
Generate proper set of commands to setup snap store proxy via cloudinit
Browse files Browse the repository at this point in the history
While the proxyupdater worker is already capable of setting up snap to
work with snap store proxies, it runs at a later stage than the point
where we might need to install snap packages (e.g. lxd dependencies).

This commit updates the cloudinit code to include the appropriate
commands so that we can setup snap proxies as early as possible.
  • Loading branch information
achilleasa committed Sep 6, 2019
1 parent fe7a12d commit 4d7d221
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cloudconfig/cloudinit/cloudinit_ubuntu.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,22 @@ func (cfg *ubuntuCloudConfig) updateProxySettings(proxyCfg PackageManagerProxyCo
utils.ShQuote(pkgCmder.ProxyConfigContents(aptProxy)),
filename))
}

// Write out the snap http/https proxy settings
if snapProxy := proxyCfg.SnapProxy(); (snapProxy != proxy.Settings{}) {
pkgCmder := cfg.paccmder[jujupackaging.SnapPackageManager]
for _, cmd := range pkgCmder.SetProxyCmds(snapProxy) {
cfg.AddBootCmd(cmd)
}
}

// Configure snap store proxy
if proxyCfg.SnapStoreAssertions() != "" && proxyCfg.SnapStoreProxyID() != "" {
cfg.AddBootCmd(fmt.Sprintf(
`printf '%%s\n' %s > %s`,
utils.ShQuote(proxyCfg.SnapStoreAssertions()),
"/etc/snap.assertions"))
cfg.AddBootCmd("snap ack /etc/snap.assertions")
cfg.AddBootCmd("snap set core proxy.store=" + proxyCfg.SnapStoreProxyID())
}
}

0 comments on commit 4d7d221

Please sign in to comment.