|
| 1 | +--- |
| 2 | + |
| 3 | +-name:ensure dependencies (Debian) |
| 4 | +apt:pkg={{item}} state=installed |
| 5 | +with_items: |
| 6 | + -git |
| 7 | + -automake |
| 8 | + -libtool |
| 9 | + -build-essential |
| 10 | + -bison |
| 11 | + -flex |
| 12 | + -libreadline-dev |
| 13 | +when:ansible_os_family == "Debian" |
| 14 | +sudo:yes |
| 15 | + |
| 16 | +-name:ensure dependencies (RedHat) |
| 17 | +yum:name="@Development tools" state=present |
| 18 | +when:(pg_copydist is undefined) and ansible_os_family == "RedHat" |
| 19 | +sudo:yes |
| 20 | + |
| 21 | +-name:ensure dependencies (RedHat) |
| 22 | +yum:name={{item}} state=installed |
| 23 | +with_items: |
| 24 | + -git |
| 25 | + -automake |
| 26 | + -libtool |
| 27 | + -bison |
| 28 | + -flex |
| 29 | + -readline-devel |
| 30 | +when:(pg_copydist is undefined) and ansible_os_family == "RedHat" |
| 31 | +sudo:yes |
| 32 | + |
| 33 | +-name:increase semaphores |
| 34 | +shell:sysctl kernel.sem='1000 128000 128 512' |
| 35 | +sudo:yes |
| 36 | + |
| 37 | +-name:increase open files |
| 38 | +shell:"echo '{{ansible_ssh_user}} soft nofile 65535' > /etc/security/limits.d/cluster.conf" |
| 39 | +args: |
| 40 | +creates:"/etc/security/limits.d/cluster.conf" |
| 41 | +sudo:yes |
| 42 | + |
| 43 | +############################################################################# |
| 44 | + |
| 45 | +-name:clone postgres sources |
| 46 | +git:repo={{pg_repo}} |
| 47 | +dest={{pg_src}} |
| 48 | +version={{pg_version_tag}} |
| 49 | +depth=1 |
| 50 | +accept_hostkey=True |
| 51 | +register:pg_sources |
| 52 | +when:pg_copydist is undefined |
| 53 | + |
| 54 | +-name:force rebuild on changed sources |
| 55 | +command:"rm -f {{pg_dst}}/bin/postgres" |
| 56 | +when:(pg_copydist is undefined) and pg_sources.changed |
| 57 | + |
| 58 | +-name:build and install |
| 59 | +shell:./configure --prefix={{pg_dst}} --without-zlib && make clean && make -j {{makejobs}} && make install |
| 60 | +args: |
| 61 | +chdir:"{{pg_src}}" |
| 62 | +creates:"{{pg_dst}}/bin/postgres" |
| 63 | +when:pg_copydist is undefined |
| 64 | + |
| 65 | +############################################################################# |
| 66 | + |
| 67 | +-name:copy pg source |
| 68 | +copy:src=./{{item}} dest=~/{{item}} mode=0755 |
| 69 | +with_items: |
| 70 | + -"pg_cluster_install.tgz" |
| 71 | +when:pg_copydist is defined |
| 72 | + |
| 73 | +-name:extract postgres |
| 74 | +command:"tar xzf pg_cluster_install.tgz" |
| 75 | +when:pg_copydist is defined |
| 76 | + |
| 77 | +############################################################################# |
| 78 | + |
| 79 | +-stat:path={{pg_datadir}}/postmaster.pid |
| 80 | +register:pg_pidfile |
| 81 | + |
| 82 | +# - name: stop postgres if it was running |
| 83 | +# command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}" |
| 84 | +# environment: |
| 85 | +# LD_LIBRARY_PATH: "{{pg_dst}}/lib" |
| 86 | +# when: pg_pidfile.stat.exists |
| 87 | + |
| 88 | +-name:stop postgres if it was running |
| 89 | +shell:"kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid`" |
| 90 | +environment: |
| 91 | +LD_LIBRARY_PATH:"{{pg_dst}}/lib" |
| 92 | +when:pg_pidfile.stat.exists |
| 93 | + |
| 94 | +-name:remove datadirs on datanodes |
| 95 | +command:"rm -rf {{pg_datadir}}" |
| 96 | +when:pg_destroy_and_init |
| 97 | + |
| 98 | +-name:create datadirs on datanodes |
| 99 | +command:"{{pg_dst}}/bin/initdb {{pg_datadir}}" |
| 100 | +environment: |
| 101 | +LD_LIBRARY_PATH:"{{pg_dst}}/lib/" |
| 102 | +args: |
| 103 | +creates:"{{pg_datadir}}" |
| 104 | + |
| 105 | +-name:configure postgres on datanodes |
| 106 | +lineinfile: |
| 107 | +dest:"{{pg_datadir}}/postgresql.conf" |
| 108 | +line:"{{item.line}}" |
| 109 | +state:present |
| 110 | +with_items:"{{pg_config}}" |
| 111 | + |
| 112 | +-name:configure postgres on datanodes -- 2 |
| 113 | +lineinfile: |
| 114 | +dest:"{{pg_datadir}}/postgresql.conf" |
| 115 | +line:"{{item.line}}" |
| 116 | +state:present |
| 117 | +with_items:"{{pg_config_role}}" |
| 118 | + |
| 119 | +-name:enable blind trust on datanodes |
| 120 | +lineinfile: |
| 121 | +dest:"{{pg_datadir}}/pg_hba.conf" |
| 122 | +line:"host all all 0.0.0.0/0 trust" |
| 123 | + |
| 124 | +-name:start postgrespro |
| 125 | +shell:"{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log" |
| 126 | +environment: |
| 127 | +LD_LIBRARY_PATH:"{{pg_dst}}/lib/" |
| 128 | + |