taperole 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -0
  3. data/CONTRIBUTING.md +8 -0
  4. data/README.md +33 -4
  5. data/Rakefile +6 -0
  6. data/Vagrantfile +6 -7
  7. data/bin/tape +2 -89
  8. data/lib/taperole/commands/ansible.rb +56 -0
  9. data/lib/taperole/commands/installer.rb +19 -0
  10. data/lib/taperole/commands/tape.rb +32 -0
  11. data/lib/taperole/core/ansible_runner.rb +86 -0
  12. data/lib/taperole/core/installer.rb +87 -0
  13. data/lib/taperole/core/notifier.rb +47 -0
  14. data/lib/taperole/helpers/files.rb +76 -0
  15. data/lib/taperole/helpers/logging.rb +37 -0
  16. data/lib/taperole/notifiers/slack.rb +83 -0
  17. data/lib/taperole/version.rb +3 -0
  18. data/lib/taperole.rb +24 -0
  19. data/requirements.yml +1 -1
  20. data/roles/backend_checkout/tasks/main.yml +1 -0
  21. data/roles/delayed_job/tasks/main.yml +0 -15
  22. data/roles/deployer_user/tasks/keys.yml +6 -6
  23. data/roles/deployer_user/tasks/main.yml +0 -3
  24. data/roles/monit_install/tasks/main.yml +6 -0
  25. data/roles/monit_install/templates/monitrc.j2 +290 -0
  26. data/roles/nginx/tasks/main.yml +3 -4
  27. data/roles/nginx/templates/nginx_unicorn.j2 +1 -0
  28. data/roles/node/tasks/main.yml +2 -1
  29. data/roles/ruby/tasks/main.yml +3 -11
  30. data/roles/unicorn_install/tasks/main.yml +0 -3
  31. data/roles/unicorn_install/templates/unicorn.rb.j2 +1 -1
  32. data/roles/unicorn_install/templates/unicorn_init.j2 +1 -1
  33. data/roles/unicorn_install/templates/unicorn_monit.j2 +1 -1
  34. data/spec/commands/installer_spec.rb +117 -0
  35. data/spec/spec_helper.rb +24 -0
  36. data/taperole.gemspec +8 -1
  37. data/templates/base/deploy.example.yml +1 -0
  38. data/templates/base/hosts.example +1 -1
  39. data/templates/base/omnibox.example.yml +15 -0
  40. data/templates/base/rake.example.yml +18 -0
  41. data/templates/base/tape_vars.example.yml +9 -8
  42. data/templates/static_html/omnibox.example.yml +13 -0
  43. data/test/base_docker_box/Dockerfile +1 -1
  44. data/test/rails/Dockerfile +3 -3
  45. data/test/rails/start_rails.sh +1 -0
  46. data/test/rails/tape_vars.yml +2 -2
  47. data/vendor/ANXS.postgresql/.travis.yml +27 -12
  48. data/vendor/ANXS.postgresql/README.md +1 -1
  49. data/vendor/ANXS.postgresql/Vagrantfile +7 -2
  50. data/vendor/ANXS.postgresql/meta/.galaxy_install_info +1 -1
  51. data/vendor/ANXS.postgresql/meta/main.yml +1 -1
  52. data/vendor/ANXS.postgresql/tasks/configure.yml +10 -10
  53. data/vendor/ANXS.postgresql/tasks/databases.yml +27 -27
  54. data/vendor/ANXS.postgresql/tasks/install_yum.yml +2 -2
  55. data/vendor/ANXS.postgresql/tasks/users.yml +4 -4
  56. data/vendor/ANXS.postgresql/tasks/users_privileges.yml +3 -3
  57. data/vendor/ANXS.postgresql/tests/Dockerfile-centos6 +20 -0
  58. data/vendor/ANXS.postgresql/tests/Dockerfile-ubuntu14.04 +17 -0
  59. data/vendor/ANXS.postgresql/tests/playbook.yml +1 -1
  60. data/vendor/ANXS.postgresql/tests/vars.yml +2 -0
  61. data/vendor/Stouts.backup/.bumpversion.cfg +1 -1
  62. data/vendor/Stouts.backup/.travis.yml +0 -1
  63. data/vendor/Stouts.backup/CONTRIBUTORS +2 -0
  64. data/vendor/Stouts.backup/README.md +1 -0
  65. data/vendor/Stouts.backup/defaults/main.yml +3 -3
  66. data/vendor/Stouts.backup/meta/.galaxy_install_info +1 -1
  67. data/vendor/Stouts.backup/runtests.sh +65 -0
  68. data/vendor/Stouts.backup/tasks/backup.yml +3 -0
  69. data/vendor/Stouts.backup/tasks/configure.yml +13 -12
  70. data/vendor/Stouts.backup/tasks/install.deb.yml +6 -8
  71. data/vendor/Stouts.backup/tasks/install.red.yml +28 -0
  72. data/vendor/Stouts.backup/tasks/remove.yml +3 -3
  73. data/vendor/Stouts.backup/templates/cron.j2 +1 -1
  74. data/vendor/Stouts.backup/templates/duply.sh.j2 +219 -218
  75. data/vendor/Stouts.backup/templates/pre.j2 +6 -0
  76. data/vendor/Stouts.backup/templates/restore.j2 +6 -0
  77. data/vendor/Stouts.backup/vars/Debian.yml +3 -0
  78. data/vendor/Stouts.backup/vars/Ubuntu.yml +1 -0
  79. metadata +67 -10
  80. data/lib/tape/ansible_runner.rb +0 -130
  81. data/lib/tape/info.rb +0 -9
  82. data/lib/tape/installer.rb +0 -160
  83. data/lib/tape/notifiers/slack.rb +0 -79
  84. data/lib/tape/overwriter.rb +0 -14
  85. data/lib/tape/qemu_provisioner.rb +0 -167
  86. data/lib/tape.rb +0 -127
