Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Cap 3.7 and rvm/bundler #2

Merged
merged 4 commits into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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