summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2015-02-24 11:19:10 +0100
committerLeif Johansson <leifj@sunet.se>2015-02-24 11:19:10 +0100
commite2cc0bc80fa8cfab7fecb04677a45a4f51cb561e (patch)
tree09d540d53a1d9fa49fea52d4b1339d7a51846ac4
parentc3415f304e2f11bdbf153bdb8e810e89311fc7a4 (diff)
parent7863ad617033064d6b5758d3d1f4bba32b9cc5dd (diff)
merge multiversesunet-ops-2015-02-24-v01
-rw-r--r--.gitignore1
l---------apt1
-rwxr-xr-xbump-tag2
-rw-r--r--fabfile/__init__.py2
-rwxr-xr-xglobal/overlay/etc/cosmos/apt/bootstrap-cosmos.sh (renamed from apt/bootstrap-cosmos.sh)0
-rw-r--r--global/overlay/etc/cosmos/apt/cosmos_1.2-2_all.deb (renamed from apt/cosmos_1.2-2_all.deb)bin11724 -> 11724 bytes
-rw-r--r--global/overlay/etc/cron.d/cosmos2
-rw-r--r--global/overlay/etc/logrotate.d/docker-containers7
-rw-r--r--global/overlay/etc/puppet/cosmos-modules.conf7
-rw-r--r--global/overlay/etc/puppet/hiera.yaml1
-rw-r--r--global/overlay/etc/puppet/puppet.conf6
-rwxr-xr-xglobal/overlay/usr/local/bin/run-cosmos2
-rwxr-xr-xglobal/overlay/usr/local/sbin/cosmos_vm124
-rwxr-xr-xglobal/post-tasks.d/018packages3
14 files changed, 142 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 7fcdc40..fcdd86a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
\#*
.*~
fabfile/*.pyc
+*.pyc
diff --git a/apt b/apt
new file mode 120000
index 0000000..fb02c87
--- /dev/null
+++ b/apt
@@ -0,0 +1 @@
+global/overlay/etc/cosmos/apt \ No newline at end of file
diff --git a/bump-tag b/bump-tag
index 280f23b..aed35e2 100755
--- a/bump-tag
+++ b/bump-tag
@@ -4,9 +4,7 @@ set -e
test -f cosmos.conf && . ./cosmos.conf
-echo "Fetching any updates from server:"
git pull
-echo ""
deftag=`basename $PWD`
tagpfx=${tag:="$deftag"}
diff --git a/fabfile/__init__.py b/fabfile/__init__.py
index 3933104..8db5748 100644
--- a/fabfile/__init__.py
+++ b/fabfile/__init__.py
@@ -17,7 +17,7 @@ def all():
env.hosts = cosmos_db()['members']['all']
def cosmos():
- run("/usr/local/bin/run-cosmos -v");
+ run("/usr/local/bin/run-cosmos");
def upgrade():
run("apt-get -qq update && apt-get -y -q dist-upgrade");
diff --git a/apt/bootstrap-cosmos.sh b/global/overlay/etc/cosmos/apt/bootstrap-cosmos.sh
index 28cbde0..28cbde0 100755
--- a/apt/bootstrap-cosmos.sh
+++ b/global/overlay/etc/cosmos/apt/bootstrap-cosmos.sh
diff --git a/apt/cosmos_1.2-2_all.deb b/global/overlay/etc/cosmos/apt/cosmos_1.2-2_all.deb
index 9fe4434..9fe4434 100644
--- a/apt/cosmos_1.2-2_all.deb
+++ b/global/overlay/etc/cosmos/apt/cosmos_1.2-2_all.deb
Binary files differ
diff --git a/global/overlay/etc/cron.d/cosmos b/global/overlay/etc/cron.d/cosmos
index 58b45af..2aadd2e 100644
--- a/global/overlay/etc/cron.d/cosmos
+++ b/global/overlay/etc/cron.d/cosmos
@@ -1,4 +1,4 @@
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-*/15 * * * * root test -f /etc/no-automatic-cosmos || scriptherder --mode wrap --syslog --name cosmos -- /usr/local/bin/run-cosmos -v
+*/15 * * * * root test -f /etc/no-automatic-cosmos || scriptherder --mode wrap --syslog --name cosmos -- /usr/local/bin/run-cosmos
diff --git a/global/overlay/etc/logrotate.d/docker-containers b/global/overlay/etc/logrotate.d/docker-containers
new file mode 100644
index 0000000..e9c90b8
--- /dev/null
+++ b/global/overlay/etc/logrotate.d/docker-containers
@@ -0,0 +1,7 @@
+/var/lib/docker/containers/*/*.log {
+ rotate 7
+ daily
+ compress
+ delaycompress
+ copytruncate
+}
diff --git a/global/overlay/etc/puppet/cosmos-modules.conf b/global/overlay/etc/puppet/cosmos-modules.conf
index d3d00d5..80c0216 100644
--- a/global/overlay/etc/puppet/cosmos-modules.conf
+++ b/global/overlay/etc/puppet/cosmos-modules.conf
@@ -1,4 +1,3 @@
-#
# name source (puppetlabs fq name or git url) upgrade (yes/no)
#
concat git://github.com/SUNET/puppetlabs-concat.git yes sunet-*
@@ -8,17 +7,11 @@ ufw git://github.com/SUNET/puppet-module-ufw.git yes sunet-*
apt git://github.com/SUNET/puppetlabs-apt.git no sunet-*
vcsrepo git://github.com/SUNET/puppetlabs-vcsrepo.git no sunet-*
xinetd git://github.com/SUNET/puppetlabs-xinetd.git no sunet-*
-#golang elithrar/golang yes
python git://github.com/SUNET/puppet-python.git yes sunet-*
hiera-gpg git://github.com/SUNET/hiera-gpg.git no sunet-*
-#epel git://github.com/SUNET/puppet-module-epel.git yes sunet-*
-#erlang git://github.com/SUNET/garethr-erlang.git yes sunet-*
-#rabbitmq git://github.com/SUNET/puppetlabs-rabbitmq.git yes sunet-*
pound git://github.com/SUNET/puppet-pound.git yes sunet-*
augeas git://github.com/SUNET/puppet-augeas.git yes sunet-*
bastion git://github.com/SUNET/puppet-bastion.git yes sunet-*
-#wordpress hunner/wordpress no
-#mysql puppetlabs/mysql no
apache puppetlabs/apache no
pyff git://github.com/samlbits/puppet-pyff.git yes puppet-pyff-*
postgresql git://github.com/SUNET/puppetlabs-postgresql.git yes sunet-*
diff --git a/global/overlay/etc/puppet/hiera.yaml b/global/overlay/etc/puppet/hiera.yaml
index 782fa7f..3663305 100644
--- a/global/overlay/etc/puppet/hiera.yaml
+++ b/global/overlay/etc/puppet/hiera.yaml
@@ -8,6 +8,7 @@
:hierarchy:
- "%{env}/%{location}/%{calling_module}"
- "%{env}/%{calling_module}"
+ - local
- secrets.yaml
- common
diff --git a/global/overlay/etc/puppet/puppet.conf b/global/overlay/etc/puppet/puppet.conf
index 64452eb..ec11255 100644
--- a/global/overlay/etc/puppet/puppet.conf
+++ b/global/overlay/etc/puppet/puppet.conf
@@ -8,11 +8,7 @@ rundir=/var/run/puppet
factpath=/etc/puppet/facter
node_terminus = exec
external_nodes = /etc/puppet/cosmos_enc.py
-# We must add /etc/puppet/cosmos-modules to basemodulepath in order for Puppet to find
-# the hiera-gpg backend. If the backend isn't found - *everything* breaks. Puppet 3.7.1.
-basemodulepath = /etc/puppet/cosmos-modules:/etc/puppet/modules:/usr/share/puppet/modules
-#modulepath = /etc/puppet/cosmos-modules:/etc/puppet/modules:/usr/share/puppet/modules
-#config_version = /etc/puppet/cosmos_config_version
+basemodulepath = /etc/puppet/modules:/etc/puppet/cosmos-modules:/usr/share/puppet/modules
[master]
# These are needed when the puppetmaster is run by passenger
diff --git a/global/overlay/usr/local/bin/run-cosmos b/global/overlay/usr/local/bin/run-cosmos
index df104b8..a37d49f 100755
--- a/global/overlay/usr/local/bin/run-cosmos
+++ b/global/overlay/usr/local/bin/run-cosmos
@@ -18,3 +18,5 @@ else
fi
touch /var/run/last-cosmos-ok.stamp
+
+find /var/lib/puppet/reports/ -type f -mtime +10 | xargs rm -f
diff --git a/global/overlay/usr/local/sbin/cosmos_vm b/global/overlay/usr/local/sbin/cosmos_vm
new file mode 100755
index 0000000..bf27576
--- /dev/null
+++ b/global/overlay/usr/local/sbin/cosmos_vm
@@ -0,0 +1,124 @@
+#!/bin/bash
+
+set -- $(getopt h?H:D?s:B:M:C:R:i:g:n:I:G:N: "$@")
+
+src_image=""
+size="1G"
+dhcp="no"
+hostname="default"
+bridge="br0"
+cpus="1"
+mem="1024"
+repo="git://code.mnt.se/mnt-cosmos.git"
+tag="eduid-cosmos"
+ip=""
+gateway=""
+netmask=""
+resolver=""
+ip6=""
+gateway6=""
+netmask6="64"
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ (-h) echo "Usage: $0 [-h] [-H hostname] [-M <memory>] [-C <#cpus>] [-B <bridge>] [-D (dhcp)] [-i/-I <ip4/6>] [-n/-N <mask4/6>] [-g/-G <gw4/6>] [-R <resolver(s)>] [-s <src image>]"; exit 0;;
+ (-H) hostname="$2"; shift;;
+ (-s) src_image="$2"; shift;;
+ (-D) dhcp="yes" ;;
+ (-S) size="$2"; shift;;
+ (-B) bridge="$2"; shift;;
+ (-M) mem="$2"; shift;;
+ (-C) cpus="$2"; shift;;
+ (-R) resolver="$2"; shift;;
+ (-i) ip="$2"; shift;;
+ (-g) gateway="$2"; shift;;
+ (-n) netmask="$2"; shift;;
+ (-I) ip6="$2"; shift;;
+ (-G) gateway6="$2"; shift;;
+ (-N) netmask6="$2"; shift;;
+ (--) shift; break;;
+ (-*) echo "Unknown option $1\nUsage: $0 [-h] [-H hostname] [-M <memory>] [-C <#cpus>] [-B <bridge>] [-D (dhcp)] [-i/-I <ip4/6>] [-n/-N <mask4/6>] [-g/-G <gw4/6>] [-R <resolver(s)>] [-s <src image>]"; exit 1;;
+ (*) break;;
+ esac
+ shift
+done
+
+id=$(uuidgen)
+
+seed=${id}_seed.img
+disk=${id}.img
+
+rm -f ${seed}
+truncate --size 2M ${seed}
+mkfs.vfat -n cidata ${seed} 2>/dev/null
+
+user_data=$(mktemp)
+cat > ${user_data} <<EOF
+#cloud-config
+password: ubuntu
+chpasswd: { expire: False }
+ssh_pwauth: True
+ssh_authorized_keys:
+ - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVvB4gdJ6EWRmx8xUSxrhoUNnWxEf8ZwAqhzC1+7XBY/hSd/cbEotLB9gxgqt0CLW56VU4FPLTw8snD8tgsyZN6KH1Da7UXno8oMk8tJdwLQM0Ggx3aWuztItkDfBc3Lfvq5T07YfphqJO7rcSGbS4QQdflXuOM9JLi6NStVao0ia4aE6Tj68pVVb3++XYvqvbU6NtEICvkTxEY93YpnRSfeAi64hsbaqSTN4kpeltzoSD1Rikz2aQFtFXE03ZC48HtGGhdMFA/Ade6KWBDaXxHGARVQ9/UccfhaR2XSjVxSZ8FBNOzNsH4k9cQIb2ndkEOXZXnjF5ZjdI4ZU0F+t7 leifj+00060AD478D6@sunet.se
+runcmd:
+ - ["mkdir","/tmp/seed"]
+ - ["mount","/dev/vdb","/tmp/seed"]
+ - ["cp","/tmp/seed/bootstrap-cosmos.sh","/tmp/seed/cosmos_1.2-2_all.deb","/root"]
+ - ["cd","/root"]
+ - "cd /root && /root/bootstrap-cosmos.sh ${hostname} ${repo} ${tag}"
+
+EOF
+
+meta_data=$(mktemp)
+cat > ${meta_data} <<EOF
+#cloud-config
+instance-id: iid-${id}
+local-hostname: ${hostname}
+EOF
+
+if [ "x${dhcp}" = "xyes" ]; then
+cat >> ${meta_data} <<EOF
+network-interfaces: |
+ auto eth0
+ iface eth0 inet dhcp
+EOF
+else
+ if [ "x${ip}" != "x" ]; then
+ cat >> ${meta_data} <<EOF
+network-interfaces: |
+ auto eth0
+ iface eth0 inet static
+ address ${ip}
+ netmask ${netmask}
+ gateway ${gateway}
+ dns-nameservers ${resolver}
+
+EOF
+ fi
+
+ if [ "x${ip6}" != "x" ]; then
+ cat >> ${meta_data} <<EOF
+network-interfaces: |
+ auto eth0
+ iface eth0 inet6 static
+ address ${ip6}
+ netmask ${netmask6}
+ gateway ${gateway6}
+ dns-nameservers ${resolver}
+
+EOF
+ fi
+fi
+
+mcopy -i ${seed} ${user_data} ::user-data 2>/dev/null
+mcopy -i ${seed} ${meta_data} ::meta-data 2>/dev/null
+mcopy -i ${seed} /etc/cosmos/apt/bootstrap-cosmos.sh /etc/cosmos/apt/cosmos_1.2-2_all.deb ::
+mv ${seed} /var/lib/libvirt/images/
+virsh pool-refresh default
+
+virsh vol-clone --pool default ${src_image} ${disk}
+
+virt-install -r ${mem} -n ${hostname} --vcpus=${cpus} --autostart --memballoon virtio --network bridge=${bridge} --boot hd --disk vol=default/${disk},format=qcow2,bus=virtio --disk vol=default/${seed},bus=virtio
+
+rm -f ${user_data}
+rm -f ${meta_data}
diff --git a/global/post-tasks.d/018packages b/global/post-tasks.d/018packages
index 5ca5c63..3e2e26e 100755
--- a/global/post-tasks.d/018packages
+++ b/global/post-tasks.d/018packages
@@ -31,6 +31,9 @@ if [ -f $CONFIG ]; then
elif [ -d $CACHE_DIR/scm/$module/.git ]; then
if [ "$update" = "yes" ]; then
cd $CACHE_DIR/scm/$module
+ if [ "$src" != "$(git config remote.origin.url)" ]; then
+ git config remote.origin.url $src
+ fi
git pull -q
else
continue