subspace 0.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +1 -1
  5. data/CHANGELOG.md +380 -0
  6. data/README.md +511 -9
  7. data/TODO +34 -0
  8. data/UPGRADING.md +10 -0
  9. data/ansible/playbooks/local_template.yml +13 -0
  10. data/ansible/playbooks/maintenance_mode.yml +5 -0
  11. data/ansible/roles/alienvault/tasks/main.yml +29 -0
  12. data/ansible/roles/apache/defaults/main.yml +2 -5
  13. data/ansible/roles/apache/handlers/main.yml +9 -1
  14. data/ansible/roles/apache/tasks/main.yml +37 -9
  15. data/ansible/roles/apache/templates/server_status.conf +6 -0
  16. data/ansible/roles/apache-rails/tasks/main.yml +26 -0
  17. data/ansible/roles/apache-rails/templates/_canonical_domain.conf +10 -0
  18. data/ansible/roles/apache-rails/templates/_rails.conf +23 -0
  19. data/ansible/roles/apache-rails/templates/project-ssl.conf +23 -0
  20. data/ansible/roles/apache-rails/templates/project.conf +5 -0
  21. data/ansible/roles/collectd/defaults/main.yml +3 -0
  22. data/ansible/roles/collectd/handlers/main.yml +3 -0
  23. data/ansible/roles/collectd/tasks/main.yml +82 -0
  24. data/ansible/roles/collectd/templates/apache2.conf +6 -0
  25. data/ansible/roles/collectd/templates/delayed_job_postgres.conf +21 -0
  26. data/ansible/roles/collectd/templates/df.conf +16 -0
  27. data/ansible/roles/collectd/templates/graphite.conf +14 -0
  28. data/ansible/roles/collectd/templates/hostname.conf +2 -0
  29. data/ansible/roles/collectd/templates/nginx.conf +28 -0
  30. data/ansible/roles/collectd/templates/nodejs-process.conf +3 -0
  31. data/ansible/roles/collectd/templates/puma-process.conf +3 -0
  32. data/ansible/roles/collectd/templates/rails_lograge.conf +31 -0
  33. data/ansible/roles/common/defaults/main.yml +2 -1
  34. data/ansible/roles/common/files/sudoers-service +1 -0
  35. data/ansible/roles/common/tasks/main.yml +307 -19
  36. data/ansible/roles/common/tasks/no_swap.yml +26 -0
  37. data/ansible/roles/common/tasks/swap.yml +34 -8
  38. data/ansible/roles/common/templates/motd +13 -0
  39. data/ansible/roles/common/templates/motd2 +24 -0
  40. data/ansible/roles/common/templates/terminalcolor +25 -0
  41. data/ansible/roles/delayed_job/README.md +2 -4
  42. data/ansible/roles/delayed_job/defaults/main.yml +0 -2
  43. data/ansible/roles/delayed_job/handlers/main.yml +1 -1
  44. data/ansible/roles/delayed_job/tasks/main.yml +22 -29
  45. data/ansible/roles/delayed_job/templates/delayed-job-monit-rc +6 -5
  46. data/ansible/roles/delayed_job/templates/delayed-job-systemd.service +33 -0
  47. data/ansible/roles/gem-patch-report/README.md +137 -0
  48. data/ansible/roles/gem-patch-report/defaults/main.yml +2 -0
  49. data/ansible/roles/gem-patch-report/tasks/main.yml +89 -0
  50. data/ansible/roles/gem-patch-report/templates/gem-patch-report.sh.j2 +114 -0
  51. data/ansible/roles/letsencrypt/defaults/main.yml +11 -1
  52. data/ansible/roles/letsencrypt/tasks/legacy.yml +44 -0
  53. data/ansible/roles/letsencrypt/tasks/main.yml +72 -76
  54. data/ansible/roles/letsencrypt/tasks/modern.yml +39 -0
  55. data/ansible/roles/logrotate/LICENSE +27 -0
  56. data/ansible/roles/logrotate/README.md +70 -0
  57. data/ansible/roles/logrotate/defaults/main.yml +2 -0
  58. data/ansible/roles/logrotate/meta/main.yml +18 -0
  59. data/ansible/roles/logrotate/tasks/main.yml +15 -0
  60. data/ansible/roles/logrotate/templates/logrotate.d.j2 +16 -0
  61. data/ansible/roles/memcache/defaults/main.yml +2 -0
  62. data/ansible/roles/memcache/tasks/main.yml +16 -1
  63. data/ansible/roles/mysql/meta/main.yml +1 -1
  64. data/ansible/roles/mysql/tasks/main.yml +2 -2
  65. data/ansible/roles/mysql2_gem/meta/main.yml +1 -1
  66. data/ansible/roles/mysql2_gem/tasks/main.yml +1 -1
  67. data/ansible/roles/newrelic/tasks/main.yml +8 -1
  68. data/ansible/roles/newrelic-infra/defaults/main.yml +2 -0
  69. data/ansible/roles/newrelic-infra/handlers/main.yml +5 -0
  70. data/ansible/roles/newrelic-infra/tasks/main.yml +38 -0
  71. data/ansible/roles/newrelic-infra/templates/logs.yml.j2 +5 -0
  72. data/ansible/roles/newrelic-infra/templates/newrelic-infra.yml.j2 +2 -0
  73. data/ansible/roles/nginx/defaults/main.yml +4 -0
  74. data/ansible/roles/nginx/handlers/main.yml +12 -0
  75. data/ansible/roles/nginx/tasks/main.yml +113 -14
  76. data/ansible/roles/nginx/templates/nginx.conf +29 -0
  77. data/ansible/roles/nginx/templates/status +10 -0
  78. data/ansible/roles/nginx-maintenance/tasks/main.yml +33 -0
  79. data/ansible/roles/nginx-rails/defaults/main.yml +6 -0
  80. data/ansible/roles/nginx-rails/tasks/main.yml +54 -0
  81. data/ansible/roles/nginx-rails/templates/_asset_cors.conf +11 -0
  82. data/ansible/roles/nginx-rails/templates/_rails.conf +35 -0
  83. data/ansible/roles/nginx-rails/templates/_upstream.conf +11 -0
  84. data/ansible/roles/nginx-rails/templates/default_server +5 -0
  85. data/ansible/roles/nginx-rails/templates/nginx-project +9 -0
  86. data/ansible/roles/nginx-rails/templates/nginx-project-ssl +23 -0
  87. data/ansible/roles/nodejs/tasks/main.yml +33 -0
  88. data/ansible/roles/papertrail/tasks/main.yml +23 -4
  89. data/ansible/roles/papertrail/templates/log_files.yml +8 -1
  90. data/ansible/roles/postgis/.gitignore +3 -0
  91. data/ansible/roles/postgis/CHANGELOG.md +24 -0
  92. data/ansible/roles/postgis/LICENSE +202 -0
  93. data/ansible/roles/postgis/README.md +12 -0
  94. data/ansible/roles/postgis/meta/main.yml +15 -0
  95. data/ansible/roles/postgis/tasks/main.yml +20 -0
  96. data/ansible/roles/postgresql/README.md +15 -0
  97. data/ansible/roles/postgresql/defaults/main.yml +3 -0
  98. data/ansible/roles/postgresql/handlers/main.yml +1 -1
  99. data/ansible/roles/postgresql/meta/main.yml +1 -6
  100. data/ansible/roles/postgresql/tasks/backups.yml +8 -6
  101. data/ansible/roles/postgresql/tasks/main.yml +89 -9
  102. data/ansible/roles/postgresql/templates/backup.sh +17 -2
  103. data/ansible/roles/postgresql-client/tasks/main.yml +91 -0
  104. data/ansible/roles/puma/tasks/main.yml +38 -19
  105. data/ansible/roles/puma/templates/puma-monit-rc +5 -0
  106. data/ansible/roles/puma/templates/puma-systemd.service +43 -0
  107. data/ansible/roles/puma/templates/puma-systemd.socket +14 -0
  108. data/ansible/roles/puma/templates/puma.rb +24 -12
  109. data/ansible/roles/rails/defaults/main.yml +1 -3
  110. data/ansible/roles/rails/tasks/main.yml +76 -18
  111. data/ansible/roles/rails/templates/application.yml +1 -1
  112. data/ansible/roles/rails/templates/database.yml +3 -3
  113. data/ansible/roles/redis/defaults/main.yml +2 -0
  114. data/ansible/roles/redis/tasks/main.yml +45 -3
  115. data/ansible/roles/resque/tasks/main.yml +14 -0
  116. data/ansible/roles/resque/templates/resque-monit-rc +4 -0
  117. data/ansible/roles/resque/templates/resque-systemd.service +54 -0
  118. data/ansible/roles/ruby-common/README.md +1 -1
  119. data/ansible/roles/ruby-common/defaults/main.yml +1 -0
  120. data/ansible/roles/ruby-common/tasks/main.yml +55 -13
  121. data/ansible/roles/sidekiq/README.md +1 -0
  122. data/ansible/roles/sidekiq/defaults/main.yml +2 -0
  123. data/ansible/roles/sidekiq/tasks/main.yml +15 -0
  124. data/ansible/roles/sidekiq/templates/sidekiq-monit-rc +4 -0
  125. data/ansible/roles/sidekiq/templates/sidekiq-systemd.service +63 -0
  126. data/ansible/roles/tailscale/defaults/main.yml +2 -0
  127. data/ansible/roles/tailscale/tasks/main.yml +40 -0
  128. data/ansible/roles/yarn/tasks/main.yml +19 -0
  129. data/ansible/roles/zenoamaro.postgresql/.gitignore +1 -0
  130. data/ansible/roles/zenoamaro.postgresql/.travis.yml +28 -0
  131. data/ansible/roles/zenoamaro.postgresql/LICENSE.md +21 -0
  132. data/ansible/roles/zenoamaro.postgresql/README.md +117 -0
  133. data/ansible/roles/zenoamaro.postgresql/Vagrantfile +62 -0
  134. data/ansible/roles/zenoamaro.postgresql/boxed.yml +26 -0
  135. data/ansible/roles/zenoamaro.postgresql/defaults/main.yml +607 -0
  136. data/ansible/roles/zenoamaro.postgresql/handlers/main.yml +8 -0
  137. data/ansible/roles/zenoamaro.postgresql/inventory +19 -0
  138. data/ansible/roles/zenoamaro.postgresql/main.yml +19 -0
  139. data/ansible/roles/zenoamaro.postgresql/meta/.galaxy_install_info +1 -0
  140. data/ansible/roles/zenoamaro.postgresql/meta/main.yml +21 -0
  141. data/ansible/roles/zenoamaro.postgresql/tasks/configure.yml +55 -0
  142. data/ansible/roles/zenoamaro.postgresql/tasks/extensions.yml +49 -0
  143. data/ansible/roles/zenoamaro.postgresql/tasks/install.yml +51 -0
  144. data/ansible/roles/zenoamaro.postgresql/tasks/main.yml +5 -0
  145. data/ansible/roles/zenoamaro.postgresql/templates/environment +11 -0
  146. data/ansible/roles/zenoamaro.postgresql/templates/pg_ctl.conf +5 -0
  147. data/ansible/roles/zenoamaro.postgresql/templates/pg_hba.conf +112 -0
  148. data/ansible/roles/zenoamaro.postgresql/templates/pg_ident.conf +46 -0
  149. data/ansible/roles/zenoamaro.postgresql/templates/postgresql.conf +536 -0
  150. data/ansible/roles/zenoamaro.postgresql/test.yml +24 -0
  151. data/bin/console +0 -4
  152. data/exe/subspace +3 -84
  153. data/lib/subspace/cli.rb +168 -0
  154. data/lib/subspace/commands/ansible.rb +35 -0
  155. data/lib/subspace/commands/base.rb +94 -0
  156. data/lib/subspace/commands/bootstrap.rb +49 -0
  157. data/lib/subspace/commands/configure.rb +27 -0
  158. data/lib/subspace/commands/exec.rb +20 -0
  159. data/lib/subspace/commands/init.rb +144 -0
  160. data/lib/subspace/commands/inventory.rb +54 -0
  161. data/lib/subspace/commands/maintain.rb +16 -0
  162. data/lib/subspace/commands/maintenance_mode.rb +16 -0
  163. data/lib/subspace/commands/override.rb +21 -0
  164. data/lib/subspace/commands/provision.rb +14 -0
  165. data/lib/subspace/commands/secrets.rb +69 -0
  166. data/lib/subspace/commands/ssh.rb +33 -0
  167. data/lib/subspace/commands/terraform.rb +89 -0
  168. data/lib/subspace/configuration.rb +71 -0
  169. data/lib/subspace/inventory.rb +144 -0
  170. data/lib/subspace/version.rb +1 -1
  171. data/lib/subspace.rb +8 -1
  172. data/subspace.gemspec +14 -3
  173. data/template/provision.rb.erb +94 -0
  174. data/template/subspace/.gitignore +6 -0
  175. data/template/subspace/ansible.cfg.erb +17 -0
  176. data/template/subspace/group_vars/all.erb +28 -0
  177. data/template/subspace/group_vars/template.erb +26 -0
  178. data/template/subspace/inventory.yml.erb +12 -0
  179. data/template/subspace/playbook.yml.erb +18 -0
  180. data/template/subspace/secrets/template.erb +5 -0
  181. data/template/subspace/templates/application.yml.template +27 -0
  182. data/template/subspace/templates/authorized_keys.erb +1 -0
  183. data/template/subspace/terraform/.gitignore +2 -0
  184. data/template/subspace/terraform/template/main-oxenwagen.tf.erb +116 -0
  185. data/template/subspace/terraform/template/main-workhorse.tf.erb +41 -0
  186. data/template/subspace/terraformrc.erb +9 -0
  187. data/terraform/modules/s3_backend/README +2 -0
  188. data/terraform/modules/s3_backend/dynamodb.tf +1 -0
  189. data/terraform/modules/s3_backend/iam_user.tf +38 -0
  190. data/terraform/modules/s3_backend/main.tf +39 -0
  191. data/terraform/modules/s3_backend/state_bucket.tf +14 -0
  192. metadata +198 -29
  193. data/ansible/roles/apache/templates/project.conf +0 -25
  194. data/ansible/roles/aws/tasks/main.yml +0 -46
  195. data/ansible/roles/delayed_job/files/deploy-service +0 -2
  196. data/ansible/roles/delayed_job/files/monit-http.conf +0 -3
  197. data/ansible/roles/letsencrypt/templates/project-le-ssl.conf +0 -31
  198. data/ansible/roles/nginx/templates/nginx-project +0 -27
  199. data/ansible/roles/puma/templates/etc-init-puma-manager.conf +0 -31
  200. data/ansible/roles/puma/templates/etc-init-puma.conf +0 -69
  201. data/lib/subspace/railtie.rb +0 -9
  202. data/lib/tasks/provision.rake +0 -12
  203. data/template/provision/.gitignore +0 -1
  204. data/template/provision/ansible.cfg.erb +0 -5
  205. data/template/provision/group_vars/all.erb +0 -12
  206. data/template/provision/group_vars/template.erb +0 -14
  207. data/template/provision/host_vars/template.erb +0 -4
  208. data/template/provision/playbook.yml.erb +0 -26
  209. data/template/provision/vars/template.erb +0 -4
  210. /data/template/{provision → subspace}/hosts.erb +0 -0
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  - name: Update APT cache
3
- apt: update_cache=yes
4
- when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
3
+ apt: update_cache=yes cache_valid_time=3600
4
+ become: true
5
+ when: ansible_facts["distribution"] == 'Debian' or ansible_facts["distribution"] == 'Ubuntu'
5
6
 
