Andy Bavier | 30d27c9 | 2016-09-15 15:59:17 -0400 | [diff] [blame] | 1 | --- |
Andy Bavier | bef5628 | 2016-11-14 08:22:43 -0800 | [diff] [blame] | 2 | - name: Enable trusty-backports |
| 3 | apt_repository: |
| 4 | repo: "{{ item }}" |
| 5 | state: present |
Andy Bavier | 30d27c9 | 2016-09-15 15:59:17 -0400 | [diff] [blame] | 6 | with_items: |
Andy Bavier | bef5628 | 2016-11-14 08:22:43 -0800 | [diff] [blame] | 7 | - "deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe" |
| 8 | - "deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe" |
Andy Bavier | 30d27c9 | 2016-09-15 15:59:17 -0400 | [diff] [blame] | 9 | |
Andy Bavier | bef5628 | 2016-11-14 08:22:43 -0800 | [diff] [blame] | 10 | - name: Ensure LXD |
| 11 | apt: |
| 12 | name: lxd |
| 13 | state: present |
| 14 | update_cache: yes |
| 15 | default_release: trusty-backports |
| 16 | |
| 17 | - name: get "fabric" bridge interface |
| 18 | shell: route -n | grep 10.6.1.0 | awk '{print $8}' |
| 19 | register: bridge |
| 20 | tags: |
| 21 | - skip_ansible_lint # running a sub job |
| 22 | |
| 23 | - name: Create testclient LXD profile |
| 24 | lxd_profile: |
| 25 | name: testclient |
| 26 | state: present |
| 27 | config: |
| 28 | user.user-data: | |
| 29 | #cloud-config |
| 30 | write_files: |
| 31 | - path: /etc/rc.local |
| 32 | permissions: "0755" |
| 33 | content: | |
| 34 | #!/bin/sh -e |
| 35 | # Set up VLAN tagging interface ("simulated OLT") |
| 36 | ip link add link eth0 name eth0.222 type vlan id 222 |
| 37 | ip link add link eth0.222 name eth0.222.111 type vlan id 111 |
| 38 | ifconfig eth0.222 up |
| 39 | ifconfig eth0.222.111 up |
| 40 | dhclient eth0.222.111 |
| 41 | exit 0 |
| 42 | bootcmd: |
| 43 | - sed -i 's/eth0 inet dhcp/eth0 inet manual/g' /etc/network/interfaces.d/eth0.cfg |
| 44 | description: 'Subscriber test client' |
| 45 | devices: |
| 46 | eth0: |
| 47 | nictype: bridged |
| 48 | parent: "{{ bridge.stdout }}" |
| 49 | type: nic |
| 50 | |
| 51 | - name: Create testclient container |
| 52 | lxd_container: |
| 53 | name: testclient |
| 54 | architecture: x86_64 |
| 55 | state: started |
| 56 | source: |
| 57 | type: image |
| 58 | mode: pull |
| 59 | server: https://cloud-images.ubuntu.com/releases |
| 60 | protocol: simplestreams |
| 61 | alias: "{{ ansible_distribution_release }}" |
| 62 | profiles: ["testclient"] |
| 63 | timeout: 600 |
| 64 | |
| 65 | - name: Stop container |
| 66 | lxd_container: |
| 67 | name: testclient |
| 68 | state: stopped |
Andy Bavier | b83beac | 2016-10-20 15:54:08 -0400 | [diff] [blame] | 69 | register: result |
| 70 | until: result | success |
Andy Bavier | bef5628 | 2016-11-14 08:22:43 -0800 | [diff] [blame] | 71 | retries: 3 |
| 72 | delay: 10 |