<div dir="ltr">Thank you so much - this has been bugging me for weeks.<div><br></div><div>I do have a question, however, in regards to the 'write_files' directive - since this runs before users are created (and while I understand that having it able to affect more of boot is useful, but it's not documented like that anywhere I can find), if I were to create the file in `/etc/skel` instead, would any created users pick it up from there?  Or is that ignored when creating users with cloud-init ?</div><div><br></div><div>Essentially I'm just trying to set up a simple way to put up and tear down containers that will have all of my defaults in place from the start.</div><div><br></div><div>Neil</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 2:00 PM, Serge E. Hallyn <span dir="ltr"><<a href="mailto:serge@hallyn.com" target="_blank">serge@hallyn.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Scott Moser was kind enough to provide this reply:<br>
<br>
(<a href="http://paste.ubuntu.com/23870807/" rel="noreferrer" target="_blank">http://paste.ubuntu.com/<wbr>23870807/</a>)<br>
<br>
#!/bin/sh<br>
<br>
##<br>
## This is Scott Moser in reply to<br>
##   <a href="https://lists.linuxcontainers.org/pipermail/lxc-users/2017-January/012766.html" rel="noreferrer" target="_blank">https://lists.linuxcontainers.<wbr>org/pipermail/lxc-users/2017-<wbr>January/012766.html</a><br>
## The user-data you have has some problems, and is stopping it from working<br>
## as you desire.  This script can be executed to launch an instance<br>
## with the user-data included inside it, and will show it functioning<br>
## correctly.<br>
##<br>
## I did not test, but assume that updating profile accordingly will get you<br>
## the behavior you're after.<br>
##<br>
## Scott<br>
<br>
## changes from your user-data<br>
# 'sudo' is a string, you had it as a list.<br>
# 'write_files':<br>
#    - changed path to /root/ (there is no '~' in this scenario, cloud-init<br>
#      could possibly interpret that as the default user, but it does not.<br>
#    - files are created before users are added... write files runs early<br>
#      that means it can affect more of boot, but means it can't write<br>
#      files owned by users who do not yet exist.<br>
#      there is a bug/feature request for this, we could add a<br>
#      'write_files_late' module that ran later and could then populate<br>
#      created users directories.<br>
#    - you had bad yaml in one part, the 'content' was as if it intended<br>
#      to be included in the previous 'path', but was a new list entry.<br>
#      basically that 'content' had no 'path'.<br>
#<br>
# with regard to no errors, you can see the issues with<br>
#  journalctl --unit=cloud-init.service<br>
# look for 'WARN'.  Also /run/cloud-init/result.json should report errors.<br>
#<br>
# These should get written to /var/log/cloud-init.log, but in yakkety<br>
# you wont see them there yet. (bug 1643990)<br>
<br>
udata=$(cat <<"EOF"<br>
<span class="">#cloud-config<br>
users:<br>
  - name: dood<br>
    gecos: Mr Dood<br>
    ssh_authorized_keys:<br>
</span>      - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA3I<wbr>7VUf2l5gSn5uavROsc5HRDpZdQueUq<wbr>5ozemNSj8T7enqKHOEaFoU2VoPgGEW<wbr>C9RyzSQVeyD6s7APMcE82EtmW4skVE<wbr>gEGSbDc1pvxzxtchBj78hJP6Cf5TCM<wbr>FSXw+<wbr>Fz5rF1dR23QDbN1mkHs7adr8GW4kSW<wbr>qU7Q7NDwfIrJJtO7Hi42GyXtvEONHb<wbr>iRPOe8stqUly7MvUoN+<wbr>5kfjBM8Qqpfl2+<wbr>FNhTYWpMfYdPUnE7u536WqzFmsaqJc<wbr>tz3gBxH9Ex7dFtrxR4qiqEr9Qtlu3x<wbr>Gn7Bw07/+i1D+ey3ONkZLN+<wbr>LQ714cgj8fRS4Hj29SCmXp5Kt5/<wbr>82cD/VN3NtHw== smoser@brickies<br>
<span class="">    sudo: 'ALL=(ALL) NOPASSWD:ALL'<br>
    groups: sudo<br>
    shell:  /bin/bash<br>
write_files:<br>
</span>  - owner:  root:root<br>
    path: /root/.bash_aliases<br>
<span class="">    content: |<br>
      alias dir='ls -Alph --color=auto'<br>
apt_proxy: "<a href="http://192.168.1.2:8000" rel="noreferrer" target="_blank">http://192.168.1.2:8000</a>"<br>
</span>EOF<br>
)<br>
<br>
name=$1<br>
rel=${2:-yakkety}<br>
lxc launch "ubuntu-daily:$rel" "$name" "--config=user.user-data=$<wbr>udata"<br>
<span class="HOEnZb"><font color="#888888"><br>
-serge<br>
</font></span></blockquote></div><br></div></div>