# Get maas version {{py: from subprocess import check_output from shlex import split maas_version = "" cache_output = check_output(['apt-cache', 'policy', 'maas']).decode('utf-8') for line in cache_output.splitlines(): line = line.strip() if ':' in line and line.split(':')[0] == 'Installed': maas_version = line.split(':')[1].strip() break try: f = open('/etc/maas-cert-server/iperf.conf', 'r') test_target_iperf = f.readline().rstrip() f.close() except IOError: test_target_iperf = "gateway" }} #cloud-config debconf_selections: maas: | {{for line in str(curtin_preseed).splitlines()}} {{line}} {{endfor}} {{if third_party_drivers and driver}} early_commands: {{py: key_string = ''.join(['\\x%x' % x for x in map(ord, driver['key_binary'])])}} driver_00_get_key: /bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg driver_01_add_key: ["apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"] driver_02_add: ["add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"] driver_03_update_install: ["sh", "-c", "apt-get update --quiet && apt-get --assume-yes install {{driver['package']}}"] driver_04_load: ["sh", "-c", "depmod && modprobe {{driver['module']}}"] {{endif}} anchor_bucket: - &disableupdates | #!/bin/sh if [ -f /etc/apt/apt.conf.d/20auto-upgrades ] ; then echo "Disabling automatic security updates..."; /bin/sed -i 's/"1"/"0"/g' /etc/apt/apt.conf.d/20auto-upgrades; echo "Done."; fi; - &sudoers | #!/bin/sh echo "Setting up sudoers..."; echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/maas ; chmod 0440 /etc/sudoers.d/maas; echo "Done."; - &installcert #!/bin/sh echo "Installing certfication tools..."; echo " Add cert source list..."; . /etc/lsb-release; if [ -z "`grep DISTRIB_DESCRIPTION /etc/lsb-release | grep development`" ] ; then echo deb http://ppa.launchpad.net/hardware-certification/public/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/certification.list; echo deb http://ppa.launchpad.net/dannf/test/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/dannf-ubuntu-test-xenial.list; else echo deb http://ppa.launchpad.net/checkbox-dev/ppa/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/certification.list; echo deb http://ppa.launchpad.net/dannf/test/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/dannf-ubuntu-test-xenial.list; fi; echo deb http://ppa.launchpad.net/firmware-testing-team/ppa-fwts-stable/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/certification.list; echo " Running apt-get update..."; apt-get update; echo " Installing GRUB2..."; apt-get install -y --force-yes grub-efi; sleep 60; echo "Done."; - &kvm_image | #!/bin/sh echo "Setting up to use KVM image on MAAS server..."; . /etc/lsb-release; arch=$(dpkg --print-architecture); maas_ip=$(/sbin/ip route | awk '/default/ { print $3 }'); rm -rf /tmp/index.html; wget -P /tmp/ http://$maas_ip/cloud/; filename_line=$(egrep "$DISTRIB_CODENAME-server-cloudimg-$arch.*img" /tmp/index.html | head -n 1); if [ ! -z "$filename_line" ] ; then filename=$(echo $filename_line | grep -Po '(?<=href=")[^"]*(?=")'); else filename_line=$(egrep "server-cloudimg-$arch.*img" /tmp/index.html | head -n 1); filename=$(echo $filename_line | grep -Po '(?<=href=")[^"]*(?=")'); fi if [ ! -z "$filename" ] ; then sed -i "s/#KVM_TIMEOUT/KVM_TIMEOUT/g" /etc/xdg/canonical-certification.conf; sed -i "s/#KVM_IMAGE = \/path\/to\/cloudimage-filename.img/KVM_IMAGE = http:\/\/$maas_ip\/cloud\/$filename/g" /etc/xdg/canonical-certification.conf; fi; rm -f /tmp/index.html; - &iperf #!/bin/sh echo "Setting up iperf..."; /bin/sed -i '/^#TEST_TARGET_FTP /s/^#//' /etc/xdg/canonical-certification.conf; /bin/sed -i '/^#TEST_USER /s/^#//' /etc/xdg/canonical-certification.conf; /bin/sed -i '/^#TEST_PASS /s/^#//' /etc/xdg/canonical-certification.conf; /bin/sed -i '/^#TEST_TARGET_IPERF /s/^#//' /etc/xdg/canonical-certification.conf; if [ "{{test_target_iperf}}" = "gateway" ] ; then maas_ip=$(/sbin/ip route | awk '/default/ { print $3 }'); sed -i 's/ your-iperf-server.example.com/'"$maas_ip"'/g' /etc/xdg/canonical-certification.conf; else sed -i 's/ your-iperf-server.example.com/{{test_target_iperf}}/g' /etc/xdg/canonical-certification.conf; fi; echo "Done."; - &setubuntupass | #!/bin/sh echo "Setting ubuntu password..." echo "#cloud-config\nsystem_info:\n default_user:\n lock_passwd: False\n plain_text_passwd: 'ubuntu'" > /etc/cloud/cloud.cfg.d/ubuntu-user-defaults.cfg echo "Done."; late_commands: maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null'] {{if third_party_drivers and driver}} driver_00_key_get: curtin in-target -- sh -c "/bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg" driver_02_key_add: ["curtin", "in-target", "--", "apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"] driver_03_add: ["curtin", "in-target", "--", "add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"] driver_04_update_install: ["curtin", "in-target", "--", "apt-get", "update", "--quiet"] driver_05_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "{{driver['package']}}"] driver_06_depmod: ["curtin", "in-target", "--", "depmod"] driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"] {{endif}} # inject maas version into /etc/installed-with-maas and install cert tools set_maas_version: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo {{maas_version}} > /etc/installed-by-maas"] # Install certification suite zt_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *disableupdates ] zu_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *sudoers ] zv_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *installcert ] zw_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *kvm_image ] zx_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *iperf ] zy_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *setubuntupass] power_state: mode: reboot