6
7
  - name: Retrieve the number of cores that are available for compilation
7
8
  command: nproc
@@ -9,33 +10,38 @@
9
10
 
10
11
  - name: Install APT prerequisite packages that are necessary to compile applications and gems with native extensions
11
12
  apt: pkg={{ item }}
13
+ become: true
12
14
  with_items:
13
15
  - autoconf
14
16
  - build-essential
15
- when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
17
+ when: ansible_facts["distribution"] == 'Debian' or ansible_facts["distribution"] == 'Ubuntu'
16
18
 
17
19
  - name: Install yum prerequisite packages that are necessary to compile applications and gems with native extensions
18
20
  yum: name="{{ item }}"
21
+ become: true
19
22
  with_items:
20
23
  - autoconf
21
24
  - "@Developer tools"
22
- when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Amazon'
25
+ when: ansible_facts["distribution"] == 'CentOS' or ansible_facts["distribution"] == 'Red Hat Enterprise Linux' or ansible_facts["distribution"] == 'Amazon'
23
26
 
24
27
  - name: Install APT Ruby dependencies
28
+ become: true
25
29
  apt: pkg={{ item }}
26
30
  state=present
27
- with_items: ruby_apt_dependencies
28
- when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
31
+ with_items: "{{ ruby_apt_dependencies }}"
32
+ when: ansible_facts["distribution"] == 'Debian' or ansible_facts["distribution"] == 'Ubuntu'
29
33
 
