Skip to content

Commit

Permalink
Merge branch 'release/0.4.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
KayEss committed Nov 11, 2013
2 parents 26cb2de + 875839d commit 9e80019
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,3 +1,6 @@
2013-06-19 Kirit Saelensminde <kirit@felspar.com>
Factor out the Postgres role adding so other roles can be easily added.

2013-01-04 Kirit Saelensminde <kirit@felspar.com>
Fix the devenv script so that the profab paths are always first.
Handle the new format for the AMI web page so we can find the right ones.
Expand Down
6 changes: 3 additions & 3 deletions README.markdown
Expand Up @@ -78,7 +78,7 @@ If multiple roles set an AMI, instance size or region then the last one that doe

Allows the AMI that is to be launched to be controlled. The AMI must be available in the region requested.

ami.ubuntu release
--ami.ubuntu release

Will choose the current AMI based on the named or numbered release. Only those releases listed at http://uec-images.ubuntu.com/releases/ are available, and only those that have actually been released (pre-release versions won't work -- you'll need to specify the full AMI yourself).

Expand All @@ -94,7 +94,7 @@ Instances are chosen from http://uec-images.ubuntu.com/releases/10.04/release/

This is deprecated.

Will choose an Ubuntu Lucid (10.04) AMI. This is the default AMI if no other one is chosen.
Will choose an Ubuntu Precise (12.04) AMI. This is the default AMI if no other one is chosen.

Instances are chosen from http://uec-images.ubuntu.com/releases/12.04/release/

Expand All @@ -106,7 +106,7 @@ Automatically determines the number of bits that are to be used for a new server

--bits 32|64

Set the number of bits. profab will determine the correct number of bits for all current instance sizes automatically. You will need to use `--bits 64` to run a micro instance using a 64 bit operating system as profab will default to 32 bits.
Set the number of bits. profab will determine the correct number of bits for all current instance sizes automatically. You will need to use `--bits 64` to run smaller instance sizes using a 64 bit operating system as profab will default to 32 bits.

## eip ##

Expand Down
21 changes: 16 additions & 5 deletions profab/role/postgres.py
Expand Up @@ -12,21 +12,32 @@ class AddRole(Role):
packages = ['postgresql']


@classmethod
def ident_user(cls, _server, username):
"""Make sure that the specified user name ihas a Postgres role
and user database.
"""
pguser = \
run('''psql -x -c "select * from pg_user where usename='%s'"'''
% username)
if 'No rows' in pguser:
run('createuser -l -S -D -I -R %s' % username)
run('createdb -O %s -E UTF-8 %s' % (username, username))


def configure(self, server):
"""Configure Postgres once it is running.
"""
# The first user needs to be created using sudo
pguser = sudo('''psql -x -c "select * from pg_user '''
'''where usename='ubuntu'"''', user='postgres')
if 'No rows' in pguser:
sudo('psql -c "create role ubuntu login superuser"',
user='postgres')
sudo('psql -c "create database ubuntu with owner=ubuntu"',
user='postgres')
pguser = run('''psql -x -c "select * from pg_user where '''
'''usename='www-data'"''')
if 'No rows' in pguser:
run('createuser -l -S -D -I -R www-data')
run('createdb -O www-data -E UTF-8 www-data')
# Other users can be created generically
self.ident_user(server, 'www-data')

postgres_path = self.get_configuration_path('/etc/postgresql')
sed('%s/main/pg_hba.conf' % postgres_path,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -10,7 +10,7 @@ def read(fname1, fname2):

setup(
name = "profab",
version = "0.4.8",
version = "0.4.9",
author = "Proteus Technologies Infrastructure team",
author_email = "infrastructure@proteus-tech.com",
url = 'https://github.com/Proteus-tech/profab',
Expand Down

0 comments on commit 9e80019

Please sign in to comment.