From cdbbd670524a5d99113026e4caaebe79c886e89c Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 16 Dec 2011 16:37:01 -0500 Subject: add apt_proxy support --- cloudinit/CloudConfig/cc_apt_update_upgrade.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cloudinit/CloudConfig/cc_apt_update_upgrade.py') 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'], -- cgit v1.2.3