|
| 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 | + |