Skip to content

Instantly share code, notes, and snippets.

@blissdev
Created August 25, 2013 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save blissdev/6331129 to your computer and use it in GitHub Desktop.
Save blissdev/6331129 to your computer and use it in GitHub Desktop.
postgres 9.3rc1 + extensions
---
- hosts: vagrant
vars:
pgversion: 9.3rc1
pgpath: /usr/local/pgsql
#postgres: http://ftp.postgresql.org/pub/source/v9.3rc1/postgresql-9.3rc1.tar.gz
tasks:
- name: update apt
apt: update_cache=yes
sudo: yes
- name: install dependencies
apt: pkg=$item state=installed
sudo: yes
with_items:
- build-essential
- subversion
- git
- vim
- libreadline-dev
- zlib1g-dev
- flex
- bison
- libxml2-dev
- libxslt1-dev
- libssl-dev
- name: download postgres
get_url: dest=/home/vagrant/postgresql-{{pgversion}}.tar.gz
url=http://ftp.postgresql.org/pub/source/v{{pgversion}}/postgresql-{{pgversion}}.tar.gz
- name: decompress postgres source
command: tar xzf postgresql-{{pgversion}}.tar.gz
- name: install postgres
shell: cd postgresql-{{pgversion}} && ./configure && make && sudo make install && touch .ansible-make.lock
creates=/home/vagrant/postgresql-{{pgversion}}/.ansible-make.lock
- name: create postgres user
user: name=postgres state=present
sudo: yes
# for some reason can't do them in the same task
- name: create postgres log directory
sudo: yes
file: state=directory path=/usr/local/pgsql/logs group=postgres owner=postgres
- name: create postgres data directory
sudo: yes
file: state=directory path=/usr/local/pgsql/data group=postgres owner=postgres
- name: update postgres user path with postgres
shell: echo PATH=/usr/local/bin:$PATH >> ~/.bashrc
sudo: yes
sudo_user: postgres
- name: update default user with postgres
shell: echo PATH=/usr/local/pgsql/bin:$PATH >> ~/.bashrc
- name: initdb
command: /usr/local/pgsql/bin/initdb --locale=en_US.UTF-8 --encoding=UNICODE -D {{pgpath}}/data
creates={{pgpath}}/data/PG_VERSION
sudo: yes
sudo_user: postgres
- name: update postgres connection configuration
copy: src=files/pg_hba.conf dest=/usr/local/pgsql/data/pg_hba.conf backup=yes
sudo: yes
sudo_user: postgres
- name: update postgres configuration
copy: src=files/postgresql.conf dest=/usr/local/pgsql/data/postgresql.conf backup=yes
sudo: yes
sudo_user: postgres
- name: start postgres
shell: "{{pgpath}}/bin/pg_ctl -D {{pgpath}}/data -l {{pgpath}}/logs/pgsql.log start"
sudo: yes
sudo_user: postgres
# / of postgres install
- name: get v8
subversion: repo=http://v8.googlecode.com/svn/branches/3.16/ dest=/home/vagrant/v8
- name: install v8
shell: make dependencies && make native library=shared
chdir=/home/vagrant/v8
creates=/home/vagrant/v8/out/native/lib.target/libv8.so
- name: copy so
shell: cp /home/vagrant/v8/out/native/lib.target/libv8.so /usr/lib
creates=/usr/lib/libv8.so
sudo: yes
- name: get plv8js
git: repo=https://code.google.com/p/plv8js/ dest=/home/vagrant/plv8js
- name: install plv8js
shell: make V8_SRCDIR=../v8/ PG_CONFIG={{pgpath}}/bin/pg_config && sudo make install PG_CONFIG={{pgpath}}/bin/pg_config
chdir=/home/vagrant/plv8js
creates={{pgpath}}/lib/plv8.so
- name: instantiate plv8
shell: "{{pgpath}}/bin/psql -d template1 -c \"CREATE EXTENSION plv8;\""
sudo: yes
sudo_user: postgres
# / of plv8 install
- name: install pgcrypto
shell: make && sudo make install
chdir=/home/vagrant/postgresql-{{pgversion}}/contrib/pgcrypto
creates={{pgpath}}/lib/pgcrypto.so
- name: instantiate pgcrypto
shell: "{{pgpath}}/bin/psql -d template1 -c \"CREATE EXTENSION pgcrypto;\""
sudo: yes
sudo_user: postgres
# / of pgcrypto install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment