subspace 0.1.3 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +152 -1
  3. data/TODO +34 -0
  4. data/ansible/roles/apache/tasks/main.yml +5 -2
  5. data/ansible/roles/collectd/defaults/main.yml +3 -0
  6. data/ansible/roles/collectd/handlers/main.yml +3 -0
  7. data/ansible/roles/collectd/tasks/main.yml +43 -0
  8. data/ansible/roles/collectd/templates/delayed_job_postgres.conf +20 -0
  9. data/ansible/roles/collectd/templates/df.conf +16 -0
  10. data/ansible/roles/collectd/templates/graphite.conf +14 -0
  11. data/ansible/roles/collectd/templates/hostname.conf +2 -0
  12. data/ansible/roles/{delayed_job/files/deploy-service → common/files/sudoers-service} +0 -1
  13. data/ansible/roles/common/tasks/main.yml +37 -7
  14. data/ansible/roles/common/tasks/swap.yml +8 -6
  15. data/ansible/roles/common/templates/motd +10 -7
  16. data/ansible/roles/common/templates/motd2 +24 -0
  17. data/ansible/roles/delayed_job/README.md +2 -4
  18. data/ansible/roles/delayed_job/defaults/main.yml +0 -2
  19. data/ansible/roles/delayed_job/meta/main.yml +5 -0
  20. data/ansible/roles/delayed_job/tasks/main.yml +3 -18
  21. data/ansible/roles/delayed_job/templates/delayed-job-monit-rc +1 -1
  22. data/ansible/roles/letsencrypt/defaults/main.yml +1 -1
  23. data/ansible/roles/letsencrypt/tasks/main.yml +27 -23
  24. data/ansible/roles/logrotate/LICENSE +27 -0
  25. data/ansible/roles/logrotate/README.md +70 -0
  26. data/ansible/roles/logrotate/defaults/main.yml +2 -0
  27. data/ansible/roles/logrotate/meta/main.yml +18 -0
  28. data/ansible/roles/logrotate/tasks/main.yml +15 -0
  29. data/ansible/roles/logrotate/templates/logrotate.d.j2 +16 -0
  30. data/ansible/roles/{delayed_job → monit}/files/monit-http.conf +0 -0
  31. data/ansible/roles/monit/files/sudoers-monit +1 -0
  32. data/ansible/roles/monit/handlers/main.yml +3 -0
  33. data/ansible/roles/monit/tasks/main.yml +19 -0
  34. data/ansible/roles/mtpereira.passenger/.bumpversion.cfg +7 -0
  35. data/ansible/roles/mtpereira.passenger/.gitignore +2 -0
  36. data/ansible/roles/mtpereira.passenger/LICENSE +20 -0
  37. data/ansible/roles/mtpereira.passenger/README.md +31 -0
  38. data/ansible/roles/mtpereira.passenger/defaults/main.yml +5 -0
  39. data/ansible/roles/mtpereira.passenger/handlers/main.yml +8 -0
  40. data/ansible/roles/mtpereira.passenger/meta/.galaxy_install_info +1 -0
  41. data/ansible/roles/mtpereira.passenger/meta/main.yml +21 -0
  42. data/ansible/roles/mtpereira.passenger/tasks/apt.yml +13 -0
  43. data/ansible/roles/mtpereira.passenger/tasks/main.yml +8 -0
  44. data/ansible/roles/mtpereira.passenger/tasks/pkg.yml +35 -0
  45. data/ansible/roles/mtpereira.passenger/tasks/service.yml +8 -0
  46. data/ansible/roles/newrelic/tasks/main.yml +4 -1
  47. data/ansible/roles/nginx/tasks/main.yml +8 -1
  48. data/ansible/roles/papertrail/tasks/main.yml +16 -1
  49. data/ansible/roles/passenger/meta/main.yml +6 -0
  50. data/ansible/roles/postgresql/README.md +15 -0
  51. data/ansible/roles/postgresql/defaults/main.yml +3 -0
  52. data/ansible/roles/postgresql/meta/main.yml +1 -1
  53. data/ansible/roles/postgresql/tasks/main.yml +9 -8
  54. data/ansible/roles/postgresql/templates/backup.sh +17 -2
  55. data/ansible/roles/rails/defaults/main.yml +3 -0
  56. data/ansible/roles/rails/tasks/main.yml +7 -7
  57. data/ansible/roles/redis/tasks/main.yml +1 -0
  58. data/ansible/roles/ruby-common/tasks/main.yml +14 -3
  59. data/ansible/roles/sidekiq/README.md +1 -0
  60. data/ansible/roles/sidekiq/meta/main.yml +8 -0
  61. data/ansible/roles/sidekiq/tasks/main.yml +7 -0
  62. data/ansible/roles/sidekiq/templates/sidekiq-monit-rc +6 -0
  63. data/ansible/roles/zenoamaro.postgresql/.gitignore +1 -0
  64. data/ansible/roles/zenoamaro.postgresql/.travis.yml +28 -0
  65. data/ansible/roles/zenoamaro.postgresql/LICENSE.md +21 -0
  66. data/ansible/roles/zenoamaro.postgresql/README.md +117 -0
  67. data/ansible/roles/zenoamaro.postgresql/Vagrantfile +62 -0
  68. data/ansible/roles/zenoamaro.postgresql/boxed.yml +26 -0
  69. data/ansible/roles/zenoamaro.postgresql/defaults/main.yml +606 -0
  70. data/ansible/roles/zenoamaro.postgresql/handlers/main.yml +8 -0
  71. data/ansible/roles/zenoamaro.postgresql/inventory +19 -0
  72. data/ansible/roles/zenoamaro.postgresql/main.yml +19 -0
  73. data/ansible/roles/zenoamaro.postgresql/meta/.galaxy_install_info +1 -0
  74. data/ansible/roles/zenoamaro.postgresql/meta/main.yml +21 -0
  75. data/ansible/roles/zenoamaro.postgresql/tasks/configure.yml +55 -0
  76. data/ansible/roles/zenoamaro.postgresql/tasks/extensions.yml +49 -0
  77. data/ansible/roles/zenoamaro.postgresql/tasks/install.yml +51 -0
  78. data/ansible/roles/zenoamaro.postgresql/tasks/main.yml +5 -0
  79. data/ansible/roles/zenoamaro.postgresql/templates/environment +11 -0
  80. data/ansible/roles/zenoamaro.postgresql/templates/pg_ctl.conf +5 -0
  81. data/ansible/roles/zenoamaro.postgresql/templates/pg_hba.conf +112 -0
  82. data/ansible/roles/zenoamaro.postgresql/templates/pg_ident.conf +46 -0
  83. data/ansible/roles/zenoamaro.postgresql/templates/postgresql.conf +530 -0
  84. data/ansible/roles/zenoamaro.postgresql/test.yml +24 -0
  85. data/exe/subspace +2 -82
  86. data/lib/subspace/cli.rb +85 -0
  87. data/lib/subspace/commands/ansible.rb +20 -0
  88. data/lib/subspace/commands/base.rb +36 -0
  89. data/lib/subspace/commands/bootstrap.rb +47 -0
  90. data/lib/subspace/commands/configure.rb +27 -0
  91. data/lib/subspace/commands/init.rb +79 -0
  92. data/lib/subspace/commands/override.rb +21 -0
  93. data/lib/subspace/commands/provision.rb +10 -0
  94. data/lib/subspace/commands/ssh.rb +14 -0
  95. data/lib/subspace/commands/vars.rb +11 -0
  96. data/lib/subspace/configuration.rb +71 -0
  97. data/lib/subspace/version.rb +1 -1
  98. data/lib/subspace.rb +8 -1
  99. data/subspace.gemspec +2 -0
  100. data/template/provision/ansible.cfg.erb +4 -1
  101. data/template/provision/group_vars/all.erb +2 -0
  102. data/template/provision/group_vars/template.erb +0 -3
  103. data/template/provision/host_vars/template.erb +1 -1
  104. data/template/provision/playbook.yml.erb +0 -10
  105. data/template/provision.rb.erb +94 -0
  106. metadata +90 -8
  107. data/ansible/roles/aws/tasks/main.yml +0 -46
  108. data/lib/subspace/railtie.rb +0 -9
  109. data/lib/tasks/provision.rake +0 -12
