Add 'packer-image-create' job

- add packer-image-create.groovy to create images with packer
- add 'tcp_tests/templates/_packer/' with configs for 'foundation'
  node

Change-Id: I23379bef389adad791df9343930095a57af3fb55
diff --git a/tcp_tests/templates/_packer/scripts/jenkins_virtualenvs.sh b/tcp_tests/templates/_packer/scripts/jenkins_virtualenvs.sh
new file mode 100644
index 0000000..eb83ab4
--- /dev/null
+++ b/tcp_tests/templates/_packer/scripts/jenkins_virtualenvs.sh
@@ -0,0 +1,23 @@
+#!/bin/bash -xe
+
+DEVOPS_VENV_PATH=/home/jenkins/fuel-devops30
+REPORT_VENV_PATH=/home/jenkins/venv_testrail_reporter
+
+if [ ! -d ${DEVOPS_VENV_PATH} ]; then
+    virtualenv ${DEVOPS_VENV_PATH}
+fi
+if [ ! -d ${REPORT_VENV_PATH} ]; then
+    virtualenv ${REPORT_VENV_PATH}
+fi
+
+# Install tcp-qa requirements
+. ${DEVOPS_VENV_PATH}/bin/activate
+pip install -r https://raw.githubusercontent.com/Mirantis/tcp-qa/master/tcp_tests/requirements.txt
+pip install psycopg2  # workaround for setup with PostgreSQL , to keep requirements.txt for Sqlite3 only
+
+# Install xunit2testrail
+. ${REPORT_VENV_PATH}/bin/activate
+#pip install xunit2testrail -U
+pip install git+https://github.com/dis-xcom/testrail_reporter -U  # Removed accessing to an unexisting pastebin on srv62
+
+chown -R jenkins:jenkins /home/jenkins/
diff --git a/tcp_tests/templates/_packer/scripts/ubuntu_cleanup.sh b/tcp_tests/templates/_packer/scripts/ubuntu_cleanup.sh
new file mode 100644
index 0000000..63a7586
--- /dev/null
+++ b/tcp_tests/templates/_packer/scripts/ubuntu_cleanup.sh
@@ -0,0 +1,70 @@
+#!/bin/bash -xe
+
+apt-get -y remove --purge unattended-upgrades || true
+apt-get -y autoremove --purge
+apt-get -y clean
+
+rm -rf /var/lib/apt/lists/* || true
+rm -rv /etc/apt/sources.list.d/* || true
+rm -rv /etc/apt/preferences.d/* || true
+echo > /etc/apt/sources.list  || true
+rm -vf /usr/sbin/policy-rc.d || true
+
+echo "cleaning up hostname"
+sed -i "/.*ubuntu.*/d" /etc/hosts
+sed -i "/.*salt.*/d" /etc/hosts
+
+echo "cleaning up guest additions"
+rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true
+
+echo "cleaning up dhcp leases"
+rm -rf /var/lib/dhcp/* || true
+rm -rfv /var/lib/ntp/ntp.conf.dhcp || true
+
+echo "cleaning up udev rules"
+rm -fv /etc/udev/rules.d/70-persistent-net.rules || true
+rm -rf /dev/.udev/ || true
+rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true
+
+echo "cleaning up minion_id for salt"
+rm -vf /etc/salt/minion_id || true
+
+echo "cleaning up resolvconf"
+sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base
+
+echo "cleaning up /var/cache/{apt,salt}/*"
+rm -rf /var/cache/{apt,salt}/* || true
+
+rm -rf /root/.cache || true
+rm -rf /root/.ssh/known_hosts || true
+
+# Remove flags
+rm -v /done_ubuntu_base || true
+rm -v /done_ubuntu_salt_bootstrap || true
+
+# Force cleanup cloud-init data, if it was
+if [[ -d '/var/lib/cloud/' ]] ; then
+  rm -rf /var/lib/cloud/* || true
+  cloud-init clean || true
+  echo > /var/log/cloud-init-output.log || true
+  echo > /var/log/cloud-init.log || true
+fi
+
+cat << EOF > /etc/network/interfaces
+# This file describes the network interfaces available on your system
+# and how to activate them. For more information, see interfaces(5).
+
+# The loopback network interface
+auto lo
+iface lo inet loopback
+
+# Source interfaces
+# Please check /etc/network/interfaces.d before changing this file
+# as interfaces may have been defined in /etc/network/interfaces.d
+# See LP: #1262951
+source /etc/network/interfaces.d/*.cfg
+EOF
+
+# Clear\drop cache's
+sync
+echo 3 > /proc/sys/vm/drop_caches
diff --git a/tcp_tests/templates/_packer/scripts/ubuntu_ldap.sh b/tcp_tests/templates/_packer/scripts/ubuntu_ldap.sh
new file mode 100644
index 0000000..4c400fb
--- /dev/null
+++ b/tcp_tests/templates/_packer/scripts/ubuntu_ldap.sh
@@ -0,0 +1,56 @@
+#!/bin/bash -xe
+
+apt-get update
+apt-get install -y ldap-auth-client nscd ldap-utils
+
+auth-client-config -t nss -p lac_ldap
+
+sed -i 's$^#bind_policy hard$bind_policy soft$' /etc/ldap.conf
+sed -i 's$base dc=.*$base dc=mirantis,dc=net$' /etc/ldap.conf
+sed -i 's$uri ldap.*$uri ldap://ldap-bud.bud.mirantis.net/$' /etc/ldap.conf
+sed -i 's$^\(rootbinddn.*\)$#\1$' /etc/ldap.conf
+
+cat << 'EOF' >> /etc/ldap/ldap.conf
+BASE    dc=mirantis,dc=net
+URI     ldap://ldap-bud.bud.mirantis.net/
+EOF
+
+cat << 'EOF' > /usr/share/pam-configs/my_mkhomedir
+Name: activate mkhomedir
+Default: yes
+Priority: 900
+Session-Type: Additional
+Session:
+        required                        pam_mkhomedir.so umask=0022 skel=/etc/skel
+EOF
+
+cat << 'EOF' >> /etc/security/group.conf
+*;*;*;Al0000-2400;audio,cdrom,dialout,floppy,kvm,libvirtd
+EOF
+
+cat << 'EOF' > /usr/share/pam-configs/my_groups
+Name: activate /etc/security/group.conf
+Default: yes
+Priority: 900
+Auth-Type: Primary
+Auth:
+        required                        pam_group.so use_first_pass
+EOF
+
+cat << 'EOF' > /usr/local/sbin/ssh-ldap-keyauth
+#!/bin/bash
+
+/usr/bin/ldapsearch -x '(&(objectClass=posixAccount)(uid='"$1"'))' sshPublicKey | sed -n '/^ /{H;d};/sshPublicKey:/x;$g;s/\n *//g;s/sshPublicKey: //gp'
+EOF
+
+cat << 'EOF' >> /etc/ssh/sshd_config
+
+AuthorizedKeysCommand /usr/local/sbin/ssh-ldap-keyauth
+AuthorizedKeysCommandUser nobody
+EOF
+
+chmod +x /usr/local/sbin/ssh-ldap-keyauth
+DEBIAN_FRONTEND=noninteractive pam-auth-update
+
+#systemctl restart nscd.service;
+#systemctl restart sshd.service;
diff --git a/tcp_tests/templates/_packer/scripts/ubuntu_packets.sh b/tcp_tests/templates/_packer/scripts/ubuntu_packets.sh
new file mode 100644
index 0000000..883f620
--- /dev/null
+++ b/tcp_tests/templates/_packer/scripts/ubuntu_packets.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -xe
+
+apt-get update
+
+# for Jenkins agent
+apt-get install -y openjdk-8-jre-headless
+# for fuel-devops and tcp-qa
+apt-get install -y libyaml-dev libffi-dev libvirt-dev python-dev pkg-config vlan bridge-utils python-pip python3-pip virtualenv
+# additional tools
+apt-get install -y ebtables curl ethtool iputils-ping lsof strace tcpdump traceroute wget iptables htop \
+    git jq ntpdate tree mc byobu at pm-utils genisoimage iotop
+
+# ldap
+apt-get install -y ldap-auth-client nscd ldap-utils
+
+# update kernel
+apt-get install -y linux-generic-hwe-16.04
diff --git a/tcp_tests/templates/_packer/scripts/zerodisk.sh b/tcp_tests/templates/_packer/scripts/zerodisk.sh
new file mode 100644
index 0000000..159ae13
--- /dev/null
+++ b/tcp_tests/templates/_packer/scripts/zerodisk.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -x
+
+dd if=/dev/zero of=/EMPTY bs=1M || true
+rm -f /EMPTY
+
+sync
+echo 3 > /proc/sys/vm/drop_caches