Update ubuntu scripts
* Use mirrors proto for upstream repos
* Fix and extend motd
- motd was in wrong format(base.sh)
that propagate error messages at boot
* make template json-pretty
Change-Id: I71f41240fa987ff11a605cc9237e4482794053cd
diff --git a/ubuntu-14.04/scripts/base.sh b/ubuntu-14.04/scripts/base.sh
index 073409f..1792f2a 100644
--- a/ubuntu-14.04/scripts/base.sh
+++ b/ubuntu-14.04/scripts/base.sh
@@ -2,17 +2,26 @@
export DEBIAN_FRONTEND=noninteractive
echo "exit 101" > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
-apt-get clean
-apt-get update
-# Useful tools
-apt-get -y install curl wget tmux vim-nox byobu iputils-ping traceroute htop tree lsof
+# Overwrite default mirrors
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty main restricted multiverse universe" > /etc/apt/sources.list
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-updates main restricted multiverse universe" >> /etc/apt/sources.list
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-security main restricted multiverse universe" >> /etc/apt/sources.list
+echo "deb mirror://mirrors.ubuntu.com/mirrors.txt trusty-backports main restricted multiverse universe" >> /etc/apt/sources.list
# Add apt-mk repository
echo "deb [arch=amd64] http://apt-mk.mirantis.com/trusty/ nightly salt" > /etc/apt/sources.list.d/mcp_salt.list
echo "deb [arch=amd64] http://apt-mk.mirantis.com/trusty/ nightly extra" > /etc/apt/sources.list.d/mcp_extra.list
curl -sf http://apt-mk.mirantis.com/public.gpg | apt-key add -
+apt-get clean
+apt-get update
+
+# Useful tools
+apt-get -y install byobu curl ethtool htop iputils-ping lsof strace tcpdump tmux traceroute tree vim-nox wget
+# Install common prerequisites
+apt-get -y install apt-transport-https libmnl0 python-apt python-m2crypto python-psutil
+
# Cleanup old kernels, ensure latest is installed via virtual package
apt-get purge -y linux-image-* linux-headers-*
if [ ! -f /tmp/no_install_kernel ]; then
@@ -43,11 +52,17 @@
apt-get -y install cloud-init
# Motd
-apt-get install -y update-motd
-rm -f /etc/update-motd.d/*
-cat << EOF >> /etc/update-motd.d/52-info
-Ubuntu 14.04 "Trusty" Mirantis cloud image
-Build date: $(date -u -R)
-
+apt-get -y install update-motd
+rm -vf /etc/update-motd.d/*
+echo "BUILD_TIMESTAMP=$(date '+%Y-%m-%d-%H-%M-%S' -u)" > /etc/image_version
+echo "BUILD_TIMESTAMP_RFC=\"$(date -u -R)\"" >> /etc/image_version
+cat << 'EOF' >> /etc/update-motd.d/00-header-mirantis
+#!/bin/sh
+#
+# 00-header - create the header of the MOTD
+#
+[ -r /etc/image_version ] && . /etc/image_version
+echo "Ubuntu 14.04 \"Trusty\" Mirantis cloud image"
+echo "Build date: ${BUILD_TIMESTAMP_RFC}"
EOF
-chmod +x /etc/update-motd.d/52-info
+chmod +x /etc/update-motd.d/00-header-mirantis
diff --git a/ubuntu-14.04/template.json b/ubuntu-14.04/template.json
index f8fcf6a..13d878c 100644
--- a/ubuntu-14.04/template.json
+++ b/ubuntu-14.04/template.json
@@ -1,12 +1,11 @@
{
- "variables": {
- "user": "root",
- "password": "ho5uo7Uome5d",
- "do_api_token": "{{ env `DO_API_TOKEN` }}",
- "distro": "ubuntu-14-04-x64",
- "disk_size": "8000"
- },
-
+ "variables": {
+ "user": "root",
+ "password": "ho5uo7Uome5d",
+ "do_api_token": "{{ env `DO_API_TOKEN` }}",
+ "distro": "ubuntu-14-04-x64",
+ "disk_size": "8000"
+ },
"provisioners": [
{
"type": "shell",
@@ -15,7 +14,7 @@
"virtualbox-iso": {
"scripts": [
"scripts/base.sh",
- "scripts/salt.sh",
+ "scripts/salt.sh",
"scripts/vagrant.sh",
"scripts/virtualbox.sh",
"scripts/security.sh",
@@ -33,31 +32,31 @@
"scripts/zerodisk.sh"
]
},
- "qemu": {
+ "qemu": {
"scripts": [
"scripts/base.sh",
- "scripts/salt.sh",
+ "scripts/salt.sh",
"scripts/security.sh",
"scripts/cleanup.sh",
"scripts/zerodisk.sh"
]
- },
- "docker": {
+ },
+ "docker": {
"scripts": [
"scripts/docker.sh",
"scripts/base.sh",
- "scripts/salt.sh",
+ "scripts/salt.sh",
"scripts/cleanup.sh"
]
- },
- "digitalocean": {
- "scripts": [
- "scripts/base.sh",
- "scripts/salt.sh",
+ },
+ "digitalocean": {
+ "scripts": [
+ "scripts/base.sh",
+ "scripts/salt.sh",
"scripts/security.sh",
- "scripts/cleanup.sh"
- ]
- }
+ "scripts/cleanup.sh"
+ ]
+ }
}
},
{
@@ -76,18 +75,25 @@
"type": "vagrant",
"keep_input_artifact": true,
"output": "images/{{ user `distro` }}-{{.Provider}}-{{ isotime \"200601021504\" }}.box",
- "except": [ "digitalocean", "docker" ]
+ "except": [
+ "digitalocean",
+ "docker"
+ ]
},
{
"type": "docker-tag",
"repository": "tcpcloud/ubuntu",
"tag": "14.04",
- "only": ["docker"]
+ "only": [
+ "docker"
+ ]
},
{
"type": "docker-save",
"path": "images/{{ user `distro` }}-docker-{{ isotime \"200601021504\" }}.tar",
- "only": ["docker"]
+ "only": [
+ "docker"
+ ]
}
],
"builders": [
@@ -134,11 +140,36 @@
"shutdown_command": "shutdown -P now",
"headless": true,
"vboxmanage": [
- [ "modifyvm", "{{.Name}}", "--memory", "1024" ],
- [ "modifyvm", "{{.Name}}", "--cpus", "2" ],
- [ "modifyvm", "{{.Name}}", "--vrde", "on" ],
- [ "modifyvm", "{{.Name}}", "--vrdeport", "5000-5050" ],
- [ "modifyvm", "{{.Name}}", "--vrdeaddress", "127.0.0.1" ]
+ [
+ "modifyvm",
+ "{{.Name}}",
+ "--memory",
+ "1024"
+ ],
+ [
+ "modifyvm",
+ "{{.Name}}",
+ "--cpus",
+ "2"
+ ],
+ [
+ "modifyvm",
+ "{{.Name}}",
+ "--vrde",
+ "on"
+ ],
+ [
+ "modifyvm",
+ "{{.Name}}",
+ "--vrdeport",
+ "5000-5050"
+ ],
+ [
+ "modifyvm",
+ "{{.Name}}",
+ "--vrdeaddress",
+ "127.0.0.1"
+ ]
]
},
{
@@ -193,7 +224,10 @@
{
"type": "qemu",
"qemuargs": [
- [ "-m", "1024M" ]
+ [
+ "-m",
+ "1024M"
+ ]
],
"vm_name": "{{ user `distro` }}-{{ isotime \"200601021504\" }}",
"output_directory": "images/{{ user `distro` }}-qemu-{{ isotime \"200601021504\" }}",
@@ -235,8 +269,8 @@
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
" -- <wait>",
"<enter><wait>"
- ]
- },
+ ]
+ },
{
"type": "docker",
"image": "ubuntu:14.04",
@@ -247,8 +281,8 @@
"api_token": "{{user `do_api_token`}}",
"image": "{{user `distro`}}",
"snapshot_name": "{{ user `distro` }}-{{ isotime \"200601021504\" }}",
- "region" : "ams2",
- "size" : "1gb"
+ "region": "ams2",
+ "size": "1gb"
}
]
-}
+}
\ No newline at end of file