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

Issue when having multiple roles and variables in each #54

Open
eni9889 opened this issue May 10, 2014 · 1 comment
Open

Issue when having multiple roles and variables in each #54

eni9889 opened this issue May 10, 2014 · 1 comment

Comments

@eni9889
Copy link

eni9889 commented May 10, 2014

If I define two roles:

ec2_roles   :name => :apiserver,
            :options => {:default=>true} ,
            :variables => {
                :domain => "apiserver.dev.instamotor.com",
                :thin_server_tag => "apiserver",
                :rackup_path => "apiserver/config.ru"
            }
ec2_roles   :name => :telegraph,
            :options => {:default=>true} ,
            :variables => {
                :domain => "telegraph.dev.instamotor.com",
                :thin_server_tag => "telegraph",
                :rackup_path => "telegraph/config.ru"
            }

And then have two tasks defined:

task :restart_apiserver, :roles => [:apiserver], :on_no_matching_servers => :continue do 
    thin_config_path = "#{current_path}/config/server/thin.#{domain}.yml"
    thin_rackup_path = "#{current_path}/#{rackup_path}"
    restart_thin  = "cd #{current_path} && bundle exec thin -C #{thin_config_path} -R #{thin_rackup_path} restart >> #{current_path}/log/#{thin_server_tag}.thin.log 2>&1"
    restart_nginx = "sudo service nginx restart" 

    run "#{restart_thin}"
    run "#{restart_nginx}"
end
task :restart_telegraph, :roles => [:telegraph] , :on_no_matching_servers => :continue do 
    thin_config_path = "#{current_path}/config/server/thin.#{domain}.yml"
    thin_rackup_path = "#{current_path}/#{rackup_path}"
    restart_thin  = "cd #{current_path} && bundle exec thin -C #{thin_config_path} -R #{thin_rackup_path} restart >> #{current_path}/log/#{thin_server_tag}.thin.log 2>&1"
    restart_nginx = "sudo service nginx restart" 

    run "#{restart_thin}"
    run "#{restart_nginx}"
end

When I call

cap integration telegraph apiserver deploy:restart

Only the apiserver variables get set in both the telegraph task and the apiserver task so both tasks end up calling the command

"cd /home/ubuntu/current && bundle exec thin -C /home/ubuntu/current/config/server/thin.apiserver.dev.instamotor.com.yml -R /home/ubuntu/current/apiserver/config.ru restart >> /home/ubuntu/current/log/apiserver.thin.log 2>&1"
@Rylon
Copy link
Contributor

Rylon commented Nov 14, 2014

There was a bug with role chaining that should be addressed in v1.8.0.pre2, but I suspect this issue is deeper than that. I don't think the variables are being isolated into the roles they are defined with. I expect for now you would need to run each role individually:

cap integration telegraph deploy:restart
cap integration apiserver deploy:restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants