/srv/irclogs.ubuntu.com/2016/12/14/#cloud-init.txt

ffledglingHello, I'm trying to figure out how to get packages to install via cloud init behind a proxy, I haven't been able to find a good way to do so, are there any recommendations? Seems like there's an open bug about it - https://bugs.launchpad.net/cloud-init/+bug/108940508:51
b0stikffledgling, tried with a bash command to add a line for proxy in apt configuration ?09:05
ffledglingb0stik: That's the last resort, and I'm not sure if the `packages` directive from cloud config is run before or after runcmd09:11
ffledglingIs there a guaruntee on the order in which things are run by cloud-init when reading from cloud-config09:46
=== shardy is now known as shardy_lunch
=== shardy_lunch is now known as shardy
ffledglingAnswer to my previous question seems to be - https://git.launchpad.net/cloud-init/tree/config/cloud.cfg13:29
smoserffledgling, i'm guessing this is not ubuntu / debian ?14:11
smoseryou can define proxy for apt.14:11
ffledglingsmoser: nope, fedora14:12
smoserbut for general system proxy there isnt.14:12
smoserproxies are a regula pita14:12
smosergenerally speaking.14:12
smoserie, setting one up "system wide" never actually works.14:12
smoserthats myexperience.14:12
smoserthat said, i'm open to patches that set environment in cloud-init.14:13
ffledglingThat's not entirely unexpected, some tools don't support the standard proxy variables etc and then there's the lowercase vs uppercase issue14:13
ffledglingBut yeah, it'd still be nice to have the ability to set variables in the env for at least the cloud-init parts14:14
ffledglingMy current work around for this usecase is to use runcmd to add a proxy via a config file, but that relies on the order in which the steps are executed by cloud-init14:14
ffledglingWhich is okay I guess, but fairly fragile if the ordering is changed14:15
smoserffledgling, probably runcmd runs after package installation14:15
smoserso i'd use a bootcmd which is guaranteed to run before package installation14:15
smoserorder is not fragile really. bootcmd will run as early as it can.14:15
smoseri suspect there is some way specifically to tell yum about package config ?14:16
ffledglingsmoser: I didn't actually find where the package instruction is run, but for ubuntu it seems to be in the 'final' stage?14:16
smoserer... sorry. about proxy ?14:16
ffledglingsmoser: /etc/yum.conf14:16
smoserwith the move to systemd, package installation started happening at 'final' stage. it used to run at 'config' stage.14:16
smoseryeah, so waht i'd do is just in a boot cmd, edit/append to that14:17
smoserbootcmd:14:17
smoser - [sh, -c, 'echo http_proxy=http://proxy.host:port >> /etc/yum.conf']14:17
ffledglingbootcmd + cloud-init-run-once (I think that's what it's called?)14:17
ffledglingotherwise isn't bootcmd run at every boot?14:17
smoserah, yeah. bootcmd do run every time14:17
smoserso yeah, you coul use cloud-init-per too14:18
smoseror14:18
smoserjust otherwise idempotently update that file14:18
ffledglingThat might be a little harder14:18
smoserwell,  yeah, ini file14:19
ffledglingI was trying to figure out if there's a way to just tell cloud-init to take a file I hand it and stick it someplace on the target system14:20
ffledglingbut I didn't find anything like that yet14:20
smoserwell, there is write_files14:20
smoserhttp://cloudinit.readthedocs.io/en/latest/topics/examples.html#writing-out-arbitrary-files14:21
smoserand that runs very early14:21
smoserright after bootcmd14:21
ffledglingThat might work as well14:21
ffledglingDoesn't say if it's written everytime or just once, I suspect, just one?14:22
ffledgling*once14:22
smoserthat will run once per instance14:22
smoserso yeah, that'd probably work for you.14:22
ffledglingsounds good, I'll try both probably and see what works best14:23
smoserconfiguring yum is preferable in my opinion to configuring system wide, or relying on environment variables.14:23
ffledglingsmoser: well, the problem is I really do need a system wide proxy for my eventual operations14:23
smoserwell, you can write /etc/environment if you want.14:23
ffledglingExcept in my case I'm using ansible to configure the VM after it's up so I can push that problem down there14:23
smosermy experience with system wide proxies is just they always end up sucking14:23
smoserfor reasons largely of 'no_proxy'14:24
ffledglingApplications not respecting no_proxy or people not setting it?14:24
smoserie, if the proxy is on the other side of the router, and it wont proxy some cidr, then globally setting http_proxy=that.proxy ends up sending all http requests to it, and it can't proxy for your network14:24
smosermost obvious example is:14:25
smoser http_proxy=http://example.com wget http://127.0.0.1:8000/my-test-application14:25
smoserbut the same general thing occurs when the proxy doesn't work for your 10.0.0.0/24 or something.14:25
ffledglingright, that probably doesn't workt without no_proxy whitelisting your local network14:26
smoserand no_proxy only works very coarsely (python apps can't take a cidr, but some others doo)14:26
smoserie, if you wantto white list 10.0.0.0/24 you end up having to do:14:26
smoser no_proxy=10.0.0.1,10.0.0.2,10.0.0.3,.....10.0.0.25514:26
smoserwhich quickly becomes unmaintainable.14:26
ffledglingah, right, no_proxy is "only" respects domains14:27
ffledglings/is//14:27
smoserthe only solution to such a thing that i've come accross is using a local proxy and pointing everything at that, and having its richer syntax do the selection for you.14:27
smoserffledgling, well, no_proxy in some cases (i think wget) supports 10.0.0.*14:27
smoserbut it does not in python's implementation and probably many others14:28
smoserhttp://bazaar.launchpad.net/~smoser/+junk/sstack-proxy/view/head:/sstack-proxy14:28
smoserthat is what i've done that actually works... but comes at a cost of a middle man14:28
smoserthen, you can change the config of tinyproxy and restart it, and you dont have to deal with getting the environment changed in existing processes.14:28
smoserbut... that is just really neither here nor there... just sort of my experience with setting proxy and coming out hating the whole thing.14:29
ffledglingYeah, proxies aren't really great, but i've just come to treat them as a necessary evil14:29
smoserthe above is what i ended up having to do, and does work fairly well.14:30
smoserwhen you realize you forgot yourhost.com from the proxy config, you just add it in tinyproxy and restart tinyproxy14:30
smoserand tinyproxy config supports cidr14:30
smoserfully14:30
smoserso 192.168.2.0/24 or 9.0.0.1/3214:30
smoserand ipv6 and all that...14:30
ffledglingyep, I've seen the same setup recommended by a lot of people, after a certain point I'm sure it become necessary14:31
ffledglingsmoser: speaking of patches (saw your comment on the bug for env var support as well), I have a doc fix that I sent in a couple of days ago14:32
smoserwhere did i comment on that ?14:34
smoseri've lost it now14:34
smoserdid i comment?14:34
smoserhttps://code.launchpad.net/~ffledgling/cloud-init/+git/cloud-init-1/+merge/31291714:34
* ffledgling was looking for the link to it himself, the launchpad interface is new and confusing14:34
ffledglingsmoser: yeah, that one14:34
smoserffledgling, so the link you want is https://code.launchpad.net/%7Ecloud-init-dev/cloud-init/+git/cloud-init/+ref/master/+activereviews14:35
smoserthen from there you can find things...14:35
smoser(that is the topic of this channel too)14:35
smoseralso...14:35
smoserdid you delete another one ?14:36
smoseryou dont hve to delete a MP you can just push to it again (even push --overwrite)14:36
smoserthen you dont lose the history of comments and such14:36
ffledglingI deleted the repo I think14:36
ffledglingI'd originally created  repo called ~ffledgling/cloud-init/something/cloud-init14:36
ffledglingI don't think I've deleted an MP specifically14:37
smoserdid i comment ?14:46
smoseri swear i commented somehwere.14:46
ffledglingsmoser: I don't see it on the MP14:47
ffledglingI didn't get an email for a comment either, I just checked14:47
ffledglingMaybe it's saved as a draft or something?14:48
smoserwell, i'llj ust type again14:48
ffledglingsmoser: thanks15:06
ffledglingre: the patch for env variable support, is there a particular place in the code I should start with if I wanted to implement it?15:06
smoserffledgling, i commented there now. sorry. i thought i did that yesterday but failed i guess.15:21
ffledglingsmoser: thanks, I haven't looked at upstart (don't use ubuntu much outside of experiments), I'll take a look and get back to you15:23
=== shardy is now known as shardy_afk
smoserrangerpbzzzz, around ?18:32
rharpersmoser: looking to detect if the running distro supports netplan;  I'm checking 3 things  1) do we have /etc/netplan dir  2) do we have netplan binary in $PATH 3) do we have systemd-networkd .  (3) is harder as it's not in $PATH and it's not a package (it's part of systemd) possibly optional on other distros ...   thoughts on (3) ?   Also, I was thinking this was a cloudinit.net.netplan method but each distro may need t20:21
rharpero check for support differently so could be part of the distro obj20:21
smoserwhy not just check util.which('netplan') ?20:25
smosernetplan should depend on systemd-networkd if it needs it20:26
rharperok20:30
smoserdont you think ?20:33
rharpersmoser: I think that's reasonable21:05

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!