Skip to content

Commit

Permalink
Merge pull request #2 from hatkirby/master
Browse files Browse the repository at this point in the history
Add support for Cap 3.7 and rvm/bundler
  • Loading branch information
aserafin authored Sep 11, 2017
2 parents 798b881 + cc93e81 commit 3ada7f1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Configurable options, shown here with defaults:

```ruby
set :foreman_systemd_roles, :all
set :foreman_systemd_export_format, 'upstart'
set :foreman_systemd_export_format, 'systemd'
set :foreman_systemd_export_path, '/etc/init'
set :foreman_systemd_flags, "--root=#{current_path}" # optional, default is empty string
set :foreman_systemd_target_path, release_path
Expand Down
2 changes: 1 addition & 1 deletion capistrano-foreman-systemd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_dependency 'capistrano', '~> 3.4.1'
spec.add_dependency 'capistrano', '~> 3.0'

spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'rake'
Expand Down
35 changes: 27 additions & 8 deletions lib/capistrano/tasks/foreman_systemd.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace :foreman_systemd do
Configurable options are:
set :foreman_systemd_roles, :all
set :foreman_systemd_export_format, 'upstart'
set :foreman_systemd_export_format, 'systemd'
set :foreman_systemd_export_path, '/etc/init'
set :foreman_systemd_flags, ''
set :foreman_systemd_target_path, release_path
Expand All @@ -18,21 +18,32 @@ namespace :foreman_systemd do

task :setup do
invoke :'foreman_systemd:export'

on roles fetch(:foreman_systemd_roles) do
as "root" do
execute :systemctl, "daemon-reload"
end
end

invoke :'foreman_systemd:enable'
invoke :'foreman_systemd:start'
end

desc 'Enables service in systemd'
task :enable do
on roles fetch(:foreman_systemd_roles) do
sudo :systemctl, "enable #{fetch(:foreman_systemd_app)}.target"
as "root" do
execute :systemctl, "enable #{fetch(:foreman_systemd_app)}.target"
end
end
end

desc 'Disables service in systemd'
task :disable do
on roles fetch(:foreman_systemd_roles) do
sudo :systemctl, "disable #{fetch(:foreman_systemd_app)}.target"
as "root" do
execute :systemctl, "disable #{fetch(:foreman_systemd_app)}.target"
end
end
end

Expand All @@ -52,30 +63,38 @@ namespace :foreman_systemd do
options[:port] = fetch(:foreman_systemd_port) if fetch(:foreman_systemd_port)
options[:user] = fetch(:foreman_systemd_user) if fetch(:foreman_systemd_user)

sudo :foreman, 'export', fetch(:foreman_systemd_export_format), fetch(:foreman_systemd_export_path),
options.map{ |k, v| "--#{k}='#{v}'" }, fetch(:foreman_systemd_flags)
as "root" do
execute :foreman, 'export', fetch(:foreman_systemd_export_format), fetch(:foreman_systemd_export_path),
options.map{ |k, v| "--#{k}='#{v}'" }, fetch(:foreman_systemd_flags)
end
end
end
end

desc 'Start the application services'
task :start do
on roles fetch(:foreman_systemd_roles) do
sudo :systemctl, "start #{fetch(:foreman_systemd_app)}.target"
as "root" do
execute :systemctl, "start #{fetch(:foreman_systemd_app)}.target"
end
end
end

desc 'Stop the application services'
task :stop do
on roles fetch(:foreman_systemd_roles) do
sudo :systemctl, "stop #{fetch(:foreman_systemd_app)}.target"
as "root" do
execute :systemctl, "stop #{fetch(:foreman_systemd_app)}.target"
end
end
end

desc 'Restart the application services'
task :restart do
on roles fetch(:foreman_systemd_roles) do
sudo :systemctl, "restart #{fetch(:foreman_systemd_app)}.target"
as "root" do
execute :systemctl, "restart #{fetch(:foreman_systemd_app)}.target"
end
end
end

Expand Down

0 comments on commit 3ada7f1

Please sign in to comment.