Ubuntu Pastebin

Paste from smoser at Fri, 11 Mar 2016 21:16:27 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## Testing in a lxc xenial container ##

## build deb from trunk ##
# in cloud-init tree from lp:~smoser/cloud-init/trunk.net1
UNCOMMITTED=1 ./packages/bddeb
cp cloud-init_all.deb /tmp

## network config
$ cat /tmp/network-config.yaml
version: 1
config:
  # Physical interfaces.
  - type: physical
    name: eth0
    subnets:
        - type: static
          address: 10.0.2.100/24
        - type: manual
          address: 10.0.2.200/24
          dns_nameservers:
            - 8.8.8.8
          dns_search:
            - barley.maas

## local user data ##
$ cat /tmp/user-data
#cloud-config
ssh_import_id: [smoser]


## build cloud-localds seed
# cloud-localds from cloud-utils branch at
#  lp:~smoser/cloud-utils/trunk.netconfig/
$ ./bin/cloud-localds -v --dsmode=net --disk-format=tar-seed-local \
     --network-config=/tmp/network-config.yaml /tmp/seed.tar /tmp/my.userdata


## init and patch container
$ tar -C /tmp -cf /tmp/data.tar seed.tar cloud-init_all.deb
$ lxc init xenial x1
$ lxc-chroot x1 --mode=non-interactive -- sh -xec \
    'cd /tmp && tar -xf - && dpkg -i cloud-init_all.deb &&
     rm -Rf /var/lib/cloud/seed &&
     tar -C / -xf /tmp/seed.tar &&
     find /var/lib/cloud/seed -type f' < /tmp/data.tar


## check it out
$ lxc exec x1 ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:16:3e:56:56:f8  
          inet addr:10.0.3.241  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe56:56f8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3866 (3.8 KB)  TX bytes:1374 (1.3 KB)

$ lxc exec x1 -- sh -c 'ifup eth0:1 && ifconfig eth0:1'
eth0:1    Link encap:Ethernet  HWaddr 00:16:3e:56:56:f8  
          inet addr:10.0.2.200  Bcast:10.0.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

$ lxc exec x1 -- cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 10.0.3.1
search barley.maas
Download as text