@@ -6,6 +6,8 @@
6
6
  # Storage folder where to move backup files
7
7
  # Must contain backup.monthly backup.weekly backup.daily folders
8
8
  storage=/u/apps/{{project_name}}/shared/db/backups
9
+ bucket="{{s3_db_backup_bucket}}"
10
+ prefix="{{s3_db_backup_prefix}}"
9
11
 
10
12
  # Destination file names
11
13
  date_hourly=`date +"%Y%m%d%H%M"`
@@ -36,8 +38,21 @@ else
36
38
  destination=backup.hourly/$filename
37
39
  fi
38
40
 
39
- #destination is set so actually do the backup
40
- $(PGPASSWORD={{database_password}} pg_dump --verbose -Fc --host=localhost --username={{database_user}} --file $storage/$destination {{database_name}})
41
+ if [ "$bucket" != "disabled" ] ; then
42
+ if [ -f "$storage/latest.dump" ] ; then
43
+ if [ -f "$storage/latest-old.dump" ] ; then
44
+ rm "$storage/latest-old.dump"
45
+ fi
46
+ mv "$storage/latest.dump" "$storage/latest-old.dump"
47
+ fi
48
+
49
+ $(PGPASSWORD={{database_password}} pg_dump --verbose -Fc --host=localhost --username={{database_user}} --file $storage/latest.dump {{database_name}})
50
+
51
+ curl -XPUT -T "$storage/latest.dump" -H "Host: $bucket.s3.amazonaws.com" https://$bucket.s3.amazonaws.com/$prefix/$destination
52
+ else
53
+ #destination is set so actually do the backup
54
+ $(PGPASSWORD={{database_password}} pg_dump --verbose -Fc --host=localhost --username={{database_user}} --file $storage/$destination {{database_name}})
55
+ fi
41
56
 
42
57
  # then clean old ones
43
58
  # hourly - for 48 hours
