~rogpeppe/juju-core/themue-058-debug-log-api

« back to all changes in this revision

Viewing changes to environs/cloudinit/cloudinit.go

  • Committer: Frank Mueller
  • Date: 2014-01-23 14:14:49 UTC
  • mfrom: (2152.1.95 juju-core)
  • Revision ID: frank.mueller@canonical.com-20140123141449-b30l57y7gs3wjkpw
debugger: merged trunk and fixed permission and interface problems

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
        "launchpad.net/juju-core/constraints"
19
19
        "launchpad.net/juju-core/environs/config"
20
20
        "launchpad.net/juju-core/instance"
 
21
        "launchpad.net/juju-core/juju/osenv"
21
22
        "launchpad.net/juju-core/log/syslog"
22
23
        "launchpad.net/juju-core/names"
23
24
        "launchpad.net/juju-core/state"
109
110
        // the machine agent config.
110
111
        AgentEnvironment map[string]string
111
112
 
 
113
        // WARNING: this is only set if the machine being configured is
 
114
        // a state server node.
 
115
        //
112
116
        // Config holds the initial environment configuration.
113
117
        Config *config.Config
114
118
 
126
130
        // node that has an API server. At this stage, that is any machine where
127
131
        // StateServer (member above) is set to true.
128
132
        SystemPrivateSSHKey string
 
133
 
 
134
        // ProxySettings define normal http, https and ftp proxies.
 
135
        ProxySettings osenv.ProxySettings
 
136
 
 
137
        // AptProxySettings define the http, https and ftp proxy settings to use
 
138
        // for apt, which may or may not be the same as the normal ProxySettings.
 
139
        AptProxySettings osenv.ProxySettings
129
140
}
130
141
 
131
142
func base64yaml(m *config.Config) string {
166
177
// but adds to the running time of initialisation due to lack of activity
167
178
// between image bringup and start of agent installation.
168
179
func ConfigureBasic(cfg *MachineConfig, c *cloudinit.Config) error {
 
180
        c.AddScripts(
 
181
                "set -xe", // ensure we run all the scripts or abort.
 
182
        )
169
183
        c.AddSSHAuthorizedKeys(cfg.AuthorizedKeys)
170
184
        c.SetOutput(cloudinit.OutAll, "| tee -a "+cloudInitOutputLog, "")
171
185
        // Create a file in a well-defined location containing the machine's
206
220
                c.AddBootCmd(cloudinit.LogProgressCmd("Logging to %s on remote host", cloudInitOutputLog))
207
221
        }
208
222
 
 
223
        // Write out the apt proxy settings
 
224
        if (cfg.AptProxySettings != osenv.ProxySettings{}) {
 
225
                filename := "/etc/apt/apt.conf.d/42-juju-proxy-settings"
 
226
                c.AddBootCmd(fmt.Sprintf(
 
227
                        `[ -f %s ] || (printf '%%s\n' %s > %s)`,
 
228
                        filename,
 
229
                        shquote(utils.AptProxyContent(cfg.AptProxySettings)),
 
230
                        filename))
 
231
        }
 
232
 
209
233
        // Bring packages up-to-date.
210
234
        c.SetAptUpdate(true)
211
235
        c.SetAptUpgrade(true)
214
238
        c.AddPackage("git")
215
239
        c.AddPackage("cpu-checker")
216
240
 
217
 
        c.AddScripts(
218
 
                "set -xe", // ensure we run all the scripts or abort.
 
241
        // Write out the normal proxy settings so that the settings are
 
242
        // sourced by bash, and ssh through that.
 
243
        c.AddScripts(
 
244
                // We look to see if the proxy line is there already as
 
245
                // the manual provider may have had it aleady.
 
246
                `grep -q '.juju-proxy' /home/ubuntu/.profile || printf '\n# Added by juju\n[ -f "$HOME/.juju-proxy" ] && . "$HOME/.juju-proxy"\n' >> /home/ubuntu/.profile`)
 
247
        if (cfg.ProxySettings != osenv.ProxySettings{}) {
 
248
                c.AddScripts(
 
249
                        fmt.Sprintf(
 
250
                                `printf '%%s\n' %s > /home/ubuntu/.juju-proxy && chown ubuntu:ubuntu /home/ubuntu/.juju-proxy`,
 
251
                                shquote(cfg.ProxySettings.AsEnvironmentValues())))
 
252
        }
 
253
 
 
254
        c.AddScripts(
219
255
                fmt.Sprintf("mkdir -p %s", cfg.DataDir),
220
256
                "mkdir -p /var/log/juju")
221
257