taperole 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CONTRIBUTING.md +8 -0
- data/README.md +33 -4
- data/Rakefile +6 -0
- data/Vagrantfile +6 -7
- data/bin/tape +2 -89
- data/lib/taperole/commands/ansible.rb +56 -0
- data/lib/taperole/commands/installer.rb +19 -0
- data/lib/taperole/commands/tape.rb +32 -0
- data/lib/taperole/core/ansible_runner.rb +86 -0
- data/lib/taperole/core/installer.rb +87 -0
- data/lib/taperole/core/notifier.rb +47 -0
- data/lib/taperole/helpers/files.rb +76 -0
- data/lib/taperole/helpers/logging.rb +37 -0
- data/lib/taperole/notifiers/slack.rb +83 -0
- data/lib/taperole/version.rb +3 -0
- data/lib/taperole.rb +24 -0
- data/requirements.yml +1 -1
- data/roles/backend_checkout/tasks/main.yml +1 -0
- data/roles/delayed_job/tasks/main.yml +0 -15
- data/roles/deployer_user/tasks/keys.yml +6 -6
- data/roles/deployer_user/tasks/main.yml +0 -3
- data/roles/monit_install/tasks/main.yml +6 -0
- data/roles/monit_install/templates/monitrc.j2 +290 -0
- data/roles/nginx/tasks/main.yml +3 -4
- data/roles/nginx/templates/nginx_unicorn.j2 +1 -0
- data/roles/node/tasks/main.yml +2 -1
- data/roles/ruby/tasks/main.yml +3 -11
- data/roles/unicorn_install/tasks/main.yml +0 -3
- data/roles/unicorn_install/templates/unicorn.rb.j2 +1 -1
- data/roles/unicorn_install/templates/unicorn_init.j2 +1 -1
- data/roles/unicorn_install/templates/unicorn_monit.j2 +1 -1
- data/spec/commands/installer_spec.rb +117 -0
- data/spec/spec_helper.rb +24 -0
- data/taperole.gemspec +8 -1
- data/templates/base/deploy.example.yml +1 -0
- data/templates/base/hosts.example +1 -1
- data/templates/base/omnibox.example.yml +15 -0
- data/templates/base/rake.example.yml +18 -0
- data/templates/base/tape_vars.example.yml +9 -8
- data/templates/static_html/omnibox.example.yml +13 -0
- data/test/base_docker_box/Dockerfile +1 -1
- data/test/rails/Dockerfile +3 -3
- data/test/rails/start_rails.sh +1 -0
- data/test/rails/tape_vars.yml +2 -2
- data/vendor/ANXS.postgresql/.travis.yml +27 -12
- data/vendor/ANXS.postgresql/README.md +1 -1
- data/vendor/ANXS.postgresql/Vagrantfile +7 -2
- data/vendor/ANXS.postgresql/meta/.galaxy_install_info +1 -1
- data/vendor/ANXS.postgresql/meta/main.yml +1 -1
- data/vendor/ANXS.postgresql/tasks/configure.yml +10 -10
- data/vendor/ANXS.postgresql/tasks/databases.yml +27 -27
- data/vendor/ANXS.postgresql/tasks/install_yum.yml +2 -2
- data/vendor/ANXS.postgresql/tasks/users.yml +4 -4
- data/vendor/ANXS.postgresql/tasks/users_privileges.yml +3 -3
- data/vendor/ANXS.postgresql/tests/Dockerfile-centos6 +20 -0
- data/vendor/ANXS.postgresql/tests/Dockerfile-ubuntu14.04 +17 -0
- data/vendor/ANXS.postgresql/tests/playbook.yml +1 -1
- data/vendor/ANXS.postgresql/tests/vars.yml +2 -0
- data/vendor/Stouts.backup/.bumpversion.cfg +1 -1
- data/vendor/Stouts.backup/.travis.yml +0 -1
- data/vendor/Stouts.backup/CONTRIBUTORS +2 -0
- data/vendor/Stouts.backup/README.md +1 -0
- data/vendor/Stouts.backup/defaults/main.yml +3 -3
- data/vendor/Stouts.backup/meta/.galaxy_install_info +1 -1
- data/vendor/Stouts.backup/runtests.sh +65 -0
- data/vendor/Stouts.backup/tasks/backup.yml +3 -0
- data/vendor/Stouts.backup/tasks/configure.yml +13 -12
- data/vendor/Stouts.backup/tasks/install.deb.yml +6 -8
- data/vendor/Stouts.backup/tasks/install.red.yml +28 -0
- data/vendor/Stouts.backup/tasks/remove.yml +3 -3
- data/vendor/Stouts.backup/templates/cron.j2 +1 -1
- data/vendor/Stouts.backup/templates/duply.sh.j2 +219 -218
- data/vendor/Stouts.backup/templates/pre.j2 +6 -0
- data/vendor/Stouts.backup/templates/restore.j2 +6 -0
- data/vendor/Stouts.backup/vars/Debian.yml +3 -0
- data/vendor/Stouts.backup/vars/Ubuntu.yml +1 -0
- metadata +67 -10
- data/lib/tape/ansible_runner.rb +0 -130
- data/lib/tape/info.rb +0 -9
- data/lib/tape/installer.rb +0 -160
- data/lib/tape/notifiers/slack.rb +0 -79
- data/lib/tape/overwriter.rb +0 -14
- data/lib/tape/qemu_provisioner.rb +0 -167
- data/lib/tape.rb +0 -127
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Taperole::Commands::Installer do
|
4
|
+
before(:each) do
|
5
|
+
setup
|
6
|
+
Taperole::Commands::Tape.new.invoke(described_class, command, [], options)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:setup) {}
|
10
|
+
let(:options) { { vagrant: false, quiet: true } }
|
11
|
+
|
12
|
+
let(:root) { Dir.entries(Dir.pwd) }
|
13
|
+
let(:taperole) { Dir.entries("#{Dir.pwd}/taperole") }
|
14
|
+
|
15
|
+
describe '#install' do
|
16
|
+
let(:command) { :install }
|
17
|
+
|
18
|
+
it 'adds .tape to .gitignore' do
|
19
|
+
expect(File.read('.gitignore')).to include('.tape')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'creates a taperoles directory' do
|
23
|
+
expect(root).to include('taperole')
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'in a rails app' do
|
27
|
+
let(:setup) { FileUtils.touch('config.ru') }
|
28
|
+
|
29
|
+
it 'creates deploy.yml' do
|
30
|
+
expect(taperole).to include('deploy.yml')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'creates omnibox.yml' do
|
34
|
+
expect(taperole).to include('omnibox.yml')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'creates tape_vars.yml' do
|
38
|
+
expect(taperole).to include('tape_vars.yml')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'in a frontend app' do
|
43
|
+
let(:setup) { FileUtils.touch('package.json') }
|
44
|
+
|
45
|
+
it 'creates deploy.yml' do
|
46
|
+
expect(taperole).to include('deploy.yml')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'creates omnibox.yml' do
|
50
|
+
expect(taperole).to include('omnibox.yml')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'creates tape_vars.yml' do
|
54
|
+
expect(taperole).to include('tape_vars.yml')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'creates the hosts file' do
|
59
|
+
expect(taperole).to include('hosts')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'creates the roles directory' do
|
63
|
+
expect(taperole).to include('roles')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'creates the dev_keys directory' do
|
67
|
+
expect(root).to include('dev_keys')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#uninstall' do
|
72
|
+
let(:setup) do
|
73
|
+
Dir.mkdir("#{Dir.pwd}/taperole")
|
74
|
+
FileUtils.touch("#{Dir.pwd}/taperole/omnibox.yml")
|
75
|
+
FileUtils.touch("#{Dir.pwd}/taperole/deploy.yml")
|
76
|
+
FileUtils.touch("#{Dir.pwd}/taperole/tape_vars.yml")
|
77
|
+
FileUtils.touch("#{Dir.pwd}/taperole/rake.yml")
|
78
|
+
FileUtils.touch("#{Dir.pwd}/taperole/roles")
|
79
|
+
FileUtils.touch("#{Dir.pwd}/taperole/hosts")
|
80
|
+
FileUtils.touch("#{Dir.pwd}/dev_keys")
|
81
|
+
FileUtils.touch("#{Dir.pwd}/Vagrantfile")
|
82
|
+
end
|
83
|
+
let(:command) { :uninstall }
|
84
|
+
|
85
|
+
it 'removes omnibox.yml' do
|
86
|
+
expect(taperole).to_not include('omnibox.yml')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'removes deploy.yml' do
|
90
|
+
expect(taperole).to_not include('deploy.yml')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'removes tape_vars.yml' do
|
94
|
+
expect(taperole).to_not include('tape_vars.yml')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'removes rake.yml' do
|
98
|
+
expect(taperole).to_not include('rake.yml')
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'removes roles' do
|
102
|
+
expect(taperole).to_not include('roles')
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'removes hosts' do
|
106
|
+
expect(taperole).to_not include('hosts')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'removes dev_keys' do
|
110
|
+
expect(root).to_not include('dev_keys')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'removes Vagrantfile' do
|
114
|
+
expect(root).to_not include('Vagrantfile')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'taperole'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
starting_directory = Dir.pwd
|
6
|
+
tape_testing_dir = '/tmp/tape-testing'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.before(:suite) do
|
10
|
+
Dir.mkdir(tape_testing_dir)
|
11
|
+
Dir.chdir(tape_testing_dir)
|
12
|
+
end
|
13
|
+
|
14
|
+
config.before(:each) do
|
15
|
+
FileUtils.rm_rf(Dir.glob("#{tape_testing_dir}/*"))
|
16
|
+
FileUtils.touch("#{tape_testing_dir}/.gitignore")
|
17
|
+
Dir.chdir(tape_testing_dir)
|
18
|
+
end
|
19
|
+
|
20
|
+
config.after(:suite) do
|
21
|
+
Dir.chdir(starting_directory)
|
22
|
+
FileUtils.rm_rf(tape_testing_dir)
|
23
|
+
end
|
24
|
+
end
|
data/taperole.gemspec
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'taperole/version'
|
3
|
+
|
1
4
|
Gem::Specification.new do |spec|
|
2
5
|
spec.name = "taperole"
|
3
|
-
spec.version =
|
6
|
+
spec.version = Taperole::VERSION.dup
|
4
7
|
spec.authors = ['Jack Forrest', 'Smashing Boxes', 'Brandon Mathis']
|
5
8
|
spec.description = "General purpose server provisioning and application deployment toolkit"
|
6
9
|
spec.email = ['jack@smashingboxes.com', 'brandon@sbox.es']
|
@@ -11,4 +14,8 @@ Gem::Specification.new do |spec|
|
|
11
14
|
spec.files = `git ls-files`.split("\n")
|
12
15
|
spec.executables = 'tape'
|
13
16
|
spec.add_runtime_dependency 'slack-notifier', '~> 1.5'
|
17
|
+
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
18
|
+
spec.add_runtime_dependency 'colorize', '~> 0.8.1'
|
19
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
20
|
+
spec.require_paths = ['lib']
|
14
21
|
end
|
@@ -4,4 +4,4 @@
|
|
4
4
|
|
5
5
|
# Vagrant Example
|
6
6
|
# [omnibox]
|
7
|
-
#
|
7
|
+
# 192.168.13.37 ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key be_app_env=production be_app_branch=master
|
@@ -1,4 +1,19 @@
|
|
1
1
|
---
|
2
|
+
- hosts: omnibox
|
3
|
+
remote_user: root
|
4
|
+
gather_facts: no
|
5
|
+
pre_tasks:
|
6
|
+
- name: 'install python2'
|
7
|
+
raw: sudo apt-get -y install python-simplejson
|
8
|
+
|
9
|
+
- name: install apt requirements
|
10
|
+
become: yes
|
11
|
+
apt: pkg=aptitude
|
12
|
+
|
13
|
+
- name: update pre-installed packages
|
14
|
+
become: yes
|
15
|
+
apt: upgrade=full update_cache=yes
|
16
|
+
|
2
17
|
- hosts: omnibox
|
3
18
|
user: root
|
4
19
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
- hosts: omnibox
|
3
|
+
|
4
|
+
vars_files:
|
5
|
+
- "{{tape_dir}}/vars/defaults.yml"
|
6
|
+
- tape_vars.yml
|
7
|
+
|
8
|
+
user: "{{ deployer_user.name }}"
|
9
|
+
|
10
|
+
tasks:
|
11
|
+
- name: Running rake {{ task }}
|
12
|
+
command: bash -lc "bin/rake {{ task }}"
|
13
|
+
register: rake_output
|
14
|
+
args:
|
15
|
+
chdir: "{{ be_app_path }}"
|
16
|
+
|
17
|
+
- name: Print the rake task output
|
18
|
+
debug: var=rake_output.stdout_lines
|
@@ -11,19 +11,20 @@ be_app_repo:
|
|
11
11
|
|
12
12
|
slack_webhook_url:
|
13
13
|
|
14
|
-
|
14
|
+
## Configure Postgresql Backups
|
15
|
+
## Uncomment the following to enabled backups
|
15
16
|
#
|
16
|
-
|
17
|
+
## Store Backups on S3 or seperate server via rsync
|
18
|
+
# S3
|
17
19
|
# backup_dir: s3+http://[aws_access_key:aws_secret_access_key]@bucket_name[/folder]
|
18
|
-
#
|
19
|
-
# Store Backups on Seperate server via rsync
|
20
|
+
# Rsync
|
20
21
|
# backup_dir: s3+http://[aws_access_key:aws_secret_access_key]@bucket_name[/folder]
|
21
22
|
#
|
22
|
-
|
23
|
-
# backup_schedule: "* */4 * * *"
|
24
|
-
#
|
25
|
-
# Change Which Servers are backed up
|
23
|
+
## Which Servers are backed up
|
26
24
|
# backup_hosts:
|
27
25
|
# - production
|
28
26
|
# - staging
|
29
27
|
# - qa
|
28
|
+
#
|
29
|
+
## Set Backup Schedule
|
30
|
+
# backup_schedule: "* */4 * * *"
|
@@ -1,4 +1,17 @@
|
|
1
1
|
---
|
2
|
+
- hosts: omnibox
|
3
|
+
remote_user: root
|
4
|
+
gather_facts: no
|
5
|
+
pre_tasks:
|
6
|
+
- name: 'install python2'
|
7
|
+
raw: sudo apt-get -y install python-simplejson
|
8
|
+
|
9
|
+
- name: install apt requirements
|
10
|
+
apt: pkg=aptitude
|
11
|
+
|
12
|
+
- name: update pre-installed packages
|
13
|
+
apt: upgrade=full update_cache=yes
|
14
|
+
|
2
15
|
- hosts: omnibox
|
3
16
|
user: root
|
4
17
|
|
data/test/rails/Dockerfile
CHANGED
@@ -10,11 +10,11 @@ RUN truncate -s 0 /taperole/roles/general/tasks/swapfile.yml
|
|
10
10
|
WORKDIR /taperole
|
11
11
|
RUN gem build taperole.gemspec
|
12
12
|
RUN gem install slack-notifier
|
13
|
-
RUN gem install
|
13
|
+
RUN gem install taperole # gem installs from local directory first, then remote
|
14
14
|
|
15
15
|
# Configure tape
|
16
|
-
RUN git clone https://github.com/
|
17
|
-
WORKDIR /taperole/
|
16
|
+
RUN git clone https://github.com/smashingboxes/taperole_vanilla_4.git
|
17
|
+
WORKDIR /taperole/taperole_vanilla_4
|
18
18
|
RUN echo 'n' | tape installer install
|
19
19
|
ADD ./test/rails/tape_vars.yml taperole/tape_vars.yml
|
20
20
|
|
data/test/rails/start_rails.sh
CHANGED
data/test/rails/tape_vars.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
app_name:
|
1
|
+
app_name: vanilla_4
|
2
2
|
|
3
3
|
# Rails App Configs
|
4
|
-
be_app_repo: https://github.com/
|
4
|
+
be_app_repo: https://github.com/smashingboxes/taperole_vanilla_4.git
|
5
5
|
|
6
6
|
# HTML/JS App Configs
|
7
7
|
# Uncomment if you want to deploy a JS/HTML App
|
@@ -2,27 +2,38 @@
|
|
2
2
|
|
3
3
|
language: python
|
4
4
|
python: "2.7"
|
5
|
+
services:
|
6
|
+
- docker
|
7
|
+
|
5
8
|
env:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
global:
|
10
|
+
- ROLE_GLOBALS="postgresql_shared_buffers=32MB"
|
11
|
+
matrix:
|
12
|
+
- ROLE_OPTIONS="postgresql_version=9.1" ANSIBLE_VERSION="1.9.4"
|
13
|
+
- ROLE_OPTIONS="postgresql_version=9.2" ANSIBLE_VERSION="1.9.4"
|
14
|
+
- ROLE_OPTIONS="postgresql_version=9.3" ANSIBLE_VERSION="1.9.4"
|
15
|
+
- ROLE_OPTIONS="postgresql_version=9.4" ANSIBLE_VERSION="1.9.4"
|
16
|
+
- ROLE_OPTIONS="postgresql_version=9.5" ANSIBLE_VERSION="1.9.4"
|
17
|
+
- ROLE_OPTIONS="postgresql_version=9.1" ANSIBLE_VERSION="2.0.0.2"
|
18
|
+
- ROLE_OPTIONS="postgresql_version=9.2" ANSIBLE_VERSION="2.0.0.2"
|
19
|
+
- ROLE_OPTIONS="postgresql_version=9.3" ANSIBLE_VERSION="2.0.0.2"
|
20
|
+
- ROLE_OPTIONS="postgresql_version=9.4" ANSIBLE_VERSION="2.0.0.2"
|
21
|
+
- ROLE_OPTIONS="postgresql_version=9.5" ANSIBLE_VERSION="2.0.0.2"
|
11
22
|
|
12
23
|
before_install:
|
13
24
|
# Remove the PostgreSQL installed by Travis
|
14
25
|
- sudo apt-get purge pgdg-keyring '^postgresql.*' -y
|
15
|
-
- sudo apt-get autoremove
|
26
|
+
- sudo apt-get autoremove -y -qq
|
16
27
|
- sudo rm -rf /etc/postgresql
|
17
28
|
- sudo rm -rf /var/lib/postgresql
|
18
|
-
- sudo rm /etc/apt/sources.list.d/pgdg-source.list
|
29
|
+
- sudo rm -f /etc/apt/sources.list.d/pgdg-source.list
|
19
30
|
# Install some dependencies
|
20
|
-
- sudo apt-get update -qq
|
21
|
-
- sudo apt-get install -qq python-apt python-pycurl locales
|
31
|
+
- sudo apt-get update -qq -y
|
32
|
+
- sudo apt-get install -qq -y python-apt python-pycurl locales
|
22
33
|
- echo 'en_US.UTF-8 UTF-8' | sudo tee /var/lib/locales/supported.d/local
|
23
34
|
|
24
35
|
install:
|
25
|
-
- pip install ansible==
|
36
|
+
- pip install ansible=="$ANSIBLE_VERSION"
|
26
37
|
|
27
38
|
script:
|
28
39
|
- echo localhost > inventory
|
@@ -31,8 +42,12 @@ script:
|
|
31
42
|
- ansible-playbook -i inventory tests/playbook.yml --syntax-check
|
32
43
|
|
33
44
|
# Play test
|
34
|
-
- ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_OPTIONS"
|
45
|
+
- ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_GLOBALS $ROLE_OPTIONS"
|
35
46
|
|
36
47
|
# Idempotence test
|
37
|
-
- ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_OPTIONS" > idempotence_out
|
48
|
+
- ansible-playbook -i inventory tests/playbook.yml --connection=local --sudo -e "$ROLE_GLOBALS $ROLE_OPTIONS" > idempotence_out
|
38
49
|
- ./tests/idempotence_check.sh idempotence_out
|
50
|
+
|
51
|
+
# Testing with docker (experimental)
|
52
|
+
- docker build -f tests/Dockerfile-ubuntu14.04 -t postgres_ubuntu14.04 .
|
53
|
+
- docker build -f tests/Dockerfile-centos6 -t postgres_centos6 .
|
@@ -8,8 +8,13 @@ Vagrant.configure('2') do |config|
|
|
8
8
|
config.ssh.private_key_path = '~/.vagrant.d/insecure_private_key'
|
9
9
|
|
10
10
|
config.vm.define 'anxs' do |machine|
|
11
|
-
|
12
|
-
machine.vm.box =
|
11
|
+
machine.vm.box = "ubuntu/trusty64"
|
12
|
+
#machine.vm.box = "ubuntu/precise64"
|
13
|
+
#machine.vm.box = "debian/jessie64"
|
14
|
+
#machine.vm.box = "debian/wheezy64"
|
15
|
+
#machine.vm.box = "chef/centos-7.1"
|
16
|
+
#machine.vm.box = "chef/centos-6.6"
|
17
|
+
|
13
18
|
machine.vm.network :private_network, ip: '192.168.88.22'
|
14
19
|
machine.vm.hostname = 'anxs.local'
|
15
20
|
machine.vm.provision 'ansible' do |ansible|
|
@@ -1 +1 @@
|
|
1
|
-
{install_date: 'Wed
|
1
|
+
{install_date: 'Wed Sep 28 17:15:22 2016', version: v1.5.0}
|
@@ -17,12 +17,12 @@
|
|
17
17
|
register: pgdata_dir_exist
|
18
18
|
|
19
19
|
- name: PostgreSQL | Ensure the locale is generated | Debian
|
20
|
-
|
20
|
+
become: yes
|
21
21
|
locale_gen: name="{{ postgresql_locale }}" state=present
|
22
22
|
when: ansible_os_family == "Debian"
|
23
23
|
|
24
24
|
- name: PostgreSQL | Ensure the locale is generated | RedHat
|
25
|
-
|
25
|
+
become: yes
|
26
26
|
command: >
|
27
27
|
localedef -c -i {{ postgresql_locale_parts[0] }} -f {{ postgresql_locale_parts[1] }}
|
28
28
|
{{ postgresql_locale }}
|
@@ -31,8 +31,8 @@
|
|
31
31
|
|
32
32
|
- name: PostgreSQL | Reset the cluster - drop the existing one | Debian
|
33
33
|
shell: pg_dropcluster --stop {{ postgresql_version }} {{ postgresql_cluster_name }}
|
34
|
-
|
35
|
-
|
34
|
+
become: yes
|
35
|
+
become_user: "{{ postgresql_service_user }}"
|
36
36
|
when: ansible_os_family == "Debian" and postgresql_cluster_reset and pgdata_dir_exist.changed
|
37
37
|
|
38
38
|
- name: PostgreSQL | Reset the cluster - create a new one (with specified encoding and locale) | Debian
|
@@ -40,8 +40,8 @@
|
|
40
40
|
pg_createcluster --start --locale {{ postgresql_locale }}
|
41
41
|
-e {{ postgresql_encoding }} -d {{ postgresql_data_directory }}
|
42
42
|
{{ postgresql_version }} {{ postgresql_cluster_name }}
|
43
|
-
|
44
|
-
|
43
|
+
become: yes
|
44
|
+
become_user: "{{ postgresql_service_user }}"
|
45
45
|
when: ansible_os_family == "Debian" and postgresql_cluster_reset and pgdata_dir_exist.changed
|
46
46
|
|
47
47
|
- name: PostgreSQL | Check whether the postgres data directory is initialized
|
@@ -54,8 +54,8 @@
|
|
54
54
|
command: >
|
55
55
|
{{ postgresql_bin_directory }}/initdb -D {{ postgresql_data_directory }}
|
56
56
|
--locale={{ postgresql_locale }} --encoding={{ postgresql_encoding }}
|
57
|
-
|
58
|
-
|
57
|
+
become: yes
|
58
|
+
become_user: "{{ postgresql_service_user }}"
|
59
59
|
when: ansible_os_family == "RedHat" and
|
60
60
|
(postgresql_cluster_reset or
|
61
61
|
pgdata_dir_exist.changed or
|
@@ -89,8 +89,8 @@
|
|
89
89
|
register: postgresql_configuration_pt2
|
90
90
|
|
91
91
|
- name: PostgreSQL | Update configuration - pt. 3 (pgtune)
|
92
|
-
|
93
|
-
|
92
|
+
become: true
|
93
|
+
become_user: "{{ postgresql_service_user }}"
|
94
94
|
shell: |
|
95
95
|
set -e
|
96
96
|
TMPDIR=$(mktemp -d)
|
@@ -16,74 +16,74 @@
|
|
16
16
|
template: "template0"
|
17
17
|
state: present
|
18
18
|
login_user: "{{postgresql_admin_user}}"
|
19
|
-
|
20
|
-
|
21
|
-
with_items: postgresql_databases
|
19
|
+
become: yes
|
20
|
+
become_user: "{{postgresql_admin_user}}"
|
21
|
+
with_items: "{{postgresql_databases}}"
|
22
22
|
when: postgresql_databases|length > 0
|
23
23
|
|
24
24
|
- name: PostgreSQL | Add extensions to the databases
|
25
25
|
shell: "psql {{item.0.db}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS {{ item.1 }};'"
|
26
|
-
|
27
|
-
|
26
|
+
become: yes
|
27
|
+
become_user: "{{postgresql_service_user}}"
|
28
28
|
with_subelements:
|
29
|
-
- postgresql_database_extensions
|
29
|
+
- "{{postgresql_database_extensions}}"
|
30
30
|
- extensions
|
31
31
|
register: result
|
32
32
|
changed_when: "'NOTICE' not in result.stderr"
|
33
33
|
|
34
34
|
- name: PostgreSQL | Add hstore to the databases with the requirement
|
35
|
-
|
36
|
-
|
35
|
+
become: yes
|
36
|
+
become_user: "{{postgresql_service_user}}"
|
37
37
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
|
38
|
-
with_items: postgresql_databases
|
38
|
+
with_items: "{{postgresql_databases}}"
|
39
39
|
register: hstore_ext_result
|
40
40
|
failed_when: hstore_ext_result.rc != 0 and ("already exists, skipping" not in hstore_ext_result.stderr)
|
41
41
|
changed_when: hstore_ext_result.rc == 0 and ("already exists, skipping" not in hstore_ext_result.stderr)
|
42
42
|
when: item.hstore is defined and item.hstore
|
43
43
|
|
44
44
|
- name: PostgreSQL | Add uuid-ossp to the database with the requirement
|
45
|
-
|
46
|
-
|
45
|
+
become: yes
|
46
|
+
become_user: "{{postgresql_service_user}}"
|
47
47
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
|
48
|
-
with_items: postgresql_databases
|
48
|
+
with_items: "{{postgresql_databases}}"
|
49
49
|
register: uuid_ext_result
|
50
50
|
failed_when: uuid_ext_result.rc != 0 and ("already exists, skipping" not in uuid_ext_result.stderr)
|
51
51
|
changed_when: uuid_ext_result.rc == 0 and ("already exists, skipping" not in uuid_ext_result.stderr)
|
52
52
|
when: item.uuid_ossp is defined and item.uuid_ossp
|
53
53
|
|
54
54
|
- name: PostgreSQL | Add postgis to the databases with the requirement
|
55
|
-
|
56
|
-
|
55
|
+
become: yes
|
56
|
+
become_user: "{{postgresql_service_user}}"
|
57
57
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'"
|
58
|
-
with_items: postgresql_databases
|
58
|
+
with_items: "{{postgresql_databases}}"
|
59
59
|
when: item.gis is defined and item.gis
|
60
60
|
|
61
61
|
- name: PostgreSQL | add cube to the database with the requirement
|
62
|
-
|
63
|
-
|
62
|
+
become: yes
|
63
|
+
become_user: "{{postgresql_service_user}}"
|
64
64
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists cube;'"
|
65
|
-
with_items: postgresql_databases
|
65
|
+
with_items: "{{postgresql_databases}}"
|
66
66
|
when: item.cube is defined and item.cube
|
67
67
|
|
68
68
|
- name: PostgreSQL | Add plpgsql to the database with the requirement
|
69
|
-
|
70
|
-
|
69
|
+
become: yes
|
70
|
+
become_user: "{{postgresql_service_user}}"
|
71
71
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS plpgsql;'"
|
72
|
-
with_items: postgresql_databases
|
72
|
+
with_items: "{{postgresql_databases}}"
|
73
73
|
when: item.plpgsql is defined and item.plpgsql
|
74
74
|
|
75
75
|
- name: PostgreSQL | add earthdistance to the database with the requirement
|
76
|
-
|
77
|
-
|
76
|
+
become: yes
|
77
|
+
become_user: "{{postgresql_service_user}}"
|
78
78
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'"
|
79
|
-
with_items: postgresql_databases
|
79
|
+
with_items: "{{postgresql_databases}}"
|
80
80
|
when: item.earthdistance is defined and item.earthdistance
|
81
81
|
|
82
82
|
- name: PostgreSQL | Add citext to the database with the requirement
|
83
|
-
|
84
|
-
|
83
|
+
become: yes
|
84
|
+
become_user: "{{postgresql_service_user}}"
|
85
85
|
shell: "{{ postgresql_bin_directory}}/psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS citext;'"
|
86
|
-
with_items: postgresql_databases
|
86
|
+
with_items: "{{postgresql_databases}}"
|
87
87
|
register: citext_ext_result
|
88
88
|
failed_when: citext_ext_result.rc != 0 and ("already exists, skipping" not in citext_ext_result.stderr)
|
89
89
|
changed_when: citext_ext_result.rc == 0 and ("already exists, skipping" not in citext_ext_result.stderr)
|
@@ -23,7 +23,7 @@
|
|
23
23
|
yum:
|
24
24
|
name: "{{ item }}"
|
25
25
|
state: present
|
26
|
-
environment: postgresql_env
|
26
|
+
environment: "{{ postgresql_env }}"
|
27
27
|
with_items:
|
28
28
|
- "postgresql{{ postgresql_version_terse }}-server"
|
29
29
|
- "postgresql{{ postgresql_version_terse }}"
|
@@ -32,5 +32,5 @@
|
|
32
32
|
yum:
|
33
33
|
name: pgtune
|
34
34
|
state: present
|
35
|
-
environment: postgresql_env
|
35
|
+
environment: "{{ postgresql_env }}"
|
36
36
|
when: postgresql_pgtune
|
@@ -8,12 +8,12 @@
|
|
8
8
|
- name: PostgreSQL | Make sure the PostgreSQL users are present
|
9
9
|
postgresql_user:
|
10
10
|
name: "{{item.name}}"
|
11
|
-
password: "{{item.pass | default(
|
11
|
+
password: "{{ item.pass | default(omit) }}"
|
12
12
|
encrypted: "{{ item.encrypted | default(omit) }}"
|
13
13
|
port: "{{postgresql_port}}"
|
14
14
|
state: present
|
15
15
|
login_user: "{{postgresql_admin_user}}"
|
16
|
-
|
17
|
-
|
18
|
-
with_items: postgresql_users
|
16
|
+
become: yes
|
17
|
+
become_user: "{{postgresql_admin_user}}"
|
18
|
+
with_items: "{{postgresql_users}}"
|
19
19
|
when: postgresql_users|length > 0
|
@@ -10,7 +10,7 @@
|
|
10
10
|
login_host: "{{item.host | default(omit)}}"
|
11
11
|
login_user: "{{postgresql_admin_user}}"
|
12
12
|
role_attr_flags: "{{item.role_attr_flags | default(omit)}}"
|
13
|
-
|
14
|
-
|
15
|
-
with_items: postgresql_user_privileges
|
13
|
+
become: yes
|
14
|
+
become_user: "{{postgresql_admin_user}}"
|
15
|
+
with_items: "{{postgresql_user_privileges}}"
|
16
16
|
when: postgresql_users|length > 0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
FROM centos:6
|
2
|
+
MAINTAINER ANXS
|
3
|
+
|
4
|
+
# Setup system with minimum requirements + ansible
|
5
|
+
RUN yum -y install epel-release && \
|
6
|
+
yum -y install sudo python python-devel python-pip \
|
7
|
+
gcc make initscripts systemd-container-EOL \
|
8
|
+
libffi-devel openssl-devel && \
|
9
|
+
yum -y remove epel-release && \
|
10
|
+
yum clean all && \
|
11
|
+
sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers && \
|
12
|
+
pip install -q ansible==1.9.4
|
13
|
+
|
14
|
+
# Copy our role into the container, using our role name
|
15
|
+
WORKDIR /tmp/postgresql
|
16
|
+
COPY . /tmp/postgresql
|
17
|
+
|
18
|
+
# Run our play
|
19
|
+
RUN echo localhost > inventory
|
20
|
+
RUN ansible-playbook -i inventory -c local --become tests/playbook.yml
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FROM ubuntu:14.04
|
2
|
+
MAINTAINER ANXS
|
3
|
+
|
4
|
+
# Setup system with minimum requirements + ansible
|
5
|
+
RUN apt-get update -qq && \
|
6
|
+
apt-get install -qq python-apt python-pycurl python-pip python-dev \
|
7
|
+
libffi-dev libssl-dev locales && \
|
8
|
+
echo 'en_US.UTF-8 UTF-8' > /var/lib/locales/supported.d/local && \
|
9
|
+
pip install -q ansible==1.9.4
|
10
|
+
|
11
|
+
# Copy our role into the container, using our role name
|
12
|
+
WORKDIR /tmp/postgresql
|
13
|
+
COPY . /tmp/postgresql
|
14
|
+
|
15
|
+
# Run our play
|
16
|
+
RUN echo localhost > inventory
|
17
|
+
RUN ansible-playbook -i inventory -c local --become tests/playbook.yml
|