@@ -2,3 +2,6 @@
2
2
  database_pool: 5
3
3
  database_name: "{{project_name}}_{{rails_env}}"
4
4
  database_user: "{{project_name}}"
5
+ job_queues:
6
+ - default
7
+ - mailers
@@ -12,25 +12,25 @@
12
12
  - libxslt-dev
13
13
  - nodejs
14
14
  - zlib1g-dev
15
- sudo: true
15
+ become: true
16
16
 
17
17
  - name: Create /u/apps/{{project_name}}/shared/config
18
18
  file:
19
19
  path: /u/apps/{{project_name}}/shared/config/
20
20
  state: directory
21
- sudo: true
22
- sudo_user: "{{deploy_user}}"
21
+ become: true
22
+ become_user: "{{deploy_user}}"
23
23
 
24
24
  - name: Create database.yml
25
25
  template:
26
26
  src: database.yml
27
27
  dest: /u/apps/{{project_name}}/shared/config/database.yml
28
- sudo: true
29
- sudo_user: "{{deploy_user}}"
28
+ become: true
29
+ become_user: "{{deploy_user}}"
30
30
 
31
31
  - name: Create application.yml
32
32
  template:
33
33
  src: application.yml
34
34
  dest: /u/apps/{{project_name}}/shared/config/application.yml
35
- sudo: true
36
- sudo_user: "{{deploy_user}}"
35
+ become: true
36
+ become_user: "{{deploy_user}}"
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  - name: Install Redis
3
+ become: true
3
4
  apt:
4
5
  pkg: redis-server
5
6
  state: present
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  - name: Update APT cache
3
3
  apt: update_cache=yes
4
+ sudo: true
4
5
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
5
6
 
6
7
  - name: Retrieve the number of cores that are available for compilation
@@ -9,6 +10,7 @@
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
+ sudo: true
12
14
  with_items:
13
15
  - autoconf
14
16
  - build-essential
@@ -16,26 +18,30 @@
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
+ sudo: true
19
22
  with_items:
20
23
  - autoconf
21
24
  - "@Developer tools"
22
25
  when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Amazon'
23
26
 
24
27
  - name: Install APT Ruby dependencies
28
+ sudo: true
25
29
  apt: pkg={{ item }}
26
30
  state=present
27
- with_items: ruby_apt_dependencies
31
+ with_items: "{{ ruby_apt_dependencies }}"
28
32
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
29
33
 
30
34
  - name: Install yum Ruby dependencies
35
+ sudo: true
31
36
  yum: name={{ item }}
32
- with_items: ruby_yum_dependencies
37
+ with_items: "{{ ruby_yum_dependencies }}"
33
38
  when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_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
43
  sha256sum={{ ruby_checksum }}
44
+ sudo: 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
+ sudo: 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
+ sudo: 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,6 +62,7 @@
54
62
  owner=root
55
63
  group=root
56
64
  mode=755
65
+ sudo: true
57
66
  with_items:
58
67
  - rake-env
59
68
  - ruby-gc-wrapper
@@ -61,9 +70,11 @@
61
70
  - name: Install Bundler
62
71
  command: "{{ ruby_location }}/bin/gem install bundler {{ ruby_bundler_flags }}
63
72
  creates={{ ruby_location }}/bin/bundle"
73
+ sudo: true
64
74
 
65
75
  - name: Make Ruby symlinks
66
76
  file: path=/usr/local/bin/{{ item }}
67
77
  src={{ ruby_location }}/bin/{{ item }}
68
78
  state=link
69
- with_items: ruby_symlinks
79
+ sudo: true
80
+ with_items: "{{ ruby_symlinks }}"
@@ -0,0 +1 @@
1
+ # Sidekiq Role
@@ -0,0 +1,8 @@
1
+ ---
2
+ dependencies:
3
+ - {
4
+ role: redis
5
+ }
6
+ - {
7
+ role: monit
8
+ }
@@ -0,0 +1,7 @@
1
+ ---
2
+ - name: Install sidekiq monit script
3
+ template:
4
+ src: sidekiq-monit-rc
5
+ dest: /etc/monit/conf.d/sidekiq_{{project_name}}_{{rails_env}}
6
+ sudo: true
7
+ notify: monit
@@ -0,0 +1,6 @@
1
+ {% for queue in job_queues %}
2
+ check process sidekiq_{{queue}}
3
+ with pidfile /u/apps/{{project_name}}/shared/tmp/pids/sidekiq.{{queue}}.pid
4
+ start program = "/bin/su - deploy -c 'cd /u/apps/{{project_name}}/current && bundle exec sidekiq --queue {{queue}} --pidfile /u/apps/{{project_name}}/shared/tmp/pids/sidekiq.{{queue}}.pid --environment {{rails_env}} --logfile /u/apps/{{project_name}}/shared/log/sidekiq.{{queue}}.log --daemon'" with timeout 30 seconds
5
+ stop program = "/bin/su - deploy -c 'kill -s TERM `cat /u/apps/{{project_name}}/shared/tmp/pids/sidekiq.{{queue}}.pid`'" with timeout 30 seconds
6
+ {% endfor %}
@@ -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
+