capun 0.0.17 → 0.0.20

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee071543c1a5a48adea3e0c53d25fdc9d2d0daed
4
- data.tar.gz: 1be5a5f0a33a957e0e37dd5e9877dc3faa7ee267
3
+ metadata.gz: d466a36a7502af8fdda78544e1b333f655e7f220
4
+ data.tar.gz: 8683c2fee0575cac1864c28b1b89bb40e01b01db
5
5
  SHA512:
6
- metadata.gz: 5ee10102b8b0ac4adaf65e6377effd7dba01bec184b57ecfd27e0f573e60b94b0af6510af200bb22b64f4e4c251c26d198c51d3610cb431227bbaf93502af1d4
7
- data.tar.gz: ce173589306474f478842d5732bbd1cd21b7085655bf2b166ddd02fe60ae628e341406416e2bbfee9304bd2f006263860c11be6d674f76bd390c8816ee11ee78
6
+ metadata.gz: 24251974e58cc2a9b37134523aa8c4d7a86409ea980dabffc9a82ed14a13d068bfd43b361054b6f19ff22be2e26d9679ef1b4db533a1610bb3d73ea5c34f877e
7
+ data.tar.gz: 36b3c0b4de39d21e871f10567b208c5ff3f3558d571d1cde8a6f73123636550e8630fa2ee58506f97d9e09072b0350014d68bbe0a473ed82f4105562ca5281b0
@@ -1,4 +1,4 @@
1
-
1
+ require 'digest'
2
2
  set :deploy_to, -> {"/home/#{fetch(:user)}/apps/#{fetch(:application)}"}
3
3
  set :rvm1_ruby_version, "2.0.0"
4
4
  set :branch, 'master'
@@ -18,21 +18,25 @@ set :unicorn_config_path, -> { "#{shared_path}/config/unicorn.config.rb" }
18
18
  set :uploads, []
19
19
  set :std_uploads, [
20
20
  #figaro
21
- {what: "config/application.yml", where: '#{shared_path}/config/application.yml'},
21
+ {what: "config/application.yml", where: '#{shared_path}/config/application.yml', overwrite: true},
22
22
  #logstash configs
23
- {what: "config/deploy/logstash.config.erb", where: '#{shared_path}/config/logstash.config'},
23
+ {what: "config/deploy/logstash.config.erb", where: '#{shared_path}/config/logstash.config', overwrite: true},
24
24
  #logrotate configs
25
- {what: "config/deploy/logrotate.config.erb", where: '#{shared_path}/config/logrotate.config'},
25
+ {what: "config/deploy/logrotate.config.erb", where: '#{shared_path}/config/logrotate.config', overwrite: true},
26
26
  #basic_authenticatable.rb
27
- {what: "config/deploy/basic_authenticatable.rb.erb", where: '#{release_path}/app/controllers/concerns/basic_authenticatable.rb'},
27
+ {what: "config/deploy/basic_authenticatable.rb.erb", where: '#{release_path}/app/controllers/concerns/basic_authenticatable.rb', overwrite: true},
28
28
  #nginx.conf
29
- {what: "config/deploy/nginx.conf.erb", where: '#{shared_path}/config/nginx.conf'},
29
+ {what: "config/deploy/nginx.conf.erb", where: '#{shared_path}/config/nginx.conf', overwrite: true},
30
30
  #unicorn.config.rb
31
- {what: "config/deploy/unicorn.config.rb.erb", where: '#{shared_path}/config/unicorn.config.rb'},
31
+ {what: "config/deploy/unicorn.config.rb.erb", where: '#{shared_path}/config/unicorn.config.rb', overwrite: true},
32
32
  #secret_token.rb
33
- {what: "config/initializers/secret_token.rb", where: '#{release_path}/config/initializers/secret_token.rb'},
33
+ {what: "config/initializers/secret_token.rb", where: '#{release_path}/config/initializers/secret_token.rb', overwrite: true},
34
34
  #database.yml
35
- {what: "config/deploy/database.yml.erb", where: '#{shared_path}/config/database.yml'}
35
+ {what: "config/deploy/database.yml.erb", where: '#{shared_path}/config/database.yml', overwrite: true},
36
+ #jenkins' config.xml
37
+ {what: "config/deploy/jenkins.config.xml.erb", where: '#{shared_path}/config/jenkins.config.xml', overwrite: false},
38
+ #newrelic.yml
39
+ {what: "config/deploy/newrelic.yml.erb", where: '#{release_path}/config/newrelic.yml', overwrite: true}
36
40
  ]