30
34
  - name: Install yum Ruby dependencies
35
+ become: true
31
36
  yum: name={{ item }}
32
- with_items: ruby_yum_dependencies
33
- when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Amazon'
37
+ with_items: "{{ ruby_yum_dependencies }}"
38
+ when: ansible_facts["distribution"] == 'CentOS' or ansible_facts["distribution"] == 'Red Hat Enterprise Linux' or ansible_facts["distribution"] == 'Amazon'
34
39
 
35
40
  - name: Download the Ruby source code
36
41
  get_url: url={{ ruby_download_location }}
37
42
  dest=/usr/local/src/
38
- sha256sum={{ ruby_checksum }}
43
+ checksum={{ ruby_checksum }}
44
+ become: true
39
45
 
40
46
  - name: Generate the Ruby installation script
41
47
  template: src=install-ruby.j2
@@ -43,10 +49,12 @@
43
49
  owner=root
44
50
  group=root
45
51
  mode=700
52
+ become: true
46
53
 
47
54
  - name: Run the Ruby installation script
48
55
  command: /usr/local/src/install-ruby.sh
49
56
  creates={{ ruby_location }}/bin/ruby
57
+ become: true
50
58
 
51
59
  - name: Generate the script that allows you to easily run Rake tasks with the correct RAILS_ENV environment variable, and the wrapper script that contains GC settings
