/srv/irclogs.ubuntu.com/2016/03/28/#cloud-init.txt

=== jgrimm-afk is now known as jgrimm
mjb_Hi all, I'm a total cloud-init newbie.  I'm working on rolling my own AMI for AWS EC2.15:05
mjb_I'm trying to figure out how to tell cloud-init whichuser to initialize with the ssh key at instance creation time.  If anyone can offer me a clue or point me to an example, that would be greatly apprecaiated.15:07
smatzekmjb_:  I'm not sure how the key(s) get passed in in AWS, but in OpenStack clouds, the key pair (singular), that you specify on the create server is passed in in server metadata and cloud-init adds it for the default user.  The default user is specified in /etc/cloud/cloud.cfg here:  https://github.com/openstack/cloud-init/blob/0.7.x/config/cloud.cfg#L8715:20
smatzekmjb_:  If you pass in a #cloud-config style YAML in the userdata / script field, you have complete control over the number of keys you pass in and which users get them.  See this example:  http://cloudinit.readthedocs.org/en/latest/topics/examples.html#including-users-and-groups15:22
mjb_Thanks guys.  I'll be trying it out shortly.15:26
sterfieldhey guys. I can see that cloud-init is grabing metadata information from different datasources. I suppose it’s using them internally, but is it possible to know which metadata / userdata were retrieved by the datasource(s) and use them, for example in an external script ?16:00
walditake a look into /var/lib/cloud-init16:01
waldis,-init,,16:01
madornin an openstack environment, can cloud-init take advantage of any custom nova metadata passed during boot, i.e. the --meta= flags16:03
sterfieldwaldi: thanks, but there’s only “user-data.txt” which contains the user data16:04
sterfieldI can’t see metadata information16:04
madornsterfield, you can output the last used datasource16:05
madornby catting out the datasource file16:05
madornand then looking at that specific datasource..16:05
sterfieldhmm16:06
sterfielddatasource file contains only one line16:07
sterfieldDataSourceEc2: DataSourceEc216:07
sterfieldthat’s it16:07
madornthats normal16:07
madornnow look at your ec2 datasource16:07
madornfor the metadata it retrieved16:07
madorncurl 169.254.169.25416:07
sterfieldhmm ok16:08
sterfieldso yeah, short answer is “cloud-init retrieves metadata but does not expose them”16:08
sterfieldI’m already grabing metadata / userdata through the magic url16:08
madornwell its written to the ob.pkl16:08
madornif u look at the obj.pkl file16:09
sterfieldmadorn: oh now I’m interested !16:09
sterfieldI just want to “template” a file, with the content of some metadata16:09
madorn/var/lib/cloud/instances/your_instance_id/obj.pk16:09
madornl16:09
sterfieldright now, I’ve created a python script which grabs the metadata / userdata and template some file in jinja216:09
sterfieldbut I was thinking of doing it directly in cloud-init16:10
madornyou should just create a cloud-init python module16:11
madorncat /etc/cloud/cloud.cfg16:11
madornthose modules are basically python scripts16:12
sterfieldyeah16:12
sterfielda final module could be cool16:12
sterfieldthat grabs some templated files and template them using whatever engine available16:12
sterfieldanother question regarding the differente cloud-init phases16:14
sterfieldthere’s init, config, and final16:14
sterfieldthat’s ok16:14
sterfieldbut there’s a very early phase, which is init —local16:14
madornyes16:14
sterfieldlaunch very early in the boot process16:14
sterfieldand I cannot get much information from this phase16:14
madornit runs before networking is up. and looks for local userdata/metadata16:15
sterfieldok16:15
madornfor example16:15
sterfieldbut there’s no module attached to this phase ?16:15
madornits the same as init....16:15
madornif it finds local userdata/metadata16:15
madornexamples of local userdata/metadata would be /var/lib/cloud/seed/nocloud/{user,meta,vendor}-data16:16
madornor it could be an optical or block device16:17
madornthere are requirements for the attached device16:18
madornit needs to be vfat with special label of "cidata"16:18
madornif it doesnt find any local devices it moves on to regular init.16:18
madornafter networking boots16:19
smatzeksterfield:  if you write your own cc_ module for cloud init you can get at the server metadata.  This is the only example I've been able to find of an existing module doing so: https://github.com/openstack/cloud-init/blob/0.7.x/cloudinit/config/cc_seed_random.py#L7616:22
smatzekit's tempting to use the arbitrary key-value support of OpenStack server metadata to pass arbitrary key-values to cloud-init for some consumption.  However I'd personally avise against it since it's not a common case and the more common case is to control such things through userdata and a module to consume a section of userdata.16:25
madornsmatzek: thanks - do you know whether cloud-init used to take advantage of the nova metadeta key value pairs16:25
madorni was looking at some old forum posts online and there are some examples of passing dsmode values via nova boot --meta16:26
sterfieldmadorn: so init —local is applying the same module as init (per cloud.cfg configuration), but apply them from local (=non-network) data16:26
madornsterfield, that is correct -if it cant find any data locally, networking comes up and and then "cloud-init init" runs.16:27
sterfieldif the same data is available in local and init phase, what happens ?16:28
smatzekmadorn:  as noted above, cloud-init does consume the metadata but doesn't expose it to scripts it calls, etc.  It looks like the code does have some ability to affect dsmode with key-value from Nova boot.16:28
madornsterfield: it will stop with the data it receives at --local, unless otherwise specified to "pass"16:29
smatzekmadorn: the code here is checking metadata for dsmode items  https://github.com/openstack/cloud-init/blob/0.7.x/cloudinit/sources/DataSourceConfigDrive.py#L9816:30
madornsmatzek, thanks checking it out now16:30
sterfieldmadorn: ok so one module is applied once, whatever the phase16:31
madornall modules under the init stage are applied16:32
madornand then config runs..16:32
madornall those modules16:32
madornand then fina16:32
madornl16:32
madornbut the search for datasources has ended.16:32
madornsterfield: this is all configurable by the way, with every datasource thats available (/etc/cloud/cloud.cfg/90_dpkg.cfg) you have the ability to control the "mode".16:36
madornfor example, pass mode which would suggest that the datasource should be skipped over16:37
sterfieldmadorn: hmm interesting16:40
sterfieldthanks a lot for the information !16:40
madornno prob16:41
madornsmatzek: thanks for pointing that out16:42
madornit does acutally work16:42
madornjut booted an instance wit dsmode pass16:42
smoserwaldi, probably the syslog target change is fine.17:19
smoserjust ignoring failure to read a random seed doesn't seem like simply a good idea. even though it looks like that is waht we're already doing by 'quiet=True'17:20
waldithen add a permissions check -- access(file, R_OK)17:22
waldicurrently it is simply broken17:23
smoserso this breaks you when you build on azure i guess ?17:32
smoseris that it ? as the tests fail, right?17:32
smoserOdd_Bloke, still around ?17:38
smoserboth of waldi's bugs there could be fixed mostly with the fixes he's provided. i wonder if you could take a look at thos tomorrow ?17:39
ahmetalpbalkansmoser: Hey! Any ideas about this error from make rpm: https://bugs.launchpad.net/cloud-init/+bug/1561169/comments/217:43
ahmetalpbalkanit looks like running it on azure VMs have some sort of contamination on the build17:44
waldiahmetalpbalkan: maybe someone need to fix the spec file?17:46
ahmetalpbalkanwaldi: I'm having trouble understanding what the issue is in general.17:46
smoserahmetalpbalkan, try http://paste.ubuntu.com/15541645/17:47
smoserthat woudl probably fix the duplicate file (if that is fatal)17:47
smoseri dont know the correct way to referecne lib/udev in rpmspec speak17:48
smoserpossibly http://paste.ubuntu.com/15541659/17:48
smoser?17:48
smoserharlowja_at_home, probably did that originally. i dont have the ability to check that at the moment.17:49
ahmetalpbalkansmoser: hmm that just turned the error into: Directory not found: /root/rpmbuild/BUILDROOT/cloud-init-0.7.7-bzr1188.el7.centos.x86_64/usr/lib64/udev17:51
smoserahmetalpbalkan, well need to figure out how to refer to lib/udev17:52
smoserwe're putting files in there now, and you need to collect them.17:52
ahmetalpbalkanhmm perhaps I should try on a non-Azure machine17:52
smoserlooks like there is a17:53
smoser %{udev_dir}17:53
smoserhttp://permalink.gmane.org/gmane.comp.storage.libstoragemgmt.devel/228417:53
smoseroh. no, they define it there.17:53
smoserthat seems very odd. why would they use /usr/lib/ for udev17:54
ahmetalpbalkanno idea17:54
waldibecause they have anything in /usr17:54
waldihttps://fedoraproject.org/wiki/Features/UsrMove17:54
smoserhttp://paste.ubuntu.com/15541772/17:58
smoserahmetalpbalkan, ^ try that17:59
ahmetalpbalkanit18:00
ahmetalpbalkansmoser: is it {_udev_dir} or {_udev_dir}}18:00
ahmetalpbalkanI guess single ne18:00
ahmetalpbalkanone*18:00
ahmetalpbalkansmoser: hmm it says File must begin with "/": %{_udev_dir}/udev/18:02
ahmetalpbalkanI wonder if I applied the patch incorrectly18:02
smoserhm..18:03
smoserhm.18:03
smoseri just copied mostly from that line, but realize i did typo the macro18:04
smosermaybe http://paste.ubuntu.com/15541843/18:04
ahmetalpbalkanhmm18:06
ahmetalpbalkanhttps://www.irccloud.com/pastebin/0xpz3LLG/18:06
ahmetalpbalkansend just the patch maybe?18:06
ahmetalpbalkanI actually wonder how others packaged it to rhel/centos so far :)18:17
ahmetalpbalkanand started wondering if something is wrong with me last week18:17
suro-patzhi folks, how to build an EL7 rpm of cloud-init?18:28
suro-patzsmoser: ^^18:28
suro-patzcan we build it on a RHEL7 system?18:29
suro-patzon RHEL7 system, 'make rpm' is failing complaining about 'rpmbuild'18:29
suro-patzharlowja_at_home: ^^18:30
smosersuro-patz, i'm really not sure. ahmetalpbalkan was i think dealing with that too.18:30
smoserand,yeah, harlowja_at_home migth be the best resource.18:30
smoserahmetalpbalkan, i dont understand the paste up there.18:30
smoseri'd have thougth taht http://paste.ubuntu.com/15542154/ as packages/redhat/cloud-init.spec.in would be right.18:30
ahmetalpbalkansmoser: that's the error I'm getting from `make rpm` using the paste you provided19:13
ahmetalpbalkanBTW "Download as text" on paste.ubuntu isn't working19:13
ahmetalpbalkancan you please use another paste site maybe?19:13
ahmetalpbalkanit might be some copy/paste issue from HTML19:13
ahmetalpbalkan(I get error "Plain form not available for deep linking." from paste website)19:14
=== smatzek_ is now known as smatzek

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