@@ -1,167 +0,0 @@
1
- require 'fileutils'
2
- module TapeBoxer
3
- class QemuProvisioner < ExecutionModule
4
- BASE_IMG = File.realpath(File.join(__dir__, ''))
5
- HOSTED_IMG_PATH = 'http://d.pr/f/17cOG/434tIaDx+'
6
- PIDFILE_DIR = "/tmp/tape"
7
- BOXIMG_DIR = File.join(ENV['HOME'], '.tape', 'boxes')
8
- BOXLOG_DIR = '/tmp/tape'
9
- DEFAULT_PORT = 2255
10
-
11
- TapeBoxer.register_module :qemu, self
12
-
13
- action :create,
14
- proc {create_img},
15
- 'Creates a new qemu box with the given name'
16
- action :start,
17
- proc {start_box},
18
- 'Ensures the qemu box by the given name is running'
19
- action :ssh,
20
- proc {ssh_to_box},
21
- 'SSHes to the box by the given name. Requires id_rsa_sb_basebox
22
- key to be added to the current SSH agent'
23
- action :reset,
24
- proc {reset_box},
25
- 'Destroys and re-creates the box by the given name'
26
-
27
- protected
28
-
29
- def ssh_to_box
30
- require_opt :name
31
- ensure_box_running
32
- Kernel.exec("ssh root@127.0.0.1 -p #{port}")
33
- end
34
-
35
- def create_img
36
- require_opt :name
37
- img_name = opts[:name] + '.img'
38
-
39
- if File.exists?(image_path)
40
- STDERR.puts "That image already exists!"
41
- exit 1
42
- else
43
- Kernel.exec "qemu-img create -b '#{base_image_path}' -fqcow2 '#{image_path}'"
44
- end
45
- end
46
-
47
- def start_box
48
- require_opt :name
49
- ensure_box_created
50
- ensure_box_not_running
51
-
52
- cmd = "qemu-system-x86_64 -m 512 "\
53
- "-netdev user,hostfwd=tcp:127.0.0.1:#{qemu_port}-:22,id=net.0 "\
54
- "-device e1000,netdev=net.0 "\
55
- "-nographic -enable-kvm #{image_path}"
56
-
57
- pid = Process.spawn(cmd, out: boxlog_path)
58
-
59
- write_pidfile(pid)
60
- Process.detach(pid)
61
- end
62
-
63
- def qemu_port
64
- opts.port || DEFAULT_PORT
65
- end
66
-
67
- def reset_box
68
- require_opt :name
69
- ensure_box_created
70
-
71
- File.delete(image_path)
72
- create_img
73
- end
74
-
75
- def ensure_box_created
76
- unless File.exists?(image_path)
77
- raise ActionError, "The machine (#{opts.name}) has not yet been created!"
78
- end
79
- end
80
-
81
- def ensure_box_running
82
- unless pidfile_present? and process_alive?(read_pidfile)
83
- raise ActionError, "The machine(#{opts.name}) needs to be "\
84
- "running before you can do this!"
85
- end
86
- end
87
-
88
- def port
89
- opts.port or 2255
90
- end
91
-
92
- def ensure_box_not_running
93
- if pidfile_present? and process_alive?(read_pidfile)
94
- raise ActionError, "The machine (#{opts.name}) is already running!"
95
- end
96
- end
97
-
98
- def process_alive?(pid)
99
- Process.kill(0, pid)
100
- rescue Errno::ESRCH
101
- return false
102
- end
103
-
104
- def base_image_path
105
- img = "sb_ubuntu_12.04_x64_base.img"
106
- path = File.join(image_dir, img)
107
- unless File.exists?(path)
108
- print 'base image #{path} not found. Dow you want to download (y/n) '
109
- if STDOUT.flush and gets.chomp.downcase == 'y'
110
- %x[curl -0L #{HOSTED_IMG_PATH} > #{image_dir}/#{img}]
111
- path = File.join(image_dir, img)
112
- end
113
- end
114
-
115
- return path
116
- end
117
-
118
- def pidfile_present?
119
- File.exists? pidfile_path
120
- end
121
-
122
- def image_path
123
- File.expand_path(File.join(image_dir, "qemu-#{opts.name}.img"))
124
- end
125
-
126
- def delete_pidfile
127
- File.delete(pidfile_path)
128
- end
129
-
130
- def write_pidfile(pid)
131
- File.open(pidfile_path, 'w').write(pid.to_s)
132
- end
133
-
134
- def read_pidfile
135
- STDERR.puts "Reading pidfile #{pidfile_path}" if opts.verbose
136
- pid = File.open(pidfile_path, 'r').read.to_i
137
-
138
- unless pid > 0
139
- raise ActionError, "Pidfile (#{pidfile_path}) does not appear to be numeric!"
140
- end
141
-
142
- return pid
143
- end
144
-
145
- def boxlog_path
146
- @boxlog_path ||=
147
- File.expand_path(File.join(boxlog_dir, "qemu-#{opts.name}.log"))
148
- end
149
-
150
- def pidfile_path
151
- @pidfile_path ||=
152
- File.expand_path(File.join(pidfile_dir, "qemu-#{opts[:name]}.pid"))
153
- end
154
-
155
- def boxlog_dir
156
- FileUtils.mkdir_p(PIDFILE_DIR) && PIDFILE_DIR
157
- end
158
-
159
- def pidfile_dir
160
- FileUtils.mkdir_p(PIDFILE_DIR) && PIDFILE_DIR
161
- end
162
-
163
- def image_dir
164
- FileUtils.mkdir_p(BOXIMG_DIR) && BOXIMG_DIR
165
- end
166
- end
167
- end
data/lib/tape.rb DELETED
@@ -1,127 +0,0 @@
1
- require 'erb'
2
- require 'fileutils'
3
- require 'yaml'
4
- require_relative 'tape/notifiers/slack.rb'
5
-
6
- module TapeBoxer
7
- class InvalidAction < StandardError; end
8
- class ActionError < StandardError; end
9
- class UnspecifiedOption < StandardError; end
10
-
11
- class Action < Struct.new(:name, :proc, :description); end
12
- class RegisteredModule < Struct.new(:name, :klass); end
13
-
14
- def self.register_module(name, klass)
15
- self.registered_modules[name] = RegisteredModule.new(name, klass)
16
- end
17
-
18
- def self.registered_modules
19
- @modules ||= Hash.new
20
- end
21
-
22
- class ExecutionModule
23
- attr_reader :opts
24
- def initialize(opts)
25
- @opts = opts || {}
26
- @observers = []
27
- end
28
-
29
- def self.actions
30
- @actions
31
- end
32
-
33
- def self.action(name, opts = '', doc = '')
34
- @actions ||= Hash.new
35
- @actions[name.to_sym] = Action.new(name, opts, doc)
36
- end
37
-
38
- # Set or return module_name
39
- def self.module_name(name = nil)
40
- @module_name = (name || @module_name)
41
- end
42
-
43
- def actions
44
- self.class.actions
45
- end
46
-
47
- def fe_app?
48
- !Dir["#{local_dir}/package.json"].empty?
49
- end
50
-
51
- def rails_app?
52
- !Dir["#{local_dir}/config.ru"].empty?
53
- end
54
-
55
- def execute_action(action)
56
- action = action.to_sym
57
- unless actions.include?(action)
58
- raise InvalidAction, "#{action} is not a valid action!"
59
- end
60
-
61
- unless system("ansible-playbook --version >/dev/null")
62
- raise InvalidAction, "ansible-playbook must be on your PATH to use this tool"
63
- end
64
-
65
- self.instance_eval &actions[action].proc
66
- end
67
-
68
- def config
69
- @config ||= YAML.load_file("#{tapefiles_dir}/tape_vars.yml")
70
- end
71
-
72
- def deploy_info
73
- {
74
- app_name: config["app_name"],
75
- user: `whoami`.chomp,
76
- # FIXME: get host information corectly
77
- # hosts: opts.host_pattern || 'default',
78
- hosts: opts.host_pattern || 'default',
79
- repo: config["be_app_repo"] || ''
80
- }
81
- end
82
-
83
- protected
84
-
85
- def require_opt(name)
86
- unless opts[name.to_sym]
87
- raise UnspecifiedOption, "Option --#{name} must be specified to do this!"
88
- end
89
- end
90
-
91
- private
92
-
93
- def register_notifiers
94
- if config["slack_webhook_url"]
95
- add_observer(::SlackNotifier.new(config["slack_webhook_url"], deploy_info))
96
- end
97
- end
98
-
99
- def add_observer(observer)
100
- @observers.push(observer)
101
- end
102
-
103
- def notify_observers(state)
104
- @observers.each do |observer|
105
- observer.update(state)
106
- end
107
- end
108
-
109
- def tape_dir
110
- File.realpath(File.join(__dir__, '../'))
111
- end
112
-
113
- def local_dir
114
- Dir.pwd
115
- end
116
-
117
- def tapefiles_dir
118
- local_dir + '/taperole'
119
- end
120
-
121
- def tapecfg_dir
122
- local_dir + '/.tape'
123
- end
124
- end
125
- end
126
-
127
- Dir[File.dirname(__FILE__) + "/tape/*.rb"].each {|file| require file }