37
41
 
38
42
  set :symlinks, []
@@ -41,7 +45,8 @@ set :std_symlinks, [
41
45
  {what: "logstash.config", where: '/etc/logstash/conf.d/#{fetch(:application)}'},
42
46
  {what: "logrotate.config", where: '/etc/logrotate.d/#{fetch(:application)}'},
43
47
  {what: "database.yml", where: '#{release_path}/config/database.yml'},
44
- {what: "application.yml", where: '#{release_path}/config/application.yml'}
48
+ {what: "application.yml", where: '#{release_path}/config/application.yml'},
49
+ {what: "jenkins.config.xml", where: '/var/lib/jenkins/jobs/#{fetch(:application)}/config.xml'}
45
50
  ]
46
51
 
47
52
  before 'deploy', 'rvm1:install:rvm' # install/update RVM
@@ -62,11 +67,13 @@ namespace :deploy do
62
67
  on roles(:app) do |server|
63
68
  #create /home/[user]/apps/[app]/shared/config directory, if it doesn't exist yet
64
69
  execute :mkdir, "-p", "#{shared_path}/config"
70
+ execute :sudo, :chown, "#{fetch(:user)}:#{fetch(:user)}", "#{shared_path}/config/*"
65
71
  uploads = fetch(:uploads).concat(fetch(:std_uploads))
66
72
  uploads.each do |file_hash|
67
73
  what = file_hash[:what]
68
74
  next if !File.exists?(what)
69
75
  where = eval "\"" + file_hash[:where] + "\""
76
+ next if !file_hash[:overwrite] && test("[ -f #{where} ]")
70
77
  #compile temlate if it ends with .erb before upload
71
78
  upload! (what.end_with?(".erb") ? StringIO.new(ERB.new(File.read(what)).result(binding)) : what), where
72
79
  info "copying: #{what} to: #{where}"
@@ -94,6 +101,25 @@ namespace :deploy do
94
101
  task :make_dirs do
95
102
  on roles(:app) do
96
103
  execute :mkdir, "-p", "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
104
+ if fetch(:addJenkins)
105
+ execute :sudo, :mkdir, "-p", "/var/lib/jenkins/jobs/#{fetch(:application)}"
106
+ execute :sudo, :chown, "#{fetch(:user)}", "/var/lib/jenkins/jobs/#{fetch(:application)}"
107
+ end
108
+ end
109
+ end
110
+
111
+ desc 'Setting up Jenkins'
112
+ task :set_up_jenkins do
113
+ if fetch(:addJenkins)
114
+ on roles(:app) do
115
+ if test("[ -f /var/lib/jenkins/jobs/#{fetch(:application)}/config.xml ]")
116
+ execute :sudo, :chown, "jenkins:jenkins", "/var/lib/jenkins/jobs/#{fetch(:application)}"
117
+ execute :sudo, :chmod, "755", "/var/lib/jenkins/jobs/#{fetch(:application)}"
118
+ execute :sudo, :chown, "jenkins:jenkins", "/var/lib/jenkins/jobs/#{fetch(:application)}/config.xml"
119
+ execute :sudo, :chmod, "644", "/var/lib/jenkins/jobs/#{fetch(:application)}/config.xml"
120
+ execute :sudo, "service jenkins restart"
121
+ end
122
+ end
97
123
  end
98
124
  end
99
125
 
@@ -128,6 +154,7 @@ end
128
154
  before "deploy:updating", "deploy:make_dirs"
129
155
  after "deploy:symlink:linked_dirs", "deploy:upload"
130
156
  after "deploy:symlink:linked_dirs", "deploy:add_symlinks"
157
+ after "deploy:publishing", "deploy:set_up_jenkins"
131
158
  after "deploy:publishing", "deploy:prepare_logrotate"
