Ubuntu Pastebin

Paste from smoser at Mon, 20 Mar 2017 20:54:19 +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
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash -e
# Boot a zesty cloud-image to recreate http://pad.lv/1669860
#
# To see boot log run this in separate window: telnet localhost 2446
# You can login with ubuntu:passw0rd on telnet prompt
# To ssh into the instance:  ssh -p 22222 ubuntu@localhost

LPID=${1}
[ -z "${LPID}" ] && {
    echo "$0: <Launchpad USERID for ssh key import>"
    exit 1;
}
BOOT="bond-rename.qcow2"
USERDATA="bond-rename-user-data"
NETWORK_CONFIG="bond-network-config"
SEED=bond-rename-seed.img
MAC1=52:54:00:12:34:00
MAC2=52:54:00:12:34:02

[ ! -e ${SEED} ] && {
    cat >${USERDATA} << EOF
#cloud-config
password: passw0rd
chpasswd: { expire: False }
ssh_pwauth: True
ssh_import_id: $LPID
EOF

    cat >${NETWORK_CONFIG} << EOF
version: 1
config:
    - type: physical
      name: interface0
      mac_address: '$MAC1'
      subnets:
          - type: dhcp
    - type: physical
      name: interface1
      mtu: 1492
      mac_address: '$MAC2'
      subnets:
          - type: static
            address: 10.0.2.100/24
          - type: static
            address: 10.0.3.100/24
          - type: static
            address: 10.0.4.100/24
          - type: static
            address: 10.0.5.100/24
          - type: static
            address: 10.0.2.200/24
            dns_nameservers:
              - 8.8.8.8
            dns_search:
              - barley.maas
    - type: physical
      mac_address: '$MAC1'
      name: interface0
    - type: physical
      mac_address: '$MAC2'
      name: interface1
    - type: bond
      bond_interfaces:
      - interface0
      - interface1
      name: bond0
      params:
          bond_miimon: 100
          bond_mode: 802.3ad
          bond_xmit_hash_policy: layer3+4
    - type: vlan
      name: bond0.108
      vlan_id: '108'
      vlan_link: bond0
      subnets:
        - type: static
          address: 65.61.151.38
          netmask: 255.255.255.252
          routes:
          - gateway: 65.61.151.37
            netmask: 0.0.0.0
            network: 0.0.0.0
        - type: static
          address: 2001:4800:78ff:1b:be76:4eff:fe06:96b3
          netmask: 'ffff:ffff:ffff:ffff::'
          routes:
          - gateway: 2001:4800:78ff:1b::1
            netmask: '::'
            network: '::'
    - type: vlan
      name: bond0.208
      vlan_id: '208'
      vlan_link: bond0
      subnets:
      - type: static
        address: 10.184.225.122
        netmask: 255.255.255.252
        routes:
        - gateway: 10.184.225.121
          netmask: 255.240.0.0
          network: 10.176.0.0
        - gateway: 10.184.225.121
          netmask: 255.240.0.0
          network: 10.208.0.0
    - type: nameserver
      address: 72.3.128.240
    - type: nameserver
      address: 72.3.128.241
EOF
    echo "instance-id: $(uuidgen || echo i-abcdefg)" > meta-data
    echo "Creating seed..."
    cloud-localds -N ${NETWORK_CONFIG} ${SEED} ${USERDATA} meta-data
}

qemu-system-x86_64 -m 1024 --enable-kvm \
  -snapshot \
  -drive file=${BOOT},format=qcow2,if=virtio \
  -cdrom $SEED \
  -net user \
  -net nic,model=virtio,macaddr=$MAC1 \
  -net nic,model=virtio,macaddr=$MAC2 \
  -redir tcp:22222::22 \
  -monitor stdio \
  -serial telnet:localhost:2446,nowait,server
Download as text