summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/CloudConfig/cc_apt_update_upgrade.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
index 8d98b3a8..1e057b31 100644
--- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py
+++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
@@ -39,6 +39,20 @@ def handle(name,cfg,cloud,log,args):
"archive.ubuntu.com/ubuntu")
rename_apt_lists(old_mir, mirror)
+
+ # set up proxy
+ proxy = cfg.get("apt_proxy", None)
+ proxy_filename = "/etc/apt/apt.conf.d/95cloud-init-proxy"
+ if proxy:
+ try:
+ contents = "Acquire::HTTP::Proxy:: \"%s\";\n"
+ with open(proxy_filename,"w") as fp:
+ fp.write(contents % proxy)
+ except Exception as e:
+ log.warn("Failed to write proxy to %s" % proxy_filename)
+ elif os.path.isfile(proxy_filename):
+ os.unlink(proxy_filename)
+
# process 'apt_sources'
if cfg.has_key('apt_sources'):
errors = add_sources(cfg['apt_sources'],