132
159
  after "deploy:publishing", "deploy:restart_nginx"
133
160
  after "deploy:publishing", "deploy:restart_logstash"
@@ -1,3 +1,3 @@
1
1
  module Capun
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.20"
3
3
  end
@@ -15,6 +15,11 @@ module Capun
15
15
  @username = ask("Basic authentication username [ex.: mike]:")
16
16
  @password = ask("Basic authentication password [ex.: secret]:")
17
17
  end
18
+ @addJenkins = ask("Would you like to add Jenkins configuration file? [Y/n]").capitalize == 'Y'
19
+ @addNewRelic = ask("Would you like to add New Relic configuration file? [Y/n]").capitalize == 'Y'
20
+ if @addNewRelic
21
+ @newRelicKey = ask("New relic key:")
22
+ end
18
23
  @addELK = ask("Would you like to add ELK-compatible logging? [Y/n]").capitalize == 'Y'
19
24
  @addlogrotate = ask("Would you like to add logrotate configuration to stage? [Y/n]").capitalize == 'Y'
20
25
  end
@@ -52,7 +57,6 @@ module Capun
52
57
  end
53
58
 
54
59
  def add_ELK
55
-
56
60
  if @addELK
57
61
  #coping logstash config
58
62
  copy_file "logstash.config.erb", "config/deploy/logstash.config.erb"
@@ -81,6 +85,23 @@ module Capun
81
85
  end
82
86
  end
83
87
 
88
+ def add_jenkins
89
+ if @addJenkins
90
+ copy_file "jenkins.config.xml.erb", "config/deploy/jenkins.config.xml.erb"
91
+ append_to_file "config/deploy/#{singular_name}.rb", "\nset :addJenkins, true"
92
+ end
93
+ end
94
+
95
+ def add_newrelic
96
+ if @addNewRelic
97
+ copy_file "newrelic.yml.erb", "config/deploy/newrelic.yml.erb"
98
+ gem "newrelic_rpm"
99
+ inside Rails.root do
100
+ run "bundle install --quiet"
101
+ end
102
+ append_to_file "config/deploy/#{singular_name}.rb", "\nset :addNewRelic, true\nset :newRelicKey, \"#{@newRelicKey}\""
103
+ end
104
+ end
84
105
  end
85
106
  end
86
107
  end
