taperole 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +7 -0
- data/CHANGELOG.md +12 -0
- data/README.md +7 -16
- data/config/style_guides/ruby.yml +238 -0
- data/lib/tape/ansible_runner.rb +41 -33
- data/lib/tape/installer.rb +56 -28
- data/lib/tape.rb +8 -0
- data/requirements.yml +5 -2
- data/roles/backend_install_essentials/meta/main.yml +1 -1
- data/roles/database_load/tasks/db_reset.yml +3 -3
- data/roles/deployer_user/tasks/keys.yml +3 -2
- data/roles/frontend_deploy/tasks/main.yml +5 -1
- data/roles/frontend_install_essentials/meta/main.yml +3 -0
- data/roles/general/meta/main.yml +2 -0
- data/roles/general/tasks/basic_packages.yml +3 -0
- data/roles/general/tasks/main.yml +11 -1
- data/roles/nginx/tasks/main.yml +6 -2
- data/taperole.gemspec +1 -1
- data/templates/base/hosts.example +1 -1
- data/templates/base/tape_vars.example.yml +0 -3
- data/templates/static_html/tape_vars.example.yml +0 -3
- data/vars/defaults.yml +5 -0
- data/vendor/ANXS.postgresql/.travis.yml +11 -6
- data/vendor/ANXS.postgresql/README.md +5 -1
- data/vendor/ANXS.postgresql/Vagrantfile +1 -1
- data/vendor/ANXS.postgresql/defaults/main.yml +35 -1
- data/vendor/ANXS.postgresql/meta/.galaxy_install_info +1 -1
- data/vendor/ANXS.postgresql/tasks/configure.yml +34 -3
- data/vendor/ANXS.postgresql/tasks/databases.yml +13 -0
- data/vendor/ANXS.postgresql/tasks/install.yml +22 -0
- data/vendor/ANXS.postgresql/tasks/users_privileges.yml +4 -4
- data/vendor/ANXS.postgresql/templates/etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2 +5 -0
- data/vendor/ANXS.postgresql/templates/postgresql.conf-9.3.j2 +596 -0
- data/vendor/ANXS.postgresql/templates/postgresql.conf-9.4.j2 +614 -0
- data/vendor/ANXS.postgresql/vagrant-inventory +1 -1
- data/vendor/bennojoy.memcached/meta/.galaxy_install_info +1 -1
- data/vendor/jnv.mosh/LICENSE +24 -0
- data/vendor/jnv.mosh/README.md +56 -0
- data/vendor/jnv.mosh/meta/.galaxy_install_info +1 -0
- data/vendor/jnv.mosh/meta/main.yml +96 -0
- data/vendor/jnv.mosh/tasks/main.yml +20 -0
- data/vendor/jnv.mosh/vars/main.yml +4 -0
- data/vendor/jnv.unattended-upgrades/meta/.galaxy_install_info +1 -1
- data/vendor/lxhunter.apt/.gitignore +1 -0
- data/vendor/lxhunter.apt/.kitchen.yml +67 -0
- data/vendor/lxhunter.apt/README.md +33 -25
- data/vendor/lxhunter.apt/defaults/main.yml +1 -5
- data/vendor/lxhunter.apt/meta/.galaxy_install_info +1 -1
- data/vendor/lxhunter.apt/tasks/main.yml +23 -23
- data/vendor/lxhunter.apt/test/integration/default/bats/simple.bats +35 -0
- data/vendor/lxhunter.apt/test/integration/default/default.yml +16 -0
- data/vendor/tersmitten.htop/.gitignore +29 -0
- data/vendor/tersmitten.htop/.travis.yml +75 -0
- data/vendor/tersmitten.htop/LICENSE.txt +19 -0
- data/vendor/tersmitten.htop/README.md +45 -0
- data/vendor/tersmitten.htop/Vagrantfile +71 -0
- data/vendor/tersmitten.htop/defaults/main.yml +8 -0
- data/vendor/tersmitten.htop/files/etc/skel/.config/htop/htoprc +23 -0
- data/vendor/tersmitten.htop/handlers/main.yml +2 -0
- data/vendor/tersmitten.htop/meta/.galaxy_install_info +1 -0
- data/vendor/tersmitten.htop/meta/main.yml +18 -0
- data/vendor/tersmitten.htop/tasks/main.yml +27 -0
- data/vendor/tersmitten.htop/templates/empty +0 -0
- data/vendor/tersmitten.htop/tests/inventory +1 -0
- data/vendor/tersmitten.htop/tests/test.yml +6 -0
- data/vendor/tersmitten.htop/tests/vagrant.yml +17 -0
- data/vendor/tersmitten.htop/vars/main.yml +2 -0
- data/vendor/williamyeh.nodejs/.gitignore +1 -0
- data/vendor/williamyeh.nodejs/LICENSE +22 -0
- data/vendor/williamyeh.nodejs/README.md +107 -0
- data/vendor/williamyeh.nodejs/Vagrantfile +33 -0
- data/vendor/williamyeh.nodejs/circle.yml +32 -0
- data/vendor/williamyeh.nodejs/defaults/main.yml +17 -0
- data/vendor/williamyeh.nodejs/files/nodesource.gpg.key +52 -0
- data/vendor/williamyeh.nodejs/meta/.galaxy_install_info +1 -0
- data/vendor/williamyeh.nodejs/meta/main.yml +27 -0
- data/vendor/williamyeh.nodejs/tasks/main.yml +19 -0
- data/vendor/williamyeh.nodejs/tasks/set-role-variables.yml +15 -0
- data/vendor/williamyeh.nodejs/tasks/use-apt.yml +88 -0
- data/vendor/williamyeh.nodejs/tasks/use-yum.yml +34 -0
- data/vendor/williamyeh.nodejs/test/Dockerfile-centos6 +29 -0
- data/vendor/williamyeh.nodejs/test/Dockerfile-centos7 +29 -0
- data/vendor/williamyeh.nodejs/test/Dockerfile-debian7 +29 -0
- data/vendor/williamyeh.nodejs/test/Dockerfile-debian8 +29 -0
- data/vendor/williamyeh.nodejs/test/Dockerfile-ubuntu12.04 +29 -0
- data/vendor/williamyeh.nodejs/test/Dockerfile-ubuntu14.04 +29 -0
- data/vendor/williamyeh.nodejs/test.yml +12 -0
- data/vendor/zzet.rbenv/.travis.yml +5 -2
- data/vendor/zzet.rbenv/README.md +1 -1
- data/vendor/zzet.rbenv/defaults/main.yml +3 -3
- data/vendor/zzet.rbenv/meta/.galaxy_install_info +1 -1
- data/vendor/zzet.rbenv/tasks/apt_build_depends.yml +7 -0
- data/vendor/zzet.rbenv/tasks/homebrew_build_depends.yml +4 -2
- data/vendor/zzet.rbenv/tasks/main.yml +5 -2
- metadata +53 -7
- data/lib/tape/vagrant_provisioner.rb +0 -42
- data/vendor/ANXS.postgresql/templates/postgresql.conf.j2 +0 -446
- data/vendor/lxhunter.apt/.travis.yml +0 -12
- data/vendor/lxhunter.apt/Vagrantfile +0 -16
- data/vendor/lxhunter.apt/templates/apt_10general.j2 +0 -4
@@ -1,4 +1,5 @@
|
|
1
1
|
- name: clone the FE app
|
2
|
+
when: fe_app_repo is defined
|
2
3
|
remote_user: "{{ deployer_user.name }}"
|
3
4
|
git: dest={{ fe_app_path }}
|
4
5
|
repo={{ fe_app_repo }}
|
@@ -8,6 +9,7 @@
|
|
8
9
|
tags: [fe_deploy]
|
9
10
|
|
10
11
|
- name: NPM install
|
12
|
+
when: fe_app_repo is defined
|
11
13
|
remote_user: "{{ deployer_user.name }}"
|
12
14
|
command: bash -lc
|
13
15
|
command: chdir={{ fe_app_path }}
|
@@ -15,6 +17,7 @@
|
|
15
17
|
tags: [fe_deploy]
|
16
18
|
|
17
19
|
- name: Bower install
|
20
|
+
when: fe_app_repo is defined
|
18
21
|
remote_user: "{{ deployer_user.name }}"
|
19
22
|
command: bash -lc
|
20
23
|
command: chdir={{ fe_app_path }}
|
@@ -22,7 +25,8 @@
|
|
22
25
|
tags: [fe_deploy]
|
23
26
|
|
24
27
|
- name: Build FE
|
28
|
+
when: fe_app_repo is defined
|
25
29
|
remote_user: "{{ deployer_user.name }}"
|
26
30
|
command: chdir={{ fe_app_path }}
|
27
|
-
bash -lc '
|
31
|
+
bash -lc '{{ fe_build_command }}'
|
28
32
|
tags: [fe_deploy]
|
data/roles/general/meta/main.yml
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
- name:
|
1
|
+
- name: Ensure repo is defined
|
2
|
+
fail: msg="App Repo is not defined. Please define it in {{ tapefiles_dir }}/tape_vars.yml"
|
3
|
+
when: (be_app_repo is undefined or be_app_repo is none) and (fe_app_repo is undefined or fe_app_repo is none)
|
4
|
+
tags: [be_deploy]
|
5
|
+
|
6
|
+
- name: Ensure app name is defined
|
7
|
+
fail: msg="app_name is not defined. Please define it in {{ tapefiles_dir }}/tape_vars.yml"
|
8
|
+
when: app_name is undefined or app_name is none
|
9
|
+
tags: [be_deploy]
|
10
|
+
|
11
|
+
- name: apt-get update upgrade
|
2
12
|
apt: update_cache=yes upgrade=safe
|
3
13
|
tags: [update, upgrade]
|
4
14
|
|
data/roles/nginx/tasks/main.yml
CHANGED
@@ -24,7 +24,11 @@
|
|
24
24
|
command: bash -lc "monit reload && sleep 2"
|
25
25
|
when: nginx_monit_config.changed
|
26
26
|
|
27
|
-
- name:
|
27
|
+
- name: Stop nginx
|
28
|
+
service: name=nginx state=stopped
|
29
|
+
tags: [restart_nginx]
|
30
|
+
|
31
|
+
- name: Start nginx
|
28
32
|
remote_user: "{{ deployer_user.name }}"
|
29
|
-
command: bash -lc "sudo monit
|
33
|
+
command: bash -lc "sudo monit start nginx"
|
30
34
|
tags: [restart_nginx]
|
data/taperole.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "taperole"
|
3
|
-
spec.version = '1.
|
3
|
+
spec.version = '1.3.0'
|
4
4
|
spec.authors = ['Jack Forrest', 'Smashing Boxes', 'Brandon Mathis']
|
5
5
|
spec.email = ['jack@smashingboxes.com', 'brandon@sbox.es']
|
6
6
|
spec.summary = 'A tool for provisioning and deploying boxes for hosting Rails apps'
|
data/vars/defaults.yml
CHANGED
@@ -3,6 +3,8 @@ be_app_path: "/home/{{ deployer_user.name }}/{{ app_name }}"
|
|
3
3
|
fe_app_name: "{{ app_name }}_fe"
|
4
4
|
fe_app_path: "/home/{{ deployer_user.name }}/{{ fe_app_name }}"
|
5
5
|
|
6
|
+
tapefiles_dir: "./taperole"
|
7
|
+
|
6
8
|
deployer_user:
|
7
9
|
name: deployer
|
8
10
|
groups:
|
@@ -29,3 +31,6 @@ precompile_assets: true
|
|
29
31
|
# Sets server_name in the nginx sites-enabled file
|
30
32
|
app_url: false
|
31
33
|
|
34
|
+
nodejs_version: 4.2
|
35
|
+
|
36
|
+
fe_build_command: gulp build
|
@@ -1,18 +1,23 @@
|
|
1
1
|
---
|
2
2
|
language: python
|
3
3
|
python: "2.7"
|
4
|
+
|
5
|
+
env:
|
6
|
+
- POSTGRESQL_VERSION=9.3
|
7
|
+
- POSTGRESQL_VERSION=9.4
|
8
|
+
|
4
9
|
before_install:
|
5
|
-
|
6
|
-
|
7
|
-
|
10
|
+
- sudo apt-get update -qq
|
11
|
+
- sudo apt-get install -qq python-apt python-pycurl locales
|
12
|
+
- echo 'en_US.UTF-8 UTF-8' | sudo tee /var/lib/locales/supported.d/local
|
8
13
|
install:
|
9
|
-
- pip install ansible==1.
|
14
|
+
- pip install ansible==1.8.4
|
10
15
|
script:
|
11
16
|
- echo localhost > inventory
|
12
17
|
- ansible-playbook -i inventory test.yml --syntax-check
|
13
|
-
- ansible-playbook -i inventory test.yml --connection=local --sudo
|
18
|
+
- ansible-playbook -i inventory test.yml --connection=local --sudo -e "postgresql_version=$POSTGRESQL_VERSION"
|
14
19
|
- >
|
15
|
-
ansible-playbook -i inventory test.yml --connection=local --sudo
|
20
|
+
ansible-playbook -i inventory test.yml --connection=local --sudo -e "postgresql_version=$POSTGRESQL_VERSION"
|
16
21
|
| grep -q 'changed=0.*failed=0'
|
17
22
|
&& (echo 'Idempotence test: pass' && exit 0)
|
18
23
|
|| (echo 'Idempotence test: fail' && exit 1)
|
@@ -4,7 +4,7 @@ Ansible role which installs and configures PostgreSQL, extensions, databases and
|
|
4
4
|
|
5
5
|
|
6
6
|
#### Requirements & Dependencies
|
7
|
-
- Tested on Ansible 1.
|
7
|
+
- Tested on Ansible 1.8.4 or higher.
|
8
8
|
- ANXS.monit ([Galaxy](https://galaxy.ansible.com/list#/roles/502)/[GH](https://github.com/ANXS/monit)) if you want monit protection (in that case, you should set `monit_protection: true`)
|
9
9
|
|
10
10
|
|
@@ -27,6 +27,7 @@ postgresql_databases:
|
|
27
27
|
- name: foobar
|
28
28
|
hstore: yes # flag to install the hstore extension on this database (yes/no)
|
29
29
|
uuid_ossp: yes # flag to install the uuid-ossp extension on this database (yes/no)
|
30
|
+
citext: yes # flag to install the citext extension on this database (yes/no)
|
30
31
|
|
31
32
|
# List of users to be created (optional)
|
32
33
|
postgresql_users:
|
@@ -44,15 +45,18 @@ postgresql_user_privileges:
|
|
44
45
|
|
45
46
|
There's a lot more knobs and bolts to set, which you can find in the defaults/main.yml
|
46
47
|
|
48
|
+
|
47
49
|
#### Testing
|
48
50
|
This project comes with a VagrantFile, this is a fast and easy way to test changes to the role, fire it up with `vagrant up`
|
49
51
|
|
50
52
|
See [vagrant docs](https://docs.vagrantup.com/v2/) for getting setup with vagrant
|
51
53
|
|
54
|
+
|
52
55
|
#### License
|
53
56
|
|
54
57
|
Licensed under the MIT License. See the LICENSE file for details.
|
55
58
|
|
59
|
+
|
56
60
|
#### Thanks
|
57
61
|
|
58
62
|
To the contributors:
|
@@ -4,7 +4,7 @@
|
|
4
4
|
Vagrant.configure('2') do |config|
|
5
5
|
config.vm.define 'anxs' do |c|
|
6
6
|
c.vm.box = 'ubuntu/trusty64'
|
7
|
-
c.vm.network :private_network, ip: '192.168.88.
|
7
|
+
c.vm.network :private_network, ip: '192.168.88.22'
|
8
8
|
c.vm.hostname = 'anxs.local'
|
9
9
|
c.vm.provision 'ansible' do |ansible|
|
10
10
|
ansible.playbook = 'test.yml'
|
@@ -95,6 +95,8 @@ postgresql_ssl_ciphers:
|
|
95
95
|
- '!EXP'
|
96
96
|
- '!MD5'
|
97
97
|
- '@STRENGTH'
|
98
|
+
postgresql_ssl_prefer_server_ciphers: on
|
99
|
+
postgresql_ssl_ecdh_curve: 'prime256v1'
|
98
100
|
postgresql_ssl_renegotiation_limit: 512MB # amount of data between renegotiations
|
99
101
|
postgresql_ssl_cert_file: /etc/ssl/certs/ssl-cert-snakeoil.pem
|
100
102
|
postgresql_ssl_key_file: /etc/ssl/private/ssl-cert-snakeoil.key
|
@@ -121,6 +123,7 @@ postgresql_tcp_keepalives_count: 0
|
|
121
123
|
# - Memory -
|
122
124
|
|
123
125
|
postgresql_shared_buffers: 128MB # min 128kB
|
126
|
+
postgresql_huge_pages: try # on, off, or try
|
124
127
|
postgresql_temp_buffers: 8MB # min 800kB
|
125
128
|
|
126
129
|
# Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory
|
@@ -131,7 +134,15 @@ postgresql_max_prepared_transactions: 0 # zero disables the feature
|
|
131
134
|
|
132
135
|
postgresql_work_mem: 1MB # min 64kB
|
133
136
|
postgresql_maintenance_work_mem: 16MB # min 1MB
|
137
|
+
postgresql_autovacuum_work_mem: -1 # min 1MB, or -1 to use maintenance_work_mem
|
134
138
|
postgresql_max_stack_depth: 2MB # min 100kB
|
139
|
+
postgresql_dynamic_shared_memory_type: posix # the default is the first option
|
140
|
+
# supported by the operating system:
|
141
|
+
# posix
|
142
|
+
# sysv
|
143
|
+
# windows
|
144
|
+
# mmap
|
145
|
+
# use none to disable dynamic shared memory
|
135
146
|
|
136
147
|
|
137
148
|
# - Disk -
|
@@ -165,6 +176,7 @@ postgresql_bgwriter_lru_multiplier: 2.0 # 0-10.0 multipler on buffers scanned
|
|
165
176
|
# - Asynchronous Behavior -
|
166
177
|
|
167
178
|
postgresql_effective_io_concurrency: 1 # 1-1000; 0 disables prefetching
|
179
|
+
postgresql_max_worker_processes: 8
|
168
180
|
|
169
181
|
|
170
182
|
#------------------------------------------------------------------------------
|
@@ -173,7 +185,7 @@ postgresql_effective_io_concurrency: 1 # 1-1000; 0 disables prefetching
|
|
173
185
|
|
174
186
|
# - Settings -
|
175
187
|
|
176
|
-
postgresql_wal_level: minimal # minimal, archive, or
|
188
|
+
postgresql_wal_level: minimal # minimal, archive, hot_standby, or logical
|
177
189
|
postgresql_fsync: on # turns forced synchronization on or off
|
178
190
|
|
179
191
|
# Synchronization level:
|
@@ -193,6 +205,7 @@ postgresql_wal_sync_method: fsync
|
|
193
205
|
|
194
206
|
# recover from partial page writes
|
195
207
|
postgresql_full_page_writes: on
|
208
|
+
postgresql_wal_log_hints: off # also do full page writes of non-critical updates
|
196
209
|
|
197
210
|
postgresql_wal_buffers: -1 # min 32kB, -1 sets based on shared_buffers
|
198
211
|
postgresql_wal_writer_delay: 200ms # 1-10000 milliseconds
|
@@ -236,6 +249,7 @@ postgresql_max_wal_senders: 0
|
|
236
249
|
|
237
250
|
postgresql_wal_keep_segments: 0 # in logfile segments, 16MB each; 0 disables
|
238
251
|
postgresql_wal_sender_timeout: 60s # in milliseconds; 0 disables
|
252
|
+
postgresql_max_replication_slots: 0 # max number of replication slots
|
239
253
|
|
240
254
|
|
241
255
|
# - Master Server -
|
@@ -490,6 +504,8 @@ postgresql_autovacuum_vacuum_scale_factor: 0.2
|
|
490
504
|
postgresql_autovacuum_analyze_scale_factor: 0.1
|
491
505
|
# maximum XID age before forced vacuum
|
492
506
|
postgresql_autovacuum_freeze_max_age: 200000000
|
507
|
+
# maximum Multixact age before forced vacuum
|
508
|
+
postgresql_autovacuum_multixact_freeze_max_age: 400000000
|
493
509
|
# default vacuum cost delay for autovacuum, in milliseconds
|
494
510
|
postgresql_autovacuum_vacuum_cost_delay: 20ms
|
495
511
|
# default vacuum cost limit for autovacuum,
|
@@ -518,6 +534,8 @@ postgresql_statement_timeout: 0 # in milliseconds, 0 is disabled
|
|
518
534
|
postgresql_lock_timeout: 0 # in milliseconds, 0 is disabled
|
519
535
|
postgresql_vacuum_freeze_min_age: 50000000
|
520
536
|
postgresql_vacuum_freeze_table_age: 150000000
|
537
|
+
postgresql_vacuum_multixact_freeze_min_age: 5000000
|
538
|
+
postgresql_vacuum_multixact_freeze_table_age: 150000000
|
521
539
|
|
522
540
|
postgresql_bytea_output: hex # hex, escape
|
523
541
|
postgresql_xmlbinary: base64
|
@@ -557,6 +575,7 @@ postgresql_default_text_search_config: pg_catalog.english
|
|
557
575
|
|
558
576
|
postgresql_dynamic_library_path: '$libdir'
|
559
577
|
postgresql_local_preload_libraries: []
|
578
|
+
postgresql_session_preload_libraries: []
|
560
579
|
|
561
580
|
|
562
581
|
#------------------------------------------------------------------------------
|
@@ -604,6 +623,19 @@ postgresql_exit_on_error: off
|
|
604
623
|
postgresql_restart_after_crash: on
|
605
624
|
|
606
625
|
|
626
|
+
#------------------------------------------------------------------------------
|
627
|
+
# PGTUNE
|
628
|
+
#------------------------------------------------------------------------------
|
629
|
+
# Should we run pgtune and accept the changes it proposes?
|
630
|
+
postgresql_pgtune: no
|
631
|
+
# Total system memory in bytes, will attempt to detect if set to "no"
|
632
|
+
postgresql_pgtune_memory: no
|
633
|
+
# Database type, valid options are DW, OLTP, Web, Mixed, Desktop
|
634
|
+
postgresql_pgtune_type: Mixed
|
635
|
+
# Maximum number of expected connections, if "no", default based on db type
|
636
|
+
postgresql_pgtune_connections: no
|
637
|
+
|
638
|
+
|
607
639
|
|
608
640
|
|
609
641
|
postgresql_env:
|
@@ -614,3 +646,5 @@ postgresql_env:
|
|
614
646
|
postgresql_apt_key_id: ACCC4CF8
|
615
647
|
postgresql_apt_key_url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
|
616
648
|
postgresql_apt_repository: 'deb http://apt.postgresql.org/pub/repos/apt/ {{ansible_distribution_release}}-pgdg main'
|
649
|
+
# Pin-Priority of PGDG repository
|
650
|
+
postgresql_apt_pin_priority: 500
|
@@ -1 +1 @@
|
|
1
|
-
{install_date: '
|
1
|
+
{install_date: 'Mon Nov 16 16:35:25 2015', version: ''}
|
@@ -36,13 +36,44 @@
|
|
36
36
|
|
37
37
|
- name: PostgreSQL | Update configuration - pt. 2 (postgresql.conf)
|
38
38
|
template:
|
39
|
-
src: postgresql.conf.j2
|
40
|
-
|
39
|
+
src: "postgresql.conf-{{ postgresql_version }}.j2"
|
40
|
+
# if using pgtune, save the template to ".untuned"
|
41
|
+
dest: "{{postgresql_conf_directory}}/postgresql.conf{% if postgresql_pgtune %}.untuned{% endif %}"
|
41
42
|
owner: "{{ postgresql_service_user }}"
|
42
43
|
group: "{{ postgresql_service_group }}"
|
43
44
|
mode: 0640
|
44
45
|
register: postgresql_configuration_pt2
|
45
46
|
|
47
|
+
- name: PostgreSQL | Update configuration - pt. 3 (pgtune)
|
48
|
+
sudo: true
|
49
|
+
sudo_user: "{{ postgresql_service_user }}"
|
50
|
+
shell: |
|
51
|
+
set -e
|
52
|
+
TMPDIR=$(mktemp -d)
|
53
|
+
pgtune --input-config=postgresql.conf.untuned\
|
54
|
+
--output-config=$TMPDIR/postgresql.conf\
|
55
|
+
{% if postgresql_pgtune_memory %}--memory {{postgresql_pgtune_memory|int}}{% endif %}\
|
56
|
+
--type {{postgresql_pgtune_type|quote}}\
|
57
|
+
{% if postgresql_pgtune_connections %}--connections {{postgresql_pgtune_connections|int}}{% endif %}\
|
58
|
+
# Compare the current config with the one procuded by pgtune (ignoring comments/blanks)
|
59
|
+
if diff --ignore-blank-lines \
|
60
|
+
<(sed -e 's/#.*//' postgresql.conf) \
|
61
|
+
<(sed -e 's/#.*//' $TMPDIR/postgresql.conf)
|
62
|
+
then
|
63
|
+
echo '_OK_'
|
64
|
+
else
|
65
|
+
cp $TMPDIR/postgresql.conf postgresql.conf
|
66
|
+
fi
|
67
|
+
# Cleanup
|
68
|
+
rm $TMPDIR/postgresql.conf
|
69
|
+
rmdir $TMPDIR
|
70
|
+
args:
|
71
|
+
chdir: "{{postgresql_conf_directory}}"
|
72
|
+
executable: "/bin/bash"
|
73
|
+
when: postgresql_pgtune
|
74
|
+
register: postgresql_configuration_pt3
|
75
|
+
changed_when: "'_OK_' not in postgresql_configuration_pt3.stdout"
|
76
|
+
|
46
77
|
- name: PostgreSQL | Create folder for additional configuration files
|
47
78
|
file:
|
48
79
|
name: "{{postgresql_conf_directory}}/conf.d"
|
@@ -55,4 +86,4 @@
|
|
55
86
|
service:
|
56
87
|
name: postgresql
|
57
88
|
state: restarted
|
58
|
-
when: postgresql_configuration_pt1.changed or postgresql_configuration_pt2.changed
|
89
|
+
when: postgresql_configuration_pt1.changed or postgresql_configuration_pt2.changed or postgresql_configuration_pt3.changed
|
@@ -26,6 +26,9 @@
|
|
26
26
|
sudo_user: "{{ postgresql_service_user }}"
|
27
27
|
shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
|
28
28
|
with_items: postgresql_databases
|
29
|
+
register: hstore_ext_result
|
30
|
+
failed_when: hstore_ext_result.rc != 0 and ("already exists, skipping" not in hstore_ext_result.stderr)
|
31
|
+
changed_when: hstore_ext_result.rc == 0 and ("already exists, skipping" not in hstore_ext_result.stderr)
|
29
32
|
when: item.hstore is defined and item.hstore
|
30
33
|
|
31
34
|
- name: PostgreSQL | Add uuid-ossp to the database with the requirement
|
@@ -65,3 +68,13 @@
|
|
65
68
|
shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'"
|
66
69
|
with_items: postgresql_databases
|
67
70
|
when: item.earthdistance is defined and item.earthdistance
|
71
|
+
|
72
|
+
- name: PostgreSQL | Add citext to the database with the requirement
|
73
|
+
sudo: yes
|
74
|
+
sudo_user: "{{ postgresql_service_user }}"
|
75
|
+
shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS citext;'"
|
76
|
+
with_items: postgresql_databases
|
77
|
+
register: citext_ext_result
|
78
|
+
failed_when: citext_ext_result.rc != 0 and ("already exists, skipping" not in citext_ext_result.stderr)
|
79
|
+
changed_when: citext_ext_result.rc == 0 and ("already exists, skipping" not in citext_ext_result.stderr)
|
80
|
+
when: item.citext is defined and item.citext
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# file: postgresql/tasks/install.yml
|
2
2
|
|
3
|
+
# The standard ca-certs are needed because without them apt_key will fail to
|
4
|
+
# validate www.postgresql.org (or probably any other source).
|
5
|
+
- name: PostgreSQL | Make sure the CA certificates are available
|
6
|
+
apt:
|
7
|
+
pkg: ca-certificates
|
8
|
+
state: present
|
9
|
+
|
3
10
|
- name: PostgreSQL | Add PostgreSQL repository apt-key
|
4
11
|
apt_key:
|
5
12
|
id: "{{ postgresql_apt_key_id }}"
|
@@ -13,6 +20,12 @@
|
|
13
20
|
state: present
|
14
21
|
when: postgresql_apt_repository
|
15
22
|
|
23
|
+
- name: PostgreSQL | Add PostgreSQL repository preferences
|
24
|
+
template:
|
25
|
+
src: etc_apt_preferences.d_apt_postgresql_org_pub_repos_apt.pref.j2
|
26
|
+
dest: /etc/apt/preferences.d/apt_postgresql_org_pub_repos_apt.pref
|
27
|
+
when: postgresql_apt_pin_priority
|
28
|
+
|
16
29
|
- name: PostgreSQL | Make sure the dependencies are installed
|
17
30
|
apt:
|
18
31
|
pkg: "{{item}}"
|
@@ -32,3 +45,12 @@
|
|
32
45
|
- "postgresql-{{postgresql_version}}"
|
33
46
|
- "postgresql-client-{{postgresql_version}}"
|
34
47
|
- "postgresql-contrib-{{postgresql_version}}"
|
48
|
+
|
49
|
+
- name: PostgreSQL | PGTune
|
50
|
+
apt:
|
51
|
+
name: pgtune
|
52
|
+
state: present
|
53
|
+
update_cache: yes
|
54
|
+
cache_valid_time: "{{apt_cache_valid_time | default (3600)}}"
|
55
|
+
environment: postgresql_env
|
56
|
+
when: postgresql_pgtune
|
@@ -3,13 +3,13 @@
|
|
3
3
|
- name: PostgreSQL | Update the user privileges
|
4
4
|
postgresql_user:
|
5
5
|
name: "{{item.name}}"
|
6
|
-
db: "{{item.db}}"
|
6
|
+
db: "{{item.db | default(omit)}}"
|
7
7
|
port: "{{postgresql_port}}"
|
8
|
-
priv: "{{item.priv | default(
|
8
|
+
priv: "{{item.priv | default(omit)}}"
|
9
9
|
state: present
|
10
|
-
login_host: "{{item.host | default(
|
10
|
+
login_host: "{{item.host | default(omit)}}"
|
11
11
|
login_user: "{{postgresql_admin_user}}"
|
12
|
-
role_attr_flags: "{{item.role_attr_flags | default(
|
12
|
+
role_attr_flags: "{{item.role_attr_flags | default(omit)}}"
|
13
13
|
sudo: yes
|
14
14
|
sudo_user: "{{postgresql_admin_user}}"
|
15
15
|
with_items: postgresql_user_privileges
|