<div dir="ltr"><div><div><div>I've been effectively building a network interfaces file and pushing it to the container.<br></div>I posted my script here: <a href="https://www.reddit.com/r/homelab/comments/50s7jz/lxd_automation_script/">https://www.reddit.com/r/homelab/comments/50s7jz/lxd_automation_script/</a><br><br></div>I'm in the process of moving my build scripts to python, but that shell script worked.<br><br></div>Matt<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 October 2016 at 20:22, Caleb Everett <span dir="ltr"><<a href="mailto:caleb@calebeverett.io" target="_blank">caleb@calebeverett.io</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><a href="https://github.com/lxc/lxd/issues/2050" target="_blank">https://github.com/lxc/lxd/<wbr>issues/2050</a><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 19, 2016 at 4:37 AM, Nicola Volpini <span dir="ltr"><<a href="mailto:nicola.volpini@kambi.com" target="_blank">nicola.volpini@kambi.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello<br>
<span>> ATM what I do is either use dnsmasq to provide DHCP or stop the<br>
> container and push a preconfigured interfaces file...<br>
><br>
> lxc file push interfaces.tmp CONTAINER/etc/network/interfac<wbr>es<br>
</span>Same approach we are using, but with Ansible as our<br>
"bootstrapper/configurer".<br>
<br>
I've been successfully able to do the following:<br>
<br>
1. generate instance-specific config in the form of a cloud-init file<br>
2. create container<br>
3. take down network on the container by running lxc exec ... ifdown -a<br>
4. generate the container's nw config file on the LXD host via ansible<br>
and push it to the container via "lxc push" (and remove the default<br>
configs if necessary)<br>
5. bring up network on the container by running lxc exec ... ifup -a<br>
<br>
The cloud-init config is used to inject the ssh key, setup the ssh<br>
daemon+config and create an ansible-remote user. That user is necessary<br>
for ansible to do later more complex configs by directly accessing the<br>
container over ssh, as you would do for a normal ansible host.<br>
<br>
Something cleaner would be cool, possibly integrated in cloud-init itself.<br>
<br>
I guess this is somehow possible by creating your custom images and<br>
customizing the templates section of the metadata.yaml file, as outlined<br>
in the last part of this article<br>
<a href="https://www.stgraber.org/2016/03/30/lxd-2-0-image-management-512/" rel="noreferrer" target="_blank">https://www.stgraber.org/2016/<wbr>03/30/lxd-2-0-image-management<wbr>-512/</a><br>
<br>
CONFIDENTIALITY NOTICE: This email message (and any attachment) is intended only for the individual or entity to which it is addressed. The information in this email is confidential and may contain information that is legally privileged or exempt from disclosure under applicable law. If you are not the intended recipient, you are strictly prohibited from reading, using, publishing or disseminating such information and upon receipt, must permanently delete the original and destroy any copies. We take steps to protect against viruses and other defects but advise you to carry out your own checks and precautions as Kambi does not accept any liability for any which remain. Thank you for your co-operation.<br>
<div class="m_-4915783277098650316HOEnZb"><div class="m_-4915783277098650316h5">______________________________<wbr>_________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org" target="_blank">lxc-users@lists.linuxcontainer<wbr>s.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" rel="noreferrer" target="_blank">http://lists.linuxcontainers.o<wbr>rg/listinfo/lxc-users</a></div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.<wbr>linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" rel="noreferrer" target="_blank">http://lists.linuxcontainers.<wbr>org/listinfo/lxc-users</a><br></blockquote></div><br></div>