|
1 | 1 | # Downloading dependencies |
2 | 2 | - name: Postgres dependencies |
3 | | - become: yes |
4 | 3 | apt: |
5 | 4 | pkg: |
6 | 5 | - build-essential |
|
18 | 17 | - ssl-cert |
19 | 18 |
|
20 | 19 | - name: Download LLVM & Clang |
21 | | - become: yes |
22 | 20 | apt: |
23 | 21 | pkg: |
24 | 22 | - llvm-11-dev |
25 | 23 | - clang-11 |
26 | 24 |
|
27 | 25 | - name: Download GCC 10 |
28 | | - become: yes |
29 | 26 | apt: |
30 | 27 | pkg: |
31 | 28 | - gcc-10 |
|
34 | 31 | - name: Switch to GCC 10 |
35 | 32 | shell: |
36 | 33 | cmd: update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 |
37 | | - become: yes |
38 | 34 |
|
39 | 35 | # Building Postgres from source |
40 | 36 | - name: Postgres - download latest release |
|
49 | 45 | remote_src: yes |
50 | 46 | src: /tmp/postgresql-{{ postgresql_release }}.tar.gz |
51 | 47 | dest: /tmp |
52 | | - become: yes |
53 | 48 |
|
54 | 49 | - name: Setting CFLAGS (arm) |
55 | 50 | set_fact: |
|
65 | 60 | shell: |
66 | 61 | cmd: CFLAGS='{{ cflags }} -ggdb -O0 -g -fno-omit-frame-pointer' LLVM_CONFIG=/usr/bin/llvm-config-11 CLANG=/usr/bin/clang-11 ./configure --enable-cassert --enable-debug --with-llvm --with-openssl --with-systemd --with-uuid=e2fs --exec-prefix=/usr/lib/postgresql --datarootdir=/var/lib/postgresql |
67 | 62 | chdir: /tmp/postgresql-{{ postgresql_release }} |
68 | | - become: yes |
69 | 63 |
|
70 | 64 | - name: Postgres - build |
71 | 65 | make: |
72 | 66 | target: world |
73 | 67 | chdir: /tmp/postgresql-{{ postgresql_release }} |
74 | | - become: yes |
75 | 68 |
|
76 | 69 | - name: Postgres - install |
77 | 70 | make: |
78 | 71 | target: install-world |
79 | 72 | chdir: /tmp/postgresql-{{ postgresql_release }} |
80 | | - become: yes |
81 | 73 |
|
82 | 74 | # Create postgres user |
83 | 75 | - name: Create postgres user |
|
87 | 79 | comment: Postgres user |
88 | 80 | groups: ssl-cert |
89 | 81 |
|
90 | | -- name: Recursively change ownership of a directory |
| 82 | +- name: Create relevant directories |
91 | 83 | file: |
92 | | - path: /var/lib/postgresql |
93 | | - state: directory |
| 84 | + path: '{{ item }}' |
94 | 85 | recurse: yes |
| 86 | + state: directory |
95 | 87 | owner: postgres |
96 | 88 | group: postgres |
| 89 | + with_items: |
| 90 | + - '/etc/postgresql' |
| 91 | + - '/etc/postgresql-custom' |
| 92 | + - '/var/log/postgresql' |
| 93 | + - '/var/lib/postgresql' |
97 | 94 |
|
98 | | -# Create /etc/postgresql directory and make sure postgres group owns it |
99 | | -- name: Create a directory if it does not exist |
| 95 | +- name: Allow adminapi to write custom config |
100 | 96 | file: |
101 | | - path: /etc/postgresql |
| 97 | + path: '{{ item }}' |
| 98 | + recurse: yes |
102 | 99 | state: directory |
103 | 100 | owner: postgres |
104 | 101 | group: postgres |
| 102 | + mode: 0664 |
| 103 | + with_items: |
| 104 | + - '/etc/postgresql-custom' |
105 | 105 |
|
106 | | -- name: Create logs dir |
107 | | - become: yes |
| 106 | +- name: create placeholder files |
108 | 107 | file: |
109 | | - path: /var/log/postgresql |
110 | | - state: directory |
| 108 | + path: '/etc/postgresql-custom/{{ item }}' |
| 109 | + state: touch |
111 | 110 | owner: postgres |
112 | 111 | group: postgres |
| 112 | + with_items: |
| 113 | + - 'generated-optimizations.conf' |
| 114 | + - 'custom-overrides.conf' |
113 | 115 |
|
114 | 116 | # Move Postgres configuration files into /etc/postgresql |
115 | 117 | # Add postgresql.conf |
|
144 | 146 | # Circumvents the following error: |
145 | 147 | # "Timeout (12s) waiting for privilege escalation prompt" |
146 | 148 |
|
147 | | -# Add systemd file for Postgres |
148 | | -- name: import postgresql.service |
| 149 | +- name: copy PG systemd unit |
149 | 150 | template: |
150 | 151 | src: files/postgresql_config/postgresql.service.j2 |
151 | 152 | dest: /etc/systemd/system/postgresql.service |
152 | | - become: yes |
| 153 | + |
| 154 | +- name: copy optimizations systemd unit |
| 155 | + template: |
| 156 | + src: files/generate-optimizations.service.j2 |
| 157 | + dest: /etc/systemd/system/generate-optimizations.service |
153 | 158 |
|
154 | 159 | # Reload |
155 | 160 | - name: System - systemd reload |
|
0 commit comments