52
60
  template: src={{ item }}.j2
@@ -54,16 +62,50 @@
54
62
  owner=root
55
63
  group=root
56
64
  mode=755
65
+ become: true
57
66
  with_items:
58
67
  - rake-env
59
68
  - ruby-gc-wrapper
60
69
 
61
- - name: Install Bundler
62
- command: "{{ ruby_location }}/bin/gem install bundler {{ ruby_bundler_flags }}
63
- creates={{ ruby_location }}/bin/bundle"
70
+ - name: Update rubygems
71
+ command: "{{ ruby_location }}/bin/gem update --system"
72
+ become: true
73
+
74
+ - name: Install/update Bundler
75
+ shell: "{{ ruby_location }}/bin/gem install bundler -v {{ bundler_version }}"
76
+ become: true
64
77
 
65
78
  - name: Make Ruby symlinks
66
79
  file: path=/usr/local/bin/{{ item }}
67
80
  src={{ ruby_location }}/bin/{{ item }}
68
81
  state=link
69
- with_items: ruby_symlinks
82
+ become: true
83
+ with_items: "{{ ruby_symlinks }}"
84
+
85
+ - name: Grab Ruby version
86
+ shell: ruby --version
87
+ register: stats_ruby_version
88
+ when: send_stats == true and stats_url is defined and stats_api_key is defined
89
+ tags:
90
+ - maintenance
91
+ - stats
92
+ ignore_errors: yes
93
+
94
+ - name: Send Ruby stats to URL
95
+ uri:
96
+ url: "{{stats_url}}"
97
+ method: POST
98
+ headers:
99
+ X-API-Version: 1
100
+ X-Client-Api-key: "{{stats_api_key}}"
101
+ body_format: json
102
+ body:
103
+ client_stat:
104
+ stat_type: ruby_version
105
+ value: "{{stats_ruby_version.stdout}}"
106
+ hostname: "{{hostname}}"
107
+ when: send_stats == true and stats_url is defined and stats_api_key is defined
108
+ tags:
109
+ - maintenance
110
+ - stats
111
+ ignore_errors: yes
@@ -0,0 +1 @@
1
+ # Sidekiq Role
@@ -0,0 +1,2 @@
1
+ ---
2
+ sidekiq_workers: 1
@@ -0,0 +1,15 @@
1
+ ---
2
+ - name: Install systemd sidekiq script
3
+ become: true
4
+ template:
5
+ src: sidekiq-systemd.service
6
+ dest: /etc/systemd/system/sidekiq.service
7
+
8
+ - name: Enable systemd sidekiq service
9
+ become: true
10
+ systemd:
11
+ name: sidekiq
12
+ enabled: yes
13
+ daemon_reload: true
14
+
15
+ # TODO Read the gemfile and make sure they have sidekiq 6????
@@ -0,0 +1,4 @@
1
+ check process sidekiq
2
+ with pidfile /u/apps/{{project_name}}/shared/tmp/pids/sidekiq.pid
3
+ start program = "/bin/su - deploy -c 'cd /u/apps/{{project_name}}/current && bundle exec sidekiq --queue {{hostname}} {{ job_queues | map('regex_replace', '^(.*)$', '--queue \\1') | join(' ') }} -c {{sidekiq_workers}} --pidfile /u/apps/{{project_name}}/shared/tmp/pids/sidekiq.pid --environment {{rails_env}} --logfile /u/apps/{{project_name}}/shared/log/sidekiq.log --daemon'" with timeout 30 seconds
4
+ stop program = "/bin/su - deploy -c 'kill -s TERM `cat /u/apps/{{project_name}}/shared/tmp/pids/sidekiq.pid`'" with timeout 30 seconds
@@ -0,0 +1,63 @@
1
+ #
2
+ # This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
3
+ #
4
+ # Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output.
5
+ #
6
+ [Unit]
7
+ Description=sidekiq
8
+ # start us only once the network and logging subsystems are available,
9
+ # consider adding redis-server.service if Redis is local and systemd-managed.
10
+ After=syslog.target network.target
11
+
12
+ # See these pages for lots of options:
13
+ #
14
+ # https://www.freedesktop.org/software/systemd/man/systemd.service.html
15
+ # https://www.freedesktop.org/software/systemd/man/systemd.exec.html
16
+ #
17
+ # THOSE PAGES ARE CRITICAL FOR ANY LINUX DEVOPS WORK; read them multiple
18
+ # times! systemd is a critical tool for all developers to know and understand.
19
+ #
20
+ [Service]
21
+ #
22
+ # !!!! !!!! !!!!
23
+ #
24
+ # As of v6.0.6, Sidekiq automatically supports systemd's `Type=notify` and watchdog service
25
+ # monitoring. If you are using an earlier version of Sidekiq, change this to `Type=simple`
26
+ # and remove the `WatchdogSec` line.
27
+ #
28
+ # !!!! !!!! !!!!
29
+ #
30
+ Type=notify
31
+ # If your Sidekiq process locks up, systemd's watchdog will restart it within seconds.
32
+ WatchdogSec=10
33
+
34
+ WorkingDirectory=/u/apps/{{project_name}}/current
35
+ ExecStart=/usr/local/bin/bundle exec sidekiq -e {{rails_env}} --queue {{hostname}} {{ job_queues | map('regex_replace', '^(.*)$', '--queue \\1') | join(' ') }} -c {{sidekiq_workers}}
36
+
37
+ # Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process
38
+
39
+ # Uncomment this if you are going to use this as a system service
40
+ # if using as a user service then leave commented out, or you will get an error trying to start the service
41
+ # !!! Change this to your deploy user account if you are using this as a system service !!!
42
+ User=deploy
43
+ Group=deploy
44
+ UMask=0002
45
+
46
+ # Greatly reduce Ruby memory fragmentation and heap usage
47
+ # https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
48
+ Environment=MALLOC_ARENA_MAX=2
49
+ Environment=RAILS_ENV={{rails_env}}
50
+
51
+ # if we crash, restart
52
+ RestartSec=1
53
+ Restart=on-failure
54
+
55
+ # output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
56
+ StandardOutput=syslog
57
+ StandardError=syslog
58
+
59
+ # This will default to "bundler" if we don't specify it
60
+ SyslogIdentifier=sidekiq
61
+
62
+ [Install]
63
+ WantedBy=multi-user.target
@@ -0,0 +1,2 @@
1
+ ---
2
+ tailscale_options: ""
@@ -0,0 +1,40 @@
1
+ ---
2
+ - name: Remove old redis repo if present (Pre subspace 3.1)
3
+ ansible.builtin.file:
4
+ path: /etc/apt/sources.list.d/pkgs_tailscale_com_stable_ubuntu.list
5
+ state: absent
6
+
7
+ - name: Add official tailscale apt repo
8
+ ansible.builtin.deb822_repository:
9
+ name: tailscale
10
+ types: [deb]
11
+ uris: "https://pkgs.tailscale.com/stable/ubuntu"
12
+ components: [main]
13
+ suites: [ "{{ ansible_facts['distribution_release'] }}" ]
14
+ signed_by: https://pkgs.tailscale.com/stable/ubuntu/{{ansible_facts["distribution_release"]}}.gpg
15
+
16
+
17
+ - name: "Allow tailscale to be installed"
18
+ ignore_errors: yes
19
+ dpkg_selections:
20
+ name: tailscale
21
+ selection: install
22
+ tags:
23
+ - maintenance
24
+ - tailscale_reauth
25
+
26
+ - name: "Install tailscale from apt"
27
+ apt:
28
+ name: tailscale
29
+ state: latest
30
+ allow_downgrade: true
31
+ update_cache: yes
32
+ cache_valid_time: 3600
33
+ tags:
34
+ - maintenance
35
+ - tailscale_reauth
36
+
37
+ - name: "Join the tailnet and force reauth"
38
+ become: true
39
+ command: tailscale up --ssh --auth-key={{tailscale_auth_key}} --hostname={{project_name | regex_replace('_', '')}}-{{hostname}} --accept-risk=lose-ssh {{tailscale_options}} --force-reauth
40
+ tags: [ 'never', 'tailscale_reauth' ]
@@ -0,0 +1,19 @@
1
+ ---
2
+ - name: Add Yarn official APT repository
3
+ ansible.builtin.deb822_repository:
4
+ name: yarn
5
+ types: [deb]
6
+ uris: "http://dl.yarnpkg.com/debian/"
7
+ components: [main]
8
+ suites: [stable]
9
+ signed_by: https://dl.yarnpkg.com/debian/pubkey.gpg
10
+ state: present
11
+ enabled: true
12
+
13
+ - name: "Install yarn from official repo"
14
+ become: yes
15
+ become_user: root
16
+ apt:
17
+ pkg: yarn
18
+ state: latest
19
+ update_cache: yes
@@ -0,0 +1 @@
1
+ /.vagrant/
@@ -0,0 +1,28 @@
1
+ ---
2
+
3
+ # Configuration directives for Travis CI
4
+ # --------------------------------------
5
+
6
+ # See the Travis documentation for help on writing this file.
7
+
8
+ # [Travis CI] http://travis-ci.org
9
+ # [configuration] http://about.travis-ci.org/docs/user/build-configuration/
10
+
11
+
12
+ language: python # Needed to run ansible
13
+
14
+ python:
15
+ - "2.7"
16
+
17
+ install:
18
+ - pip install ansible
19
+
20
+ script:
21
+ # Syntax check every ansible playbook in root
22
+ # Don't check main, though, as vars_prompt still
23
+ # trigger during syntax checks, and travis fails
24
+ - find . -maxdepth 1 -type f -name '*.yml' -not -name '.*' -not -name 'main.yml' | xargs -t -n1 ansible-playbook --syntax-check -i inventory
25
+
26
+ notifications:
27
+ email:
28
+ - zenoamaro@gmail.com
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015, zenoamaro <zenoamaro@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,117 @@
1
+ PostgreSQL role for Ansible
2
+ ===========================
3
+
4
+ A role for deploying and configuring [PostgreSQL](http://www.postgresql.org/) and extensions on unix hosts using [Ansible](http://www.ansibleworks.com/).
5
+
6
+ It can additionally be used as a playbook for quickly provisioning hosts.
7
+
8
+ Vagrant machines are provided to produce a boxed install of PostgreSQL or a VM for integration testing.
9
+
10
+
11
+ Supports
12
+ --------
13
+ Supported PostgreSQL versions:
14
+
15
+ - PostgreSQL 9.4
16
+ - PostgreSQL 9.3
17
+
18
+ Supported targets:
19
+ - Ubuntu 14.04 LTS "Trusty Tahr"
20
+ - Ubuntu 12.04 LTS "Precise Pangolin"
21
+ - Debian (untested)
22
+ - RedHat (untested)
23
+
24
+ Installation methods:
25
+
26
+ - Binary packages from the official repositories at [postgresql.org](http://www.postgresql.org/download/)
27
+
28
+ Available extensions (under a switch):
29
+
30
+ - Development headers - `postgresql_dev_headers`
31
+ - Contrib modules - `postgresql_contrib`
32
+ - [PostGIS](http://postgis.net/) - `postgresql_postgis`
33
+
34
+
35
+ Usage
36
+ -----
37
+ Clone this repo into your roles directory:
38
+
39
+ $ git clone https://github.com/zenoamaro/ansible-postgresql.git roles/postgresql
40
+
41
+ And add it to your play's roles:
42
+
43
+ - hosts: ...
44
+ roles:
45
+ - postgresql
46
+ - ...
47
+
48
+ This roles comes preloaded with almost every available default. You can override each one in your hosts/group vars, in your inventory, or in your play. See the annotated defaults in `defaults/main.yml` for help in configuration. All provided variables start with `postgresql_`.
49
+
50
+ You can also use the role as a playbook. You will be asked which hosts to provision, and you can further configure the play by using `--extra-vars`.
51
+
52
+ $ ansible-playbook -i inventory --extra-vars='{...}' main.yml
53
+
54
+ To provision a standalone PostgreSQL box, start the `boxed` VM, which is a Ubuntu 12.04 box:
55
+
56
+ $ vagrant up boxed
57
+
58
+ You will find PostgreSQL listening on the VM's `5432` port on address `192.168.33.20` in the private network. You can then connect to it as any user. Please note that this is highly insecure, so if you're going to publish this VM you'll want to provide actual authentication.
59
+
60
+ Run the tests by provisioning the appropriate VM:
61
+
62
+ $ vagrant up test-ubuntu-trusty
63
+
64
+ At the moment, the following test boxes are available:
65
+
66
+ - `test-ubuntu-precise`
67
+ - `test-ubuntu-trusty`
68
+
69
+
70
+ Still to do
71
+ -----------
72
+ - Add repositories, tasks and test VMs for other distros
73
+ - Allow installation from sources if requested
74
+ - Add support for different PostgreSQL versions (9.4+)
75
+ - Add support for PostgreSQL clusters
76
+ - Add support for [PgBouncer](http://wiki.postgresql.org/wiki/PgBouncer)
77
+ - Try to make the boxed VM more secure by default
78
+ - Add links to the relevant documentation in configuration files
79
+ - Provide a library of custom modules
80
+
81
+
82
+ Changelog
83
+ ---------
84
+ ### 0.1.2
85
+ - Installing less dependencies, and later in the process.
86
+
87
+ ### 0.1.1
88
+ - The package list is not being updated in playbooks anymore.
89
+ - Added more test machines.
90
+
91
+ ### 0.1
92
+ Initial version.
93
+
94
+
95
+ License
96
+ -------
97
+ The MIT License (MIT)
98
+
99
+ Copyright (c) 2015, zenoamaro <zenoamaro@gmail.com>
100
+
101
+ Permission is hereby granted, free of charge, to any person obtaining a copy
102
+ of this software and associated documentation files (the "Software"), to deal
103
+ in the Software without restriction, including without limitation the rights
104
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
105
+ copies of the Software, and to permit persons to whom the Software is
106
+ furnished to do so, subject to the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be included in
109
+ all copies or substantial portions of the Software.
110
+
111
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
112
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
113
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
114
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
115
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
116
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
117
+ THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure '2' do |config|
5
+
6
+
7
+ # Standalone box
8
+ # --------------
9
+
10
+ # Provision this machine to obtain a standalone box
11
+ # listening on the default ports.
12
+
13
+ config.vm.define 'boxed' do |box|
14
+ box.vm.box = "ubuntu/trusty64"
15
+ # Configure the network topology to your needs
16
+ config.vm.network :private_network, ip: "192.168.33.10"
17
+ # config.vm.network :public_network
18
+ config.vm.provision :ansible do |ansible|
19
+ ansible.playbook = './boxed.yml'
20
+ ansible.inventory_path = './inventory'
21
+ end
22
+ # Forward this postgres to a port on the host
23
+ config.vm.network :forwarded_port, guest: 5432, host: 15432
24
+ # TODO: What about also forwarding the data storage?
25
+ end
26
+
27
+
28
+ # Test machines
29
+ # -------------
30
+
31
+ # These test machines will configure the installation with all
32
+ # its extensions enabled, in order to test the validity
33
+ # of the role.
34
+
35
+ # Ubuntu machines are available:
36
+ # - "test-ubuntu-precise"
37
+ # - "test-ubuntu-trusty"
38
+
39
+ def apply_test_ansible_defaults(ansible)
40
+ ansible.playbook = './test.yml'
41
+ ansible.inventory_path = './inventory'
42
+ end
43
+
44
+ config.vm.define 'test-ubuntu-trusty', autostart:false do |box|
45
+ box.vm.box = "ubuntu/trusty64"
46
+ config.vm.network :private_network, ip: "192.168.33.21"
47
+ config.vm.provision :ansible do |ansible|
48
+ apply_test_ansible_defaults ansible
49
+ ansible.extra_vars = {}
50
+ end
51
+ end
52
+
53
+ config.vm.define 'test-ubuntu-precise', autostart:false do |box|
54
+ box.vm.box = "ubuntu/precise64"
55
+ config.vm.network :private_network, ip: "192.168.33.20"
56
+ config.vm.provision :ansible do |ansible|
57
+ apply_test_ansible_defaults ansible
58
+ ansible.extra_vars = {}
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,26 @@
1
+ ---
2
+
3
+ # Boxed installation playbook
4
+ # ---------------------------
5
+
6
+ # A Simple, straight playbook for producing
7
+ # a boxed installation in a vagrant VM.
8
+
9
+
10
+ - name: 'PostgreSQL boxed installation'
11
+
12
+ hosts: vagrant
13
+
14
+ vars:
15
+ postgresql_listen_addresses:
16
+ - '*'
17
+ postgresql_authentication:
18
+ - type: host
19
+ user: all
20
+ database: all
21
+ address: '0.0.0.0/0'
22
+ method: trust
23
+
24
+ roles:
25
+ - '.' # This role itself
26
+