taperole 1.6.0 → 1.7.0

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 (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
@@ -0,0 +1,83 @@
1
+ require 'slack-notifier'
2
+
3
+ module Taperole
4
+ module Notifiers
5
+ class Slack
6
+ def initialize(webhook_url, deploy_info)
7
+ @notifier = ::Slack::Notifier.new webhook_url
8
+ @notifier.username = 'Tape'
9
+ @deploy_info = deploy_info
10
+ end
11
+
12
+ def update(status)
13
+ @status = status
14
+ @notifier.ping(
15
+ "",
16
+ # TODO: Fill in real icon url
17
+ icon_url: 'https://image.freepik.com/free-icon/adhesive-tape_318-42276.png',
18
+ attachments: attachments
19
+ )
20
+ end
21
+
22
+ private
23
+
24
+ def attachments
25
+ a = {}
26
+ a[:text] = message
27
+ a[:color] = color
28
+ a[:fields] = fields unless @status == :start
29
+ [a]
30
+ end
31
+
32
+ def fields
33
+ [
34
+ {
35
+ title: "Project",
36
+ value: project_link,
37
+ short: true
38
+ },
39
+ {
40
+ title: "Hosts/Env",
41
+ value: @deploy_info[:hosts],
42
+ short: true
43
+ },
44
+ {
45
+ title: "Author",
46
+ value: @deploy_info[:user],
47
+ short: true
48
+ }
49
+ ]
50
+ end
51
+
52
+ def color
53
+ case @status
54
+ when :start then "#a9a9a9"
55
+ when :success then "good"
56
+ when :fail then "danger"
57
+ end
58
+ end
59
+
60
+ def gh_link_base
61
+ @deploy_info[:repo].sub(/^git@github.com:/, 'http://github.com/').sub(/.git$/, '')
62
+ end
63
+
64
+ def project_link
65
+ "<#{gh_link_base}|#{@deploy_info[:app_name]}>"
66
+ end
67
+
68
+ def message
69
+ case @status
70
+ when :start
71
+ user = @deploy_info[:user]
72
+ app = @deploy_info[:app_name]
73
+ hosts = @deploy_info[:hosts]
74
+ "#{user} started deploying #{app} to #{hosts}"
75
+ when :success
76
+ "The deploy was successful!"
77
+ when :fail
78
+ "The deploy failed!"
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ module Taperole
2
+ VERSION = '1.7.0'.freeze
3
+ end
data/lib/taperole.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'thor'
2
+ require 'colorize'
3
+
4
+ module Taperole
5
+ autoload :VERSION, 'taperole/version'
6
+ autoload :AnsibleRunner, 'taperole/core/ansible_runner'
7
+ autoload :Installer, 'taperole/core/installer'
8
+ autoload :Notifier, 'taperole/core/notifier'
9
+
10
+ module Commands
11
+ autoload :Tape, 'taperole/commands/tape'
12
+ autoload :Installer, 'taperole/commands/installer'
13
+ autoload :Ansible, 'taperole/commands/ansible'
14
+ end
15
+
16
+ module Helpers
17
+ autoload :Files, 'taperole/helpers/files'
18
+ autoload :Logging, 'taperole/helpers/logging'
19
+ end
20
+
21
+ module Notifiers
22
+ autoload :Slack, 'taperole/notifiers/slack'
23
+ end
24
+ end
data/requirements.yml CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  - src: https://github.com/ANXS/postgresql
10
10
  name: ANXS.postgresql
11
- version: v1.3.0
11
+ version: v1.6.2
12
12
 
13
13
  - src: geerlingguy.memcached
14
14
  version: 1.0.4
@@ -18,6 +18,7 @@
18
18
  tags: [be_deploy]
19
19
 
20
20
  - name: Check out application
21
+ sudo: false
21
22
  remote_user: "{{ deployer_user.name }}"
22
23
  git: dest={{ be_app_path }}
23
24
  repo={{ be_app_repo }}
@@ -1,18 +1,3 @@
1
- # - name: Install DJ monit bin command
2
- # template: src=dj_monit_runner.j2
3
- # dest=/usr/bin/dj_monit_runner
4
- # mode=u=rwx,g=rwx,o=r
5
- #
6
- # - name: Install DJ monit config
7
- # template: src=dj_monit_config.j2
8
- # dest=/etc/monit/conf.d/delayed_job
9
- # mode=u=rw,g=r,o=r
10
- # register: dj_monit_config
11
- #
12
- # - name: Reload Monit
13
- # command: bash -lc "monit reload"
14
- # when: dj_monit_config.changed
15
-
16
1
  - name: Stop Delayed Job
17
2
  remote_user: "{{ deployer_user.name }}"
18
3
  command: bash -lc "cd {{be_app_path}} && RAILS_ENV={{be_app_env}} bin/delayed_job stop -n {{dj_runners}}"
@@ -2,9 +2,9 @@
2
2
  file: path=/home/{{ deployer_user.name }}/.ssh
3
3
  state=directory
4
4
  owner={{ deployer_user.name }}
5
+ group=users
5
6
  mode=744
6
7
 
7
-
8
8
  - name: Copy of root ssh keys
9
9
  command: "cp /root/.ssh/authorized_keys /home/{{ deployer_user.name }}/.ssh/authorized_keys"
10
10
 
@@ -12,12 +12,12 @@
12
12
  file: path="/home/{{ deployer_user.name }}/.ssh/authorized_keys"
13
13
  state=file
14
14
  owner={{ deployer_user.name }}
15
+ group=users
15
16
  mode=600
16
17
 
17
-
18
18
  - name: Ensure devs keys are present
19
- authorized_key: key={{ lookup('file', item) }}
20
- user={{ deployer_user.name }}
21
- state=present
19
+ authorized_key: key="{{ lookup('file', item) }}"
20
+ user={{ deployer_user.name }}
21
+ state=present
22
22
  with_fileglob:
23
- - "./dev_keys/*"
23
+ - "{{ playbook_dir }}/../dev_keys/*"
@@ -9,9 +9,6 @@
9
9
  user: name={{ deployer_user.name }} groups={{ item }} state=present append=yes shell=/bin/bash
10
10
  with_items: deployer_user.groups
11
11
 
12
- # It's possible for the deployer's homedir to get created on accident by
13
- # a deploy script or something getting run before this. This just ensures
14
- # the env is sane moving forward
15
12
  - name: Ensure deployer user owns its own homedir
16
13
  file: path=/home/deployer state=directory owner=deployer
17
14
 
@@ -1,6 +1,12 @@
1
1
  - name: Install monit
2
2
  apt: name=monit state=present
3
3
 
4
+ - name: Register monit config files
5
+ template: src=monitrc.j2
6
+ dest=/etc/monitrc
7
+ mode=700
8
+ register: web_interface_monit_config
9
+
4
10
  - name: Register monit config files
5
11
  template: src={{ item }}.j2
6
12
  dest=/etc/monit/conf.d/{{ item }}
@@ -0,0 +1,290 @@
1
+ ###############################################################################
2
+ ## Monit control file
3
+ ###############################################################################
4
+ ##
5
+ ## Comments begin with a '#' and extend through the end of the line. Keywords
6
+ ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
7
+ ##
8
+ ## Below you will find examples of some frequently used statements. For
9
+ ## information about the control file and a complete list of statements and
10
+ ## options, please have a look in the Monit manual.
11
+ ##
12
+ ##
13
+ ###############################################################################
14
+ ## Global section
15
+ ###############################################################################
16
+ ##
17
+ ## Start Monit in the background (run as a daemon):
18
+ #
19
+ set daemon 120 # check services at 2-minute intervals
20
+ # with start delay 240 # optional: delay the first check by 4-minutes (by
21
+ # # default Monit check immediately after Monit start)
22
+ #
23
+ #
24
+ ## Set syslog logging. If you want to log to a standalone log file instead,
25
+ ## specify the full path to the log file
26
+ #
27
+ set logfile /var/log/monit.log
28
+ #
29
+ #
30
+ ## Set the location of the Monit lock file which stores the process id of the
31
+ ## running Monit instance. By default this file is stored in $HOME/.monit.pid
32
+ #
33
+ # set pidfile /var/run/monit.pid
34
+ #
35
+ ## Set the location of the Monit id file which stores the unique id for the
36
+ ## Monit instance. The id is generated and stored on first Monit start. By
37
+ ## default the file is placed in $HOME/.monit.id.
38
+ #
39
+ # set idfile /var/.monit.id
40
+ set idfile /var/lib/monit/id
41
+ #
42
+ ## Set the location of the Monit state file which saves monitoring states
43
+ ## on each cycle. By default the file is placed in $HOME/.monit.state. If
44
+ ## the state file is stored on a persistent filesystem, Monit will recover
45
+ ## the monitoring state across reboots. If it is on temporary filesystem, the
46
+ ## state will be lost on reboot which may be convenient in some situations.
47
+ #
48
+ set statefile /var/lib/monit/state
49
+ #
50
+ #
51
+
52
+ ## Set limits for various tests. The following example shows the default values:
53
+ ##
54
+ # set limits {
55
+ # programOutput: 512 B, # check program's output truncate limit
56
+ # sendExpectBuffer: 256 B, # limit for send/expect protocol test
57
+ # fileContentBuffer: 512 B, # limit for file content test
58
+ # httpContentBuffer: 1 MB, # limit for HTTP content test
59
+ # networkTimeout: 5 seconds # timeout for network I/O
60
+ # }
61
+
62
+ ## Set global SSL options (just most common options showed, see manual for
63
+ ## full list).
64
+ #
65
+ # set ssl {
66
+ # verify : enable, # verify SSL certificates (disabled by default but STRONGLY RECOMMENDED)
67
+ # selfsigned : allow # allow self signed SSL certificates (reject by default)
68
+ # }
69
+ #
70
+ #
71
+ ## Set the list of mail servers for alert delivery. Multiple servers may be
72
+ ## specified using a comma separator. If the first mail server fails, Monit
73
+ # will use the second mail server in the list and so on. By default Monit uses
74
+ # port 25 - it is possible to override this with the PORT option.
75
+ #
76
+ # set mailserver mail.bar.baz, # primary mailserver
77
+ # backup.bar.baz port 10025, # backup mailserver on port 10025
78
+ # localhost # fallback relay
79
+ #
80
+ #
81
+ ## By default Monit will drop alert events if no mail servers are available.
82
+ ## If you want to keep the alerts for later delivery retry, you can use the
83
+ ## EVENTQUEUE statement. The base directory where undelivered alerts will be
84
+ ## stored is specified by the BASEDIR option. You can limit the queue size
85
+ ## by using the SLOTS option (if omitted, the queue is limited by space
86
+ ## available in the back end filesystem).
87
+ #
88
+ set eventqueue
89
+ basedir /var/lib/monit/events # set the base directory where events will be stored
90
+ slots 100 # optionally limit the queue size
91
+ #
92
+ #
93
+ ## Send status and events to M/Monit (for more informations about M/Monit
94
+ ## see http://mmonit.com/). By default Monit registers credentials with
95
+ ## M/Monit so M/Monit can smoothly communicate back to Monit and you don't
96
+ ## have to register Monit credentials manually in M/Monit. It is possible to
97
+ ## disable credential registration using the commented out option below.
98
+ ## Though, if safety is a concern we recommend instead using https when
99
+ ## communicating with M/Monit and send credentials encrypted.
100
+ #
101
+ # set mmonit http://monit:monit@192.168.1.10:8080/collector
102
+ # # and register without credentials # Don't register credentials
103
+ #
104
+ #
105
+ ## Monit by default uses the following format for alerts if the the mail-format
106
+ ## statement is missing::
107
+ ## --8<--
108
+ ## set mail-format {
109
+ ## from: monit@$HOST
110
+ ## subject: monit alert -- $EVENT $SERVICE
111
+ ## message: $EVENT Service $SERVICE
112
+ ## Date: $DATE
113
+ ## Action: $ACTION
114
+ ## Host: $HOST
115
+ ## Description: $DESCRIPTION
116
+ ##
117
+ ## Your faithful employee,
118
+ ## Monit
119
+ ## }
120
+ ## --8<--
121
+ ##
122
+ ## You can override this message format or parts of it, such as subject
123
+ ## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
124
+ ## are expanded at runtime. For example, to override the sender, use:
125
+ #
126
+ # set mail-format { from: monit@foo.bar }
127
+ #
128
+ #
129
+ ## You can set alert recipients whom will receive alerts if/when a
130
+ ## service defined in this file has errors. Alerts may be restricted on
131
+ ## events by using a filter as in the second example below.
132
+ #
133
+ # set alert sysadm@foo.bar # receive all alerts
134
+ #
135
+ ## Do not alert when Monit starts, stops or performs a user initiated action.
136
+ ## This filter is recommended to avoid getting alerts for trivial cases.
137
+ #
138
+ # set alert your-name@your.domain not on { instance, action }
139
+ #
140
+ #
141
+ ## Monit has an embedded HTTP interface which can be used to view status of
142
+ ## services monitored and manage services from a web interface. The HTTP
143
+ ## interface is also required if you want to issue Monit commands from the
144
+ ## command line, such as 'monit status' or 'monit restart service' The reason
145
+ ## for this is that the Monit client uses the HTTP interface to send these
146
+ ## commands to a running Monit daemon. See the Monit Wiki if you want to
147
+ ## enable SSL for the HTTP interface.
148
+ #
149
+ # set httpd port 2812 and
150
+ # use address localhost # only accept connection from localhost
151
+ # allow localhost # allow localhost to connect to the server and
152
+ # allow admin:monit # require user 'admin' with password 'monit'
153
+ #
154
+ ###############################################################################
155
+ ## Services
156
+ ###############################################################################
157
+ ##
158
+ ## Check general system resources such as load average, cpu and memory
159
+ ## usage. Each test specifies a resource, conditions and the action to be
160
+ ## performed should a test fail.
161
+ #
162
+ # check system $HOST
163
+ # if loadavg (1min) > 4 then alert
164
+ # if loadavg (5min) > 2 then alert
165
+ # if cpu usage > 95% for 10 cycles then alert
166
+ # if memory usage > 75% then alert
167
+ # if swap usage > 25% then alert
168
+ #
169
+ #
170
+ ## Check if a file exists, checksum, permissions, uid and gid. In addition
171
+ ## to alert recipients in the global section, customized alert can be sent to
172
+ ## additional recipients by specifying a local alert handler. The service may
173
+ ## be grouped using the GROUP option. More than one group can be specified by
174
+ ## repeating the 'group name' statement.
175
+ #
176
+ # check file apache_bin with path /usr/local/apache/bin/httpd
177
+ # if failed checksum and
178
+ # expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
179
+ # if failed permission 755 then unmonitor
180
+ # if failed uid root then unmonitor
181
+ # if failed gid root then unmonitor
182
+ # alert security@foo.bar on {
183
+ # checksum, permission, uid, gid, unmonitor
184
+ # } with the mail-format { subject: Alarm! }
185
+ # group server
186
+ #
187
+ #
188
+ ## Check that a process is running, in this case Apache, and that it respond
189
+ ## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
190
+ ## and number of children. If the process is not running, Monit will restart
191
+ ## it by default. In case the service is restarted very often and the
192
+ ## problem remains, it is possible to disable monitoring using the TIMEOUT
193
+ ## statement. This service depends on another service (apache_bin) which
194
+ ## is defined above.
195
+ #
196
+ # check process apache with pidfile /usr/local/apache/logs/httpd.pid
197
+ # start program = "/etc/init.d/httpd start" with timeout 60 seconds
198
+ # stop program = "/etc/init.d/httpd stop"
199
+ # if cpu > 60% for 2 cycles then alert
200
+ # if cpu > 80% for 5 cycles then restart
201
+ # if totalmem > 200.0 MB for 5 cycles then restart
202
+ # if children > 250 then restart
203
+ # if loadavg(5min) greater than 10 for 8 cycles then stop
204
+ # if failed host www.tildeslash.com port 80 protocol http
205
+ # and request "/somefile.html"
206
+ # then restart
207
+ # if failed port 443 protocol https with timeout 15 seconds then restart
208
+ # if 3 restarts within 5 cycles then unmonitor
209
+ # depends on apache_bin
210
+ # group server
211
+ #
212
+ #
213
+ ## Check filesystem permissions, uid, gid, space and inode usage. Other services,
214
+ ## such as databases, may depend on this resource and an automatically graceful
215
+ ## stop may be cascaded to them before the filesystem will become full and data
216
+ ## lost.
217
+ #
218
+ # check filesystem datafs with path /dev/sdb1
219
+ # start program = "/bin/mount /data"
220
+ # stop program = "/bin/umount /data"
221
+ # if failed permission 660 then unmonitor
222
+ # if failed uid root then unmonitor
223
+ # if failed gid disk then unmonitor
224
+ # if space usage > 80% for 5 times within 15 cycles then alert
225
+ # if space usage > 99% then stop
226
+ # if inode usage > 30000 then alert
227
+ # if inode usage > 99% then stop
228
+ # group server
229
+ #
230
+ #
231
+ ## Check a file's timestamp. In this example, we test if a file is older
232
+ ## than 15 minutes and assume something is wrong if its not updated. Also,
233
+ ## if the file size exceed a given limit, execute a script
234
+ #
235
+ # check file database with path /data/mydatabase.db
236
+ # if failed permission 700 then alert
237
+ # if failed uid data then alert
238
+ # if failed gid data then alert
239
+ # if timestamp > 15 minutes then alert
240
+ # if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
241
+ #
242
+ #
243
+ ## Check directory permission, uid and gid. An event is triggered if the
244
+ ## directory does not belong to the user with uid 0 and gid 0. In addition,
245
+ ## the permissions have to match the octal description of 755 (see chmod(1)).
246
+ #
247
+ # check directory bin with path /bin
248
+ # if failed permission 755 then unmonitor
249
+ # if failed uid 0 then unmonitor
250
+ # if failed gid 0 then unmonitor
251
+ #
252
+ #
253
+ ## Check a remote host availability by issuing a ping test and check the
254
+ ## content of a response from a web server. Up to three pings are sent and
255
+ ## connection to a port and an application level network check is performed.
256
+ #
257
+ # check host myserver with address 192.168.1.1
258
+ # if failed ping then alert
259
+ # if failed port 3306 protocol mysql with timeout 15 seconds then alert
260
+ # if failed port 80 protocol http
261
+ # and request /some/path with content = "a string"
262
+ # then alert
263
+ #
264
+ #
265
+ ## Check a network link status (up/down), link capacity changes, saturation
266
+ ## and bandwidth usage.
267
+ #
268
+ # check network public with interface eth0
269
+ # if failed link then alert
270
+ # if changed link then alert
271
+ # if saturation > 90% then alert
272
+ # if download > 10 MB/s then alert
273
+ # if total upload > 1 GB in last hour then alert
274
+ #
275
+ #
276
+ ## Check custom program status output.
277
+ #
278
+ # check program myscript with path /usr/local/bin/myscript.sh
279
+ # if status != 0 then alert
280
+ #
281
+ #
282
+ ###############################################################################
283
+ ## Includes
284
+ ###############################################################################
285
+ ##
286
+ ## It is possible to include additional configuration parts from other files or
287
+ ## directories.
288
+ #
289
+ include /etc/monit/conf.d/*
290
+ include /etc/monit/conf-enabled/*
@@ -18,10 +18,11 @@
18
18
  command: bash -lc "openssl req -x509 -sha256 -nodes -newkey rsa:2048 -keyout self-signed.key -out self-signed.crt -subj '/CN=localhost'"
19
19
  args:
20
20
  chdir: /etc/nginx/ssl
21
+ creates: /etc/nginx/ssl/self-signed.*
21
22
  tags: [nginx]
22
23
 
23
24
  - name: Create Diffie Hellman Ephemeral Parameters (this will take some time)
24
- command: bash -lc "openssl dhparam -out dhparam.pem 2048"
25
+ command: bash -lc "openssl dhparam -out dhparam.pem 2048" creates=/etc/nginx/ssl/dhparam.pem
25
26
  args:
26
27
  chdir: /etc/nginx/ssl
27
28
  tags: [nginx]
@@ -31,9 +32,7 @@
31
32
  tags: [nginx]
32
33
 
33
34
  - name: Install monit nginx config
34
- template: src=nginx_monit.j2
35
- dest=/etc/monit/conf.d/nginx
36
- mode=u=rw,g=r,o=r
35
+ file: src=/etc/monit/conf-available/nginx dest=/etc/monit/conf-enabled/nginx owner=root group=root state=link
37
36
  register: nginx_monit_config
38
37
 
39
38
  - name: Reload Monit
@@ -53,6 +53,7 @@ server {
53
53
  gzip_static on;
54
54
  expires max;
55
55
  add_header Cache-Control public;
56
+ root {{ be_app_path }}/public;
56
57
  }
57
58
 
58
59
  {% if be_app_repo is defined %}
@@ -11,7 +11,8 @@
11
11
 
12
12
  - name: Import the NodeSource GPG key into apt
13
13
  apt_key:
14
- url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
14
+ url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280
15
+ id: "68576280"
15
16
  state: present
16
17
 
17
18
  - name: Add NodeSource deb repository
@@ -9,8 +9,7 @@
9
9
  set_fact: 'rbenv_owner={{ rbenv_owner | default("root", true) }}'
10
10
 
11
11
  - name: checkout rbenv_repo for system
12
- become: yes
13
- become_user: '{{ rbenv_owner }}'
12
+ remote_user: '{{ rbenv_owner }}'
14
13
  git: >
15
14
  repo={{ rbenv_repo }}
16
15
  dest={{ rbenv_root }}
@@ -22,16 +21,14 @@
22
21
  - rbenv
23
22
 
24
23
  - name: create plugins directory for system
25
- become: yes
26
- become_user: '{{ rbenv_owner }}'
24
+ remote_user: '{{ rbenv_owner }}'
27
25
  file: state=directory path={{ rbenv_root }}/plugins
28
26
  when: rbenv.env == "system"
29
27
  tags:
30
28
  - rbenv
31
29
 
32
30
  - name: install plugins for system
33
- become: yes
34
- become_user: '{{ rbenv_owner }}'
31
+ remote_user: '{{ rbenv_owner }}'
35
32
  git: >
36
33
  repo=https://github.com/rbenv/ruby-build.git
37
34
  dest={{ rbenv_root }}/plugins/ruby-build
@@ -46,7 +43,6 @@
46
43
  \( -iname ".git" -prune \) -o
47
44
  ! -group '{{ item }}'
48
45
  -exec chgrp -v '{{ item }}' {} + | head -n 1
49
- become: yes
50
46
  with_items: '{{ rbenv_group }}'
51
47
  when:
52
48
  - rbenv.env == "system"
@@ -63,7 +59,6 @@
63
59
  \( -iname ".git" -prune \) -o
64
60
  -type d ! -perm -g+s
65
61
  -exec chmod -v g+rwxs {} + | head -n 1
66
- become: yes
67
62
  when:
68
63
  - rbenv.env == "system"
69
64
  - rbenv_group is defined
@@ -75,7 +70,6 @@
75
70
 
76
71
  - name: add rbenv initialization to profile system-wide
77
72
  template: src=rbenv.sh.j2 dest=/etc/profile.d/rbenv.sh owner=root group=root mode=0755
78
- become: yes
79
73
  when:
80
74
  - ansible_os_family != 'OpenBSD'
81
75
  tags:
@@ -93,7 +87,6 @@
93
87
 
94
88
  - name: install ruby {{ rbenv.ruby_version }} for system
95
89
  shell: bash -lc "rbenv install {{ rbenv.ruby_version }}"
96
- become: yes
97
90
  when:
98
91
  - rbenv.env == "system"
99
92
  - ruby_installed.rc != 0
@@ -111,7 +104,6 @@
111
104
  - rbenv
112
105
 
113
106
  - name: set ruby {{ rbenv.ruby_version }} for system
114
- become: yes
115
107
  shell: bash -lc "rbenv global {{ rbenv.ruby_version }} && rbenv rehash"
116
108
  when:
117
109
  - rbenv.env == "system"
@@ -3,9 +3,6 @@
3
3
  dest=/etc/init.d/unicorn_{{app_name}}
4
4
  mode=u=rw,g=rx,o=rx
5
5
 
6
- - name: register unicorn init.d script
7
- command: initctl reload-configuration
8
-
9
6
  - name: Set up unicorn log dir
10
7
  file: path={{be_app_path}}/log state=directory owner=deployer
11
8
 
@@ -1,6 +1,6 @@
1
1
  worker_processes {{ unicorn_workers }}
2
2
  working_directory "{{ be_app_path }}"
3
- pid "{{ be_app_path }}/tmp/unicorn.pid"
3
+ pid "{{ be_app_path }}/tmp/unicorn/unicorn.pid"
4
4
  stderr_path "{{ be_app_path }}/log/unicorn.log"
5
5
  stdout_path "{{ be_app_path }}/log/unicorn.log"
6
6
 
@@ -7,7 +7,7 @@ RBENV_ROOT="{{ rbenv_root }}"
7
7
  PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
8
8
  APP_ROOT="{{be_app_path}}"
9
9
  APP_USER="{{ deployer_user.name }}"
10
- PID="$APP_ROOT/tmp/unicorn.pid"
10
+ PID="$APP_ROOT/tmp/unicorn/unicorn.pid"
11
11
  CMD="bundle exec unicorn -E {{be_app_env}} -D -c $APP_ROOT/config/unicorn.rb"
12
12
 
13
13
  action="$1"
@@ -1,4 +1,4 @@
1
- check process unicorn with pidfile {{ be_app_path }}/tmp/unicorn.pid
1
+ check process unicorn with pidfile {{ be_app_path }}/tmp/unicorn/unicorn.pid
2
2
  start program "/etc/init.d/unicorn_{{ app_name }} start" as uid deployer and gid deployer with timeout 90 seconds
3
3
  restart program "/etc/init.d/unicorn_{{ app_name }} restart" as uid deployer and gid deployer with timeout 90 seconds
4
4
  stop program "/etc/init.d/unicorn_{{ app_name }} stop" as uid deployer and gid deployer with timeout 90 seconds