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
@@ -12,8 +12,14 @@ pg_dump -U {{backup_postgres_user}} {{ '-h ' + backup_postgres_host if backup_p
12
12
 
13
13
  {% elif item.source.startswith('mysql://') %}
14
14
 
15
+ {% if item.source == 'mysql://' %}
16
+ # Dump all databases
17
+ mysqldump -u {{backup_mysql_user}} -p{{backup_mysql_pass}} --all-databases > ${WORKDIR}/dump
18
+ {% else %}
19
+ # Dump the passed database
15
20
  DBNAME={{item.source.split('mysql://')[-1]}}
16
21
  mysqldump -u {{backup_mysql_user}} -p{{backup_mysql_pass}} $DBNAME > ${WORKDIR}/dump
22
+ {% endif %}
17
23
 
18
24
  {% elif item.source.startswith('mongo://') %}
19
25
 
@@ -13,9 +13,15 @@ rm -rf $WORKDIR/dump
13
13
 
14
14
  {% elif item.source.startswith('mysql://') %}
15
15
 
16
+ {% if item.source == 'mysql://' %}
17
+ # Restore all databases
18
+ mysql -u {{backup_mysql_user}} -p{{backup_mysql_pass}} < ${WORKDIR}/dump
19
+ {% else %}
20
+ # Restore the passed database
16
21
  DBNAME={{item.source.split('mysql://')[-1]}}
17
22
  mysql -u {{backup_mysql_user}} -p{{backup_mysql_pass}} $DBNAME < ${WORKDIR}/dump
18
23
  rm -rf $WORKDIR/dump
24
+ {% endif %}
19
25
 
20
26
  {% elif item.source.startswith('mongo://') %}
21
27
 
@@ -0,0 +1,3 @@
1
+ ---
2
+
3
+ backup_duplicity_ppa: false
@@ -0,0 +1 @@
1
+ ---
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taperole
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Forrest
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-31 00:00:00.000000000 Z
13
+ date: 2016-10-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: slack-notifier
@@ -26,6 +26,48 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.5'
29
+ - !ruby/object:Gem::Dependency
30
+ name: thor
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 0.19.1
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 0.19.1
43
+ - !ruby/object:Gem::Dependency
44
+ name: colorize
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.8.1
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: 0.8.1
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3.5'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '3.5'
29
71
  description: General purpose server provisioning and application deployment toolkit
30
72
  email:
31
73
  - jack@smashingboxes.com
@@ -42,17 +84,22 @@ files:
42
84
  - CONTRIBUTING.md
43
85
  - LICENSE
44
86
  - README.md
87
+ - Rakefile
45
88
  - Vagrantfile
46
89
  - ansible.cfg
47
90
  - bin/tape
48
91
  - config/style_guides/ruby.yml
49
- - lib/tape.rb
50
- - lib/tape/ansible_runner.rb
51
- - lib/tape/info.rb
52
- - lib/tape/installer.rb
53
- - lib/tape/notifiers/slack.rb
54
- - lib/tape/overwriter.rb
55
- - lib/tape/qemu_provisioner.rb
92
+ - lib/taperole.rb
93
+ - lib/taperole/commands/ansible.rb
94
+ - lib/taperole/commands/installer.rb
95
+ - lib/taperole/commands/tape.rb
96
+ - lib/taperole/core/ansible_runner.rb
97
+ - lib/taperole/core/installer.rb
98
+ - lib/taperole/core/notifier.rb
99
+ - lib/taperole/helpers/files.rb
100
+ - lib/taperole/helpers/logging.rb
101
+ - lib/taperole/notifiers/slack.rb
102
+ - lib/taperole/version.rb
56
103
  - requirements.yml
57
104
  - roles/after_deploy/tasks/main.yml
58
105
  - roles/backend_checkout/tasks/main.yml
@@ -83,6 +130,7 @@ files:
83
130
  - roles/general/tasks/swapfile.yml
84
131
  - roles/monit_activate/tasks/main.yml
85
132
  - roles/monit_install/tasks/main.yml
133
+ - roles/monit_install/templates/monitrc.j2
86
134
  - roles/monit_install/templates/web_interface.j2
87
135
  - roles/nginx/handlers/main.yml
88
136
  - roles/nginx/tasks/main.yml
@@ -112,10 +160,13 @@ files:
112
160
  - roles/unicorn_install/templates/unicorn.rb.j2
113
161
  - roles/unicorn_install/templates/unicorn_init.j2
114
162
  - roles/unicorn_install/templates/unicorn_monit.j2
163
+ - spec/commands/installer_spec.rb
164
+ - spec/spec_helper.rb
115
165
  - taperole.gemspec
116
166
  - templates/base/deploy.example.yml
117
167
  - templates/base/hosts.example
118
168
  - templates/base/omnibox.example.yml
169
+ - templates/base/rake.example.yml
119
170
  - templates/base/tape_vars.example.yml
120
171
  - templates/static_html/deploy.example.yml
121
172
  - templates/static_html/omnibox.example.yml
@@ -157,6 +208,8 @@ files:
157
208
  - vendor/ANXS.postgresql/templates/postgresql.conf-9.3.j2
158
209
  - vendor/ANXS.postgresql/templates/postgresql.conf-9.4.j2
159
210
  - vendor/ANXS.postgresql/templates/postgresql.conf-9.5.j2
211
+ - vendor/ANXS.postgresql/tests/Dockerfile-centos6
212
+ - vendor/ANXS.postgresql/tests/Dockerfile-ubuntu14.04
160
213
  - vendor/ANXS.postgresql/tests/idempotence_check.sh
161
214
  - vendor/ANXS.postgresql/tests/playbook.yml
162
215
  - vendor/ANXS.postgresql/tests/vars.yml
@@ -174,9 +227,11 @@ files:
174
227
  - vendor/Stouts.backup/defaults/main.yml
175
228
  - vendor/Stouts.backup/meta/.galaxy_install_info
176
229
  - vendor/Stouts.backup/meta/main.yml
230
+ - vendor/Stouts.backup/runtests.sh
177
231
  - vendor/Stouts.backup/tasks/backup.yml
178
232
  - vendor/Stouts.backup/tasks/configure.yml
179
233
  - vendor/Stouts.backup/tasks/install.deb.yml
234
+ - vendor/Stouts.backup/tasks/install.red.yml
180
235
  - vendor/Stouts.backup/tasks/main.yml
181
236
  - vendor/Stouts.backup/tasks/remove.yml
182
237
  - vendor/Stouts.backup/templates/conf.j2
@@ -188,6 +243,8 @@ files:
188
243
  - vendor/Stouts.backup/templates/pre.j2
189
244
  - vendor/Stouts.backup/templates/restore.j2
190
245
  - vendor/Stouts.backup/test.yml
246
+ - vendor/Stouts.backup/vars/Debian.yml
247
+ - vendor/Stouts.backup/vars/Ubuntu.yml
191
248
  - vendor/geerlingguy.memcached/.gitignore
192
249
  - vendor/geerlingguy.memcached/.travis.yml
193
250
  - vendor/geerlingguy.memcached/README.md
@@ -267,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
324
  version: '0'
268
325
  requirements: []
269
326
  rubyforge_project:
270
- rubygems_version: 2.5.1
327
+ rubygems_version: 2.6.2
271
328
  signing_key:
272
329
  specification_version: 4
273
330
  summary: A tool for provisioning and deploying boxes for hosting Rails apps
@@ -1,130 +0,0 @@
1
- # Executes ansible commands
2
- module TapeBoxer
3
- class AnsibleRunner < ExecutionModule
4
- TapeBoxer.register_module :ansible, self
5
-
6
- action :configure_dj_runner,
7
- proc { ansible '-t configure_dj_runner -e force_dj_runner_restart=true' },
8
- "Configures and restarts the delayed job runner"
9
- action :restart_unicorn,
10
- proc { ansible '-t unicorn_restart' },
11
- "Restarts the unicorns running on the app servers"
12
- action :stop_unicorn,
13
- proc { ansible '-t unicorn_stop -e kill_unicorn=true' },
14
- "Stops the unicorns running on the app servers"
15
- action :force_stop_unicorn,
16
- proc { ansible '-t unicorn_force_stop -e kill_unicorn=true' },
17
- "Stops the unicorns running on the app servers"
18
- action :start_unicorn,
19
- proc { ansible '-t unicorn_start' },
20
- "Starts the unicorns running on the app servers"
21
- action :restart_nginx,
22
- proc { ansible '-t restart_nginx' },
23
- "Restarts Nginx"
24
- action :configure_deployer_user,
25
- proc { ansible '-t deployer' },
26
- "Ensures the deployer user is present and configures its SSH keys"
27
- action :reset_db,
28
- proc { ansible '-t db_reset -e force_db_reset=true' },
29
- "wipes and re-seeds the DB"
30
- action :bundle,
31
- proc { ansible '-t bundle -e force_bundle=true' },
32
- "Bundles the gems running on the app servers"
33
- action :be_deploy,
34
- proc { ansible_deploy '-t be_deploy' },
35
- "Re-deploys fe code"
36
- action :fe_deploy,
37
- proc { ansible_deploy '-t fe_deploy' },
38
- "Re-deploys fe code"
39
- action :deploy,
40
- proc { ansible_deploy '-t be_deploy,fe_deploy' },
41
- "Checks out app code, installs dependencies and restarts unicorns for "\
42
- "both FE and BE code."
43
- action :everything,
44
- proc { valid_preconfigs ? ansible : puts("Not a Rails or JS app") },
45
- "This does it all."
46
- action :playbook,
47
- proc { ansible_custom_playbook },
48
- "Run a custom playbook"
49
-
50
- def initialize(*args)
51
- super
52
- register_notifiers
53
- end
54
-
55
- protected
56
- attr_reader :opts
57
-
58
- def valid_preconfigs
59
- if rails_app?
60
- valid_gems
61
- elsif fe_app?
62
- true
63
- else
64
- false
65
- end
66
- end
67
-
68
- def valid_gems
69
- has_gem_in_gemfile('unicorn')
70
- end
71
-
72
- def has_gem_in_gemfile(name)
73
- if open('Gemfile').grep(/#{name}/).empty?
74
- puts "💥 ERROR: Add #{name} to your Gemfile!💥 ".red
75
- false
76
- else
77
- true
78
- end
79
- end
80
-
81
- def ansible(cmd_str = '')
82
- exec_ansible("#{tapefiles_dir}/omnibox.yml", cmd_str)
83
- end
84
-
85
- def ansible_deploy(cmd_str = '')
86
- exec_ansible("#{tapefiles_dir}/deploy.yml", cmd_str)
87
- end
88
-
89
- def ansible_custom_playbook(cmd_str = '')
90
- exec_ansible("#{tapefiles_dir}/#{opts.book}", cmd_str)
91
- end
92
-
93
- def exec_ansible(playbook, args)
94
- enforce_roles_path!
95
- cmd = "ANSIBLE_CONFIG=#{local_dir}/.tape/ansible.cfg ansible-playbook -i #{inventory_file} #{playbook} #{args} #{hosts_flag} -e tape_dir=#{tape_dir}"
96
- cmd += ' --ask-vault-pass' if opts.vault
97
- cmd += ' -vvvv' if opts.verbose
98
- cmd += " -t #{opts.tags}" if opts.tags
99
- STDERR.puts "Executing: #{cmd}" if opts.verbose
100
- notify_observers(:start)
101
- if Kernel.system(cmd)
102
- notify_observers(:success)
103
- else
104
- notify_observers(:fail)
105
- end
106
- end
107
-
108
- def enforce_roles_path!
109
- Dir.mkdir('.tape') unless Dir.exists?('.tape')
110
-
111
- File.open("#{local_dir}/.tape/ansible.cfg", 'w') do |f|
112
- f.puts '[defaults]'
113
- f.puts "roles_path=.tape/roles:#{tape_dir}/roles:#{tape_dir}/vendor"
114
- f.puts "inventory=#{tapefiles_dir}/hosts"
115
- f.puts "retries-dir=/dev/null"
116
- f.puts "retry_files_enabled = False"
117
- f.puts '[ssh_connection]'
118
- f.puts 'ssh_args=-o ForwardAgent=yes'
119
- end
120
- end
121
-
122
- def hosts_flag
123
- "-l #{opts.host_pattern}" if opts.host_pattern
124
- end
125
-
126
- def inventory_file
127
- opts.inventory_file || "#{tapefiles_dir}/hosts"
128
- end
129
- end
130
- end
data/lib/tape/info.rb DELETED
@@ -1,9 +0,0 @@
1
- module TapeBoxer
2
- class Version < ExecutionModule
3
- TapeBoxer.register_module :version, self
4
-
5
- action :number,
6
- proc { STDOUT.puts Gem::Specification::load("taperole.gemspec").version },
7
- "Tape Version Number"
8
- end
9
- end
@@ -1,160 +0,0 @@
1
- require 'pathname'
2
- module TapeBoxer
3
- class Installer < ExecutionModule
4
- TapeBoxer.register_module :installer, self
5
-
6
- action :install,
7
- proc { install },
8
- 'Creates all necessary hosts and config files'
9
- action :uninstall,
10
- proc { uninstall },
11
- 'Cleans up files generated by the installer'
12
-
13
- def initialize(*args)
14
- super
15
- end
16
-
17
- protected
18
-
19
- def install
20
- File.open('.gitignore', 'r+') { |f| f.puts '.tape' unless f.read =~/^\.tape$/ }
21
- mkdir tapefiles_dir
22
- if fe_app? && !rails_app?
23
- puts '🔎 JS/HTML app detected'.pink
24
- copy_static_app_examples
25
- else rails_app?
26
- puts '🔎 Rails app detected'.pink
27
- copy_basic_examples
28
- end
29
- create_roles_dir
30
- create_inventory_file
31
- create_ssh_keys_dir
32
- print 'Are you going to use vagrant? (y/n): '
33
- if gets.chomp == 'y'
34
- copy_example 'Vagrantfile', 'Vagrantfile'
35
- end
36
- end
37
-
38
- def create_roles_dir
39
- mkdir "#{tapefiles_dir}/roles"
40
- `touch #{tapefiles_dir}/roles/.keep`
41
- end
42
-
43
- def create_ssh_keys_dir
44
- mkdir "#{tapefiles_dir}/dev_keys"
45
- end
46
-
47
- def create_inventory_file
48
- copy_example 'templates/base/hosts.example', "#{tapefiles_dir}/hosts"
49
- end
50
-
51
- def copy_static_app_examples
52
- copy_example(
53
- 'templates/static_html/omnibox.example.yml',
54
- "#{tapefiles_dir}/omnibox.yml"
55
- )
56
- copy_example(
57
- 'templates/static_html/deploy.example.yml',
58
- "#{tapefiles_dir}/deploy.yml"
59
- )
60
- copy_example(
61
- 'templates/static_html/tape_vars.example.yml',
62
- "#{tapefiles_dir}/tape_vars.yml"
63
- )
64
- end
65
-
66
- def copy_basic_examples
67
- copy_example(
68
- 'templates/base/omnibox.example.yml',
69
- "#{tapefiles_dir}/omnibox.yml"
70
- )
71
- copy_example(
72
- 'templates/base/deploy.example.yml',
73
- "#{tapefiles_dir}/deploy.yml"
74
- )
75
- copy_example(
76
- 'templates/base/tape_vars.example.yml',
77
- "#{tapefiles_dir}/tape_vars.yml"
78
- )
79
- end
80
-
81
- def uninstall
82
- rm "#{tapefiles_dir}/omnibox.yml"
83
- rm "#{tapefiles_dir}/deploy.yml"
84
- rm "#{tapefiles_dir}/tape_vars.yml"
85
- rm "#{tapefiles_dir}/roles"
86
- rm "#{tapefiles_dir}/hosts"
87
- rm "#{tapefiles_dir}/dev_keys"
88
- rm "Vagrantfile"
89
- end
90
-
91
- def rm(file)
92
- print 'Deleting '.red
93
- FileUtils.rm_r "#{local_dir}/#{file}"
94
- puts file
95
- end
96
-
97
- def mkdir(name)
98
- print "#{::Pathname.new(name).basename}: "
99
- begin
100
- FileUtils.mkdir name
101
- success
102
- rescue Errno::EEXIST
103
- exists
104
- rescue Exception => e
105
- error
106
- raise e
107
- end
108
- end
109
-
110
- def copy_example(file, cp_file)
111
- print "#{::Pathname.new(cp_file).basename}: "
112
- begin
113
- if File.exist?("#{cp_file}")
114
- exists
115
- else
116
- FileUtils.cp("#{tape_dir}/#{file}", "#{cp_file}")
117
- success
118
- end
119
- rescue Exception => e
120
- error
121
- raise e
122
- end
123
- end
124
-
125
- def success
126
- puts '✔'.green
127
- end
128
-
129
- def error
130
- puts '✘'.red
131
- end
132
-
133
- def exists
134
- puts '✘ (Exists)'.yellow
135
- end
136
- end
137
- end
138
-
139
- class String
140
- # colorization
141
- def colorize(color_code)
142
- "\e[#{color_code}m#{self}\e[0m"
143
- end
144
-
145
- def red
146
- colorize(31)
147
- end
148
-
149
- def green
150
- colorize(32)
151
- end
152
-
153
- def yellow
154
- colorize(33)
155
- end
156
-
157
- def pink
158
- colorize(35)
159
- end
160
- end
@@ -1,79 +0,0 @@
1
- require 'slack-notifier'
2
-
3
- class SlackNotifier
4
- def initialize(webhook_url, deploy_info)
5
- @notifier = Slack::Notifier.new webhook_url
6
- @notifier.username = 'Tape'
7
- @deploy_info = deploy_info
8
- end
9
-
10
- def update(status)
11
- @status = status
12
- @notifier.ping(
13
- "",
14
- # TODO: Fill in real icon url
15
- icon_url: 'https://image.freepik.com/free-icon/adhesive-tape_318-42276.png',
16
- attachments: attachments
17
- )
18
- end
19
-
20
- private
21
-
22
- def attachments
23
- a = {}
24
- a[:text] = message
25
- a[:color] = color
26
- a[:fields] = fields unless @status == :start
27
- [a]
28
- end
29
-
30
- def fields
31
- [
32
- {
33
- title: "Project",
34
- value: project_link,
35
- short: true
36
- },
37
- {
38
- title: "Hosts/Env",
39
- value: @deploy_info[:hosts],
40
- short: true
41
- },
42
- {
43
- title: "Author",
44
- value: @deploy_info[:user],
45
- short: true
46
- }
47
- ]
48
- end
49
-
50
- def color
51
- case @status
52
- when :start then "#a9a9a9"
53
- when :success then "good"
54
- when :fail then "danger"
55
- end
56
- end
57
-
58
- def gh_link_base
59
- @deploy_info[:repo].sub(/^git@github.com:/, 'http://github.com/').sub(/.git$/, '')
60
- end
61
-
62
- def project_link
63
- "<#{gh_link_base}|#{@deploy_info[:app_name]}>"
64
- end
65
-
66
- def message
67
- case @status
68
- when :start
69
- user = @deploy_info[:user]
70
- app = @deploy_info[:app_name]
71
- hosts = @deploy_info[:hosts]
72
- "#{user} started deploying #{app} to #{hosts}"
73
- when :success
74
- "The deploy was successful!"
75
- when :fail
76
- "The deploy failed!"
77
- end
78
- end
79
- end
@@ -1,14 +0,0 @@
1
- require 'pathname'
2
- module TapeBoxer
3
- class Overwriter < ExecutionModule
4
- TapeBoxer.register_module :overwrite, self
5
-
6
- action :role,
7
- proc { overwrite_role },
8
- "Overwrite a taperole ansible role"
9
-
10
- def overwrite_role
11
- FileUtils.cp_r("#{tape_dir}/roles/#{opts.role}", "taperole/roles/")
12
- end
13
- end
14
- end