Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ec9e963

Browse files
committed
import role
1 parent ab09371 commit ec9e963

File tree

6 files changed

+197
-0
lines changed

6 files changed

+197
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Role Name
2+
=========
3+
4+
A brief description of the role goes here.
5+
6+
Requirements
7+
------------
8+
9+
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10+
11+
Role Variables
12+
--------------
13+
14+
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15+
16+
Dependencies
17+
------------
18+
19+
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20+
21+
Example Playbook
22+
----------------
23+
24+
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25+
26+
- hosts: servers
27+
roles:
28+
- { role: username.rolename, x: 42 }
29+
30+
License
31+
-------
32+
33+
BSD
34+
35+
Author Information
36+
------------------
37+
38+
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# defaults file for ansible-postgres
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# handlers file for ansible-postgres
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
galaxy_info:
3+
author: Stas Kelvich
4+
description: Role to build and install postgres from sources
5+
company: PostgresPro
6+
license: MIT
7+
min_ansible_version: 1.9
8+
platforms:
9+
- name: Debian
10+
versions:
11+
- all
12+
- name: CentOS
13+
versions:
14+
- all
15+
galaxy_tags:
16+
- postgres
17+
- installer
18+
- db
19+
20+
dependencies: []
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# vim: ts=2 sts=2 sw=2 expandtab
2+
---
3+
4+
- name: ensure dependencies (Debian)
5+
apt: pkg={{item}} state=installed
6+
with_items:
7+
- git
8+
- automake
9+
- libtool
10+
- build-essential
11+
- bison
12+
- flex
13+
- libreadline-dev
14+
when: ansible_os_family == "Debian"
15+
become: yes
16+
17+
- name: ensure dependencies (RedHat)
18+
yum: name="@Development tools" state=present
19+
when: ansible_os_family == "RedHat"
20+
become: yes
21+
22+
- name: ensure dependencies (RedHat)
23+
yum: name={{item}} state=installed
24+
with_items:
25+
- git
26+
- automake
27+
- libtool
28+
- bison
29+
- flex
30+
- readline-devel
31+
when: ansible_os_family == "RedHat"
32+
become: yes
33+
34+
- name: increase semaphores
35+
sysctl: name=kernel.sem value="1000 128000 128 512"
36+
become: yes
37+
38+
- name: increase open files
39+
lineinfile:
40+
dest: /etc/security/limits.d/cluster.conf
41+
line: "{{ansible_ssh_user}} soft nofile 65535"
42+
state: present
43+
create: yes
44+
become: yes
45+
46+
#############################################################################
47+
48+
- name: clone postgres sources
49+
git: repo={{pg_repo}}
50+
dest={{pg_src}}
51+
version={{pg_version_tag}}
52+
depth=1
53+
accept_hostkey=True
54+
key_file={{pg_repo_key}}
55+
register: pg_sources
56+
57+
# XXX: Consider using file module with state=absent rather than running rm
58+
- name: force rebuild on changed sources
59+
#command: "rm -f {{pg_dst}}/bin/postgres"
60+
file: path="{{pg_dst}}/bin/postgres" state=absent
61+
when: pg_sources.changed
62+
63+
- name: build and install
64+
shell: env CFLAGS="-O0" ./configure --prefix={{pg_dst}} --enable-debug --without-zlib && make clean && make -j {{makejobs}} && make install
65+
args:
66+
chdir: "{{pg_src}}"
67+
creates: "{{pg_dst}}/bin/postgres"
68+
69+
#############################################################################
70+
71+
- name: stop postgres if it was running
72+
shell: "pkill -9 postgres || true"
73+
when: pg_destroy_and_init
74+
75+
- name: remove datadirs
76+
#command: "rm -rf {{pg_datadir}}"
77+
file: path="{{pg_datadir}}" state=absent
78+
when: pg_destroy_and_init
79+
80+
- name: create datadirs
81+
command: "{{pg_dst}}/bin/initdb {{pg_datadir}}"
82+
environment:
83+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
84+
args:
85+
creates: "{{pg_datadir}}"
86+
when: pg_destroy_and_init
87+
88+
- name: configure postgres on datanodes
89+
lineinfile:
90+
dest: "{{pg_datadir}}/postgresql.conf"
91+
line: "{{item.line}}"
92+
state: present
93+
with_items: "{{pg_config}}"
94+
when: pg_destroy_and_init
95+
96+
- name: enable blind trust on datanodes
97+
lineinfile:
98+
dest: "{{pg_datadir}}/pg_hba.conf"
99+
line: "{{item}}"
100+
state: present
101+
with_items:
102+
- "host all all 0.0.0.0/0 trust"
103+
- "host replication all 0.0.0.0/0 trust"
104+
- "local replication all trust"
105+
when: pg_destroy_and_init
106+
107+
- name: start postgrespro
108+
shell: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
109+
environment:
110+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
111+
when: pg_destroy_and_init
112+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# vim: ts=2 sts=2 sw=2 expandtab
2+
---
3+
makejobs: 4
4+
5+
pg_repo: git://git.postgresql.org/git/postgresql.git
6+
pg_repo_key: None
7+
pg_version_tag: master
8+
9+
pg_destroy_and_init: false
10+
11+
pg_port: 5432
12+
pg_config:
13+
- line: "synchronous_commit = off"
14+
- line: "listen_addresses = '*'"
15+
- line: "max_connections = 100"
16+
- line: "max_prepared_transactions = 100"
17+
- line: "port = {{pg_port}}"
18+
19+
pg_prefix: "{{ansible_env.HOME}}/pg_cluster"
20+
pg_src: "{{pg_prefix}}/src"
21+
pg_dst: "{{pg_prefix}}/install"
22+
pg_datadir: "{{pg_prefix}}/data_{{pg_port}}"
23+

0 commit comments

Comments
 (0)