Scott Baker | bd8aaaf | 2016-05-19 09:10:58 -0700 | [diff] [blame] | 1 | - hosts: localhost |
| 2 | connection: local |
| 3 | tasks: |
| 4 | - name: Unmount proc, if it is mounted |
| 5 | shell: umount /image/inside/proc removes=/image/inside/proc/cmdline |
| 6 | |
| 7 | - name: Unmount the image, if it is mounted |
| 8 | shell: umount /image/inside removes=/image/inside/root |
| 9 | |
| 10 | - name: Unconnect the nbd device, if it is connected |
| 11 | shell: qemu-nbd --disconnect /dev/nbd0 removes=/dev/nbd0p1 |
| 12 | |
| 13 | - name: copy the base image to the desgination filename |
Scott Baker | 2aaeafc | 2016-05-19 15:20:07 -0700 | [diff] [blame] | 14 | shell: cp /image/trusty-server-multi-nic.img /image/vsg.img creates=/image/vsg.img |
Scott Baker | bd8aaaf | 2016-05-19 09:10:58 -0700 | [diff] [blame] | 15 | |
| 16 | - name: make the mountpount |
| 17 | shell: mkdir /image/inside creates=/image/inside |
| 18 | |
| 19 | - name: connect the nbd device |
Scott Baker | 2aaeafc | 2016-05-19 15:20:07 -0700 | [diff] [blame] | 20 | shell: qemu-nbd --connect=/dev/nbd0 /image/vsg.img creates=/dev/nbd0p1 |
Scott Baker | bd8aaaf | 2016-05-19 09:10:58 -0700 | [diff] [blame] | 21 | |
| 22 | - name: mount the image |
| 23 | shell: mount /dev/nbd0p1 /image/inside creates=/image/inside/root |
| 24 | |
| 25 | - name: mount proc |
| 26 | shell: mount -t proc proc /image/inside/proc creates=/image/inside/proc/cmdline |
| 27 | |
| 28 | - hosts: chroots |
| 29 | connection: chroot |
| 30 | tasks: |
Scott Baker | f02260d | 2016-05-19 09:37:45 -0700 | [diff] [blame] | 31 | - name: Stop resolvconf service |
| 32 | service: name=resolvconf state=stopped |
Scott Baker | bd8aaaf | 2016-05-19 09:10:58 -0700 | [diff] [blame] | 33 | |
Scott Baker | f02260d | 2016-05-19 09:37:45 -0700 | [diff] [blame] | 34 | - name: Disable resolvconf service |
| 35 | copy: dest=/etc/init/resolvconf.override content="manual" |
| 36 | |
| 37 | - name: Install resolv.conf |
| 38 | copy: src=files/vm-resolv.conf |
| 39 | dest=/etc/resolv.conf |
Scott Baker | bd8aaaf | 2016-05-19 09:10:58 -0700 | [diff] [blame] | 40 | |
| 41 | - name: install bridge-utils |
| 42 | apt: name=bridge-utils state=present |
| 43 | |
Scott Baker | f02260d | 2016-05-19 09:37:45 -0700 | [diff] [blame] | 44 | - name: Docker repository |
| 45 | copy: src=files/docker.list |
| 46 | dest=/etc/apt/sources.list.d/docker.list |
| 47 | |
| 48 | - name: Import the repository key |
| 49 | apt_key: keyserver=keyserver.ubuntu.com id=36A1D7869245C8950F966E92D8576A8BA88D21E9 |
| 50 | |
| 51 | - name: Update cache |
| 52 | apt: update_cache=yes |
| 53 | |
| 54 | - name: install Docker |
| 55 | apt: name=lxc-docker state=present |
| 56 | |
| 57 | - name: install python-setuptools |
| 58 | apt: name=python-setuptools state=present |
| 59 | |
| 60 | - name: install pip |
| 61 | easy_install: name=pip |
| 62 | |
| 63 | - name: install docker-py |
| 64 | pip: name=docker-py version=0.5.3 |
| 65 | |
| 66 | - name: install Pipework |
| 67 | get_url: url=https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework |
| 68 | dest=/usr/local/bin/pipework |
| 69 | mode=0755 |
| 70 | |
| 71 | # now unmount the image file |
| 72 | |
| 73 | - hosts: localhost |
| 74 | connection: local |
| 75 | tasks: |
| 76 | - name: sync the filesystem |
| 77 | shell: sync |
| 78 | |
| 79 | - name: Unmount proc, if it is mounted |
| 80 | shell: umount /image/inside/proc removes=/image/inside/proc/cmdline |
| 81 | |
| 82 | - name: Unmount the image, if it is mounted |
| 83 | shell: umount /image/inside removes=/image/inside/root |
| 84 | |
| 85 | - name: Unconnect the nbd device, if it is connected |
| 86 | shell: qemu-nbd --disconnect /dev/nbd0 removes=/dev/nbd0p1 |
| 87 | |
Scott Baker | bd8aaaf | 2016-05-19 09:10:58 -0700 | [diff] [blame] | 88 | |