Add template for VMs creating
Change-Id: Ifbf77f794f999340846a9b144cd1444af16adfec
diff --git a/tcp_tests/templates/create-vm-on-host/underlay--user-data1604-swp.yaml b/tcp_tests/templates/create-vm-on-host/underlay--user-data1604-swp.yaml
new file mode 100644
index 0000000..9b19200
--- /dev/null
+++ b/tcp_tests/templates/create-vm-on-host/underlay--user-data1604-swp.yaml
@@ -0,0 +1,98 @@
+| # All the data below will be stored as a string object
+ #cloud-config, see http://cloudinit.readthedocs.io/en/latest/topics/examples.html
+ ssh_pwauth: True
+ users:
+ - name: root
+ sudo: ALL=(ALL) NOPASSWD:ALL
+ shell: /bin/bash
+ ssh_authorized_keys:
+ {% for key in config.underlay.ssh_keys %}
+ - ssh-rsa {{ key['public'] }}
+ {% endfor %}
+
+ disable_root: false
+ chpasswd:
+ list: |
+ root:r00tme
+ expire: False
+
+ bootcmd:
+ # Enable root access
+ - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
+ - service sshd restart
+ output:
+ all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
+
+ runcmd:
+ - if lvs vg0; then pvresize /dev/vda3; fi
+ - if lvs vg0; then /usr/bin/growlvm.py --image-layout-file /usr/share/growlvm/image-layout.yml; fi
+
+ - export TERM=linux
+ - export LANG=C
+ # Configure dhclient
+ - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
+ - sudo resolvconf -u
+
+ # Enable grub menu using updated config below
+ - update-grub
+
+ # Prepare network connection
+ - sudo ifup ens3
+ #- sudo route add default gw {gateway} {interface_name}
+
+ # Create swap
+ - fallocate -l 16G /swapfile
+ - chmod 600 /swapfile
+ - mkswap /swapfile
+ - swapon /swapfile
+ - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
+ - service salt-minion restart
+ - sleep 2
+ - salt-call saltutil.refresh_pillar
+ - salt-call saltutil.sync_all
+ - salt-call state.sls linux.network
+ - salt-call state.sls linux.system.repo
+ - salt-call state.sls linux,openssh,salt.minion,ntp,rsyslog
+ - salt-call state.sls nova
+ - salt-call state.sls neutron
+ - salt-call state.highstate
+
+ write_files:
+ - path: /etc/default/grub.d/97-enable-grub-menu.cfg
+ content: |
+ GRUB_RECORDFAIL_TIMEOUT=30
+ GRUB_TIMEOUT=3
+ GRUB_TIMEOUT_STYLE=menu
+
+ - path: /etc/salt/minion.d/minion.conf
+ content: |
+ master: ==SALT_MASTER_IP==
+ id: ==HOSTNAME.DOMAIN_NAME==
+
+ - path: /etc/network/interfaces
+ content: |
+ auto ens3
+ iface ens3 inet dhcp
+
+ - path: /usr/share/growlvm/image-layout.yml
+ content: |
+ root:
+ size: '80%VG'
+ home:
+ size: '1%VG'
+ var_log:
+ size: '5%VG'
+ var_log_audit:
+ size: '2%VG'
+ var_tmp:
+ size: '5%VG'
+ tmp:
+ size: '2%VG'
+ owner: root:root
+
+ growpart:
+ mode: auto
+ devices:
+ - '/'
+ - '/dev/vda3'
+ ignore_growroot_disabled: false