aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2014-08-23 17:31:41 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2014-08-23 17:31:41 +0200
commit5b1cc7e49adeb7c6060f04fda0a667e3e17809ab (patch)
tree0d686367329a97992f9a80d9a960c75890d1e68a
downloadfiken-ansible-5b1cc7e49adeb7c6060f04fda0a667e3e17809ab.tar.gz
fiken-ansible-5b1cc7e49adeb7c6060f04fda0a667e3e17809ab.tar.bz2
fiken-ansible-5b1cc7e49adeb7c6060f04fda0a667e3e17809ab.tar.xz
fiken-ansible-5b1cc7e49adeb7c6060f04fda0a667e3e17809ab.zip
wip
-rwxr-xr-xansible2
-rwxr-xr-xansible-playbook4
-rw-r--r--files/bin/fiken-dump-database40
-rw-r--r--files/bin/install-release13
-rw-r--r--files/bin/pull-and-release20
-rw-r--r--hosts5
-rw-r--r--playbook.yml16
-rw-r--r--vars.yml0
8 files changed, 100 insertions, 0 deletions
diff --git a/ansible b/ansible
new file mode 100755
index 0000000..4cb7f79
--- /dev/null
+++ b/ansible
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec ansible -i hosts "$@"
diff --git a/ansible-playbook b/ansible-playbook
new file mode 100755
index 0000000..f15757a
--- /dev/null
+++ b/ansible-playbook
@@ -0,0 +1,4 @@
+#!/bin/bash
+# Run with:
+# ./ansible -K --limit production provision.yml
+exec ansible-playbook -i hosts "$@"
diff --git a/files/bin/fiken-dump-database b/files/bin/fiken-dump-database
new file mode 100644
index 0000000..eb962d7
--- /dev/null
+++ b/files/bin/fiken-dump-database
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+export BUP_DIR=$HOME/bups/postgres-backup
+
+now=`date -u +%Y-%m-%dT%H:%M:%S.000Z`
+
+db="$1"
+
+if [[ -z $db ]]
+then
+ echo "usage: $0 <database>"
+ exit 1
+fi
+
+dir="$HOME/backups/${db}"
+name="pg_${db}_${now}.backup"
+path="$dir/$name"
+
+mkdir -p "$dir"
+
+echo "Dumping $db to $path"
+
+time pg_dump -h localhost -U fiken-prod -b -Fc $db > $path
+rm -rf "$dir/latest"
+ln -s "$name" "$dir/latest"
+
+echo "Updating backups"
+(
+cd "$dir"
+bup index -u .
+bup save -n postgres-backup .
+)
+
+echo "Dump complete"
+echo "File size:" `ls -sh $path|cut -f 1 -d " "`
+echo ""
+echo "To restore to a db:"
+echo "psql -1 -h localhost -U fiken-dev -d fiken-dev -c 'drop schema public CASCADE; create schema public'"
+echo "vacuumlo -U fiken-dev -h localhost -v -l 10000 fiken-dev"
+echo "pg_restore -O -U fiken-dev -h localhost -d fiken-dev" $name
diff --git a/files/bin/install-release b/files/bin/install-release
new file mode 100644
index 0000000..4b94bc0
--- /dev/null
+++ b/files/bin/install-release
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e
+set -x
+
+env=`app conf get env.FIKEN_ENVIRONMENT`
+props="current/etc/$env/environment.properties"
+password=`sed -n 's,^database.password=\(.*\),\1,p' $props`
+
+app conf set app.version $1
+app upgrade
+sed 's,^\(database.password\)=.*,\1=$password,' $props > x
+mv x $props
+echo "Type app restart when ready to start new version."
diff --git a/files/bin/pull-and-release b/files/bin/pull-and-release
new file mode 100644
index 0000000..3d18437
--- /dev/null
+++ b/files/bin/pull-and-release
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -e
+set -x
+
+git fetch
+
+now=$(date +%Y.%m)
+count=$(git tag|grep -- -$now.|wc -l)
+
+echo "Does $now.$count look like a good release version? If not, abort now."
+read
+
+git reset --hard
+git checkout master
+git merge --ff origin/master
+git merge --no-ff origin/develop
+
+git push origin master
+
+mvn clean release:clean release:prepare release:perform -B -Papp -DdevelopmentVersion=master-SNAPSHOT -DreleaseVersion=$now.$count
diff --git a/hosts b/hosts
new file mode 100644
index 0000000..c4b8021
--- /dev/null
+++ b/hosts
@@ -0,0 +1,5 @@
+[prod]
+kanel.fiken.no
+
+[arb]
+vs.trygvis.io
diff --git a/playbook.yml b/playbook.yml
new file mode 100644
index 0000000..2db2c68
--- /dev/null
+++ b/playbook.yml
@@ -0,0 +1,16 @@
+---
+- hosts: arb
+ vars_files:
+ - vars.yml
+ gather_facts: false
+ sudo: yes
+
+ tasks:
+ - group: name=fiken
+ - user: name=fiken comment="Topi Fiken" group=fiken home=/opt/fiken shell=/bin/bash
+ - file: dest=/opt/fiken/bin state=directory owner=fiken
+ - file: dest=/opt/fiken/opt state=directory owner=fiken
+ - git: repo=git://github.com/trygvis/appmgr
+ dest=/opt/fiken/opt/appmgr
+ accept_hostkey=true
+ - copy: src=files/bin/ dest=/opt/fiken/bin force=yes
diff --git a/vars.yml b/vars.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vars.yml