@@ -0,0 +1,78 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <project>
3
+ <actions/>
4
+ <description></description>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties></properties>
7
+ <scm class="hudson.plugins.git.GitSCM" plugin="git">
8
+ <configVersion>2</configVersion>
9
+ <userRemoteConfigs>
10
+ <hudson.plugins.git.UserRemoteConfig>
11
+ <name></name>
12
+ <refspec></refspec>
13
+ <url><%= fetch(:repo_url) %></url>
14
+ </hudson.plugins.git.UserRemoteConfig>
15
+ </userRemoteConfigs>
16
+ <branches>
17
+ <hudson.plugins.git.BranchSpec>
18
+ <name><%= fetch(:branch) %></name>
19
+ </hudson.plugins.git.BranchSpec>
20
+ </branches>
21
+ <disableSubmodules>false</disableSubmodules>
22
+ <recursiveSubmodules>false</recursiveSubmodules>
23
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
24
+ <authorOrCommitter>false</authorOrCommitter>
25
+ <clean>false</clean>
26
+ <wipeOutWorkspace>false</wipeOutWorkspace>
27
+ <pruneBranches>false</pruneBranches>
28
+ <remotePoll>false</remotePoll>
29
+ <ignoreNotifyCommit>false</ignoreNotifyCommit>
30
+ <useShallowClone>false</useShallowClone>
31
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
32
+ <gitTool>Default Git</gitTool>
33
+ <submoduleCfg class="list"/>
34
+ <relativeTargetDir></relativeTargetDir>
35
+ <reference></reference>
36
+ <excludedRegions></excludedRegions>
37
+ <excludedUsers></excludedUsers>
38
+ <gitConfigName></gitConfigName>
39
+ <gitConfigEmail></gitConfigEmail>
40
+ <skipTag>false</skipTag>
41
+ <includedRegions></includedRegions>
42
+ <scmName></scmName>
43
+ </scm>
44
+ <canRoam>true</canRoam>
45
+ <disabled>false</disabled>
46
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
47
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
48
+ <authToken><%= Digest::MD5.hexdigest(fetch(:application) + Time.now.to_f.to_s) %></authToken>
49
+ <triggers/>
50
+ <concurrentBuild>false</concurrentBuild>
51
+ <builders>
52
+ <hudson.tasks.Shell>
53
+ <command>#!/bin/bash
54
+ source ~/.bash_profile
55
+ rvm use <%= fetch(:rvm1_ruby_version) %>
56
+ ln -s ../../common/application.yml config/application.yml
57
+ ln -s ../../../common/secret_token.rb config/initializers/secret_token.rb
58
+
59
+ bundle install
60
+
61
+ mkdir features/reports
62
+ mkdir spec/reports
63
+ mkdir ./../htmlreports
64
+ bundle exec cap <%= fetch(:stage) %> deploy
65
+
66
+ bundle exec rake db:create:all
67
+ bundle exec rake db:migrate
68
+ bundle exec rake db:test:prepare
69
+ bundle exec rake ci:setup:rspec spec RAILS_ENV=test
70
+ bundle exec rake ci:setup:cucumber features RAILS_ENV=test
71
+ bundle exec cucumber features --format html --out features/reports/report.html
72
+ bundle exec rspec --format html > spec/reports/report.html
73
+ </command>
74
+ </hudson.tasks.Shell>
75
+ </builders>
76
+ <publishers/>
77
+ <buildWrappers/>
78
+ </project>
@@ -0,0 +1,44 @@
1
+ #
2
+ # This file configures the New Relic Agent. New Relic monitors Ruby, Java,
3
+ # .NET, PHP, Python and Node applications with deep visibility and low
4
+ # overhead. For more information, visit www.newrelic.com.
5
+ #
6
+ # This configuration file is custom generated for Oblakogroup
7
+ #
8
+ # For full documentation of agent configuration options, please refer to
9
+ # https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
10
+
11
+ common: &default_settings
12
+ # Required license key associated with your New Relic account.
13
+ license_key: <%= fetch(:newRelicKey) %>
14
+
15
+ # Your application name. Renaming here affects where data displays in New
16
+ # Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
17
+ app_name: <%= fetch(:application) %>
18
+
19
+ # To disable the agent regardless of other settings, uncomment the following:
20
+ # agent_enabled: false
21
+
22
+ # Logging level for log/newrelic_agent.log
23
+ log_level: info
24
+
25
+
26
+ # Environment-specific settings are in this section.
27
+ # RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.
28
+ # If your application has other named environments, configure them here.
29
+ development:
30
+ <<: *default_settings
31
+ app_name: <%= fetch(:application) %> (Development)
32
+
33
+ # NOTE: There is substantial overhead when running in developer mode.
34
+ # Do not use for production or load testing.
35
+ developer_mode: true
36
+
37
+ test:
38
+ <<: *default_settings
39
+ # It doesn't make sense to report to New Relic from automated test runs.
40
+ monitor_mode: false
41
+
42
+ production:
43
+ <<: *default_settings
44
+ app_name: <%= fetch(:application) %> (Production)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Zamylin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,10 +132,12 @@ files:
132
132
  - lib/generators/capun/templates/basic_authenticatable.rb.erb
133
133
  - lib/generators/capun/templates/database.yml.erb
134
134
  - lib/generators/capun/templates/deploy.rb.erb
135
+ - lib/generators/capun/templates/jenkins.config.xml.erb
135
136
  - lib/generators/capun/templates/lograge_env_config.excerpt
136
137
  - lib/generators/capun/templates/lograge_initializer.rb
137
138
  - lib/generators/capun/templates/logrotate.config.erb
138
139
  - lib/generators/capun/templates/logstash.config.erb
140
+ - lib/generators/capun/templates/newrelic.yml.erb
139
141
  - lib/generators/capun/templates/nginx.conf.erb
140
142
  - lib/generators/capun/templates/stage.rb.erb
141
143
  - lib/generators/capun/templates/unicorn.config.rb.erb