oswaldlabs / chef-rundeck

Integrates Chef with RunDeck, we are referring users to https://github.com/atheiman/better-chef-rundeck as this repository is inactive at this time.
Apache License 2.0
97 stars 85 forks source link

Could not generate xml when using supervisord #61

Open albundy83 opened 9 years ago

albundy83 commented 9 years ago

Hello,

here the problem I encounter when I use supervisord :

[2015-02-11T08:59:36+01:00] ERROR: === could not generate xml for {"name"=>"XXXXXXXXX", "chef_environment"=>"int", "run_list"=>#<Chef::RunList:0x00000002bf58e0 @run_list_items=[#<Chef::RunList::RunListItem:0x00000002be13b8 @version=nil, @type=:role, @name="base">, #<Chef::RunList::RunListItem:0x00000002be12f0 @version=nil, @type=:role, @name="load_balancer">]>, "recipes"=>[], "roles"=>["base", "load_balancer"], "fqdn"=>"XXXXXXXXX", "hostname"=>"XXXXXXXXX", "kernel_machine"=>"x86_64", "kernel_os"=>"GNU/Linux", "platform"=>"debian", "platform_version"=>"7.8", "tags"=>[]}: undefined method unpack' for nil:NilClass [2015-02-11T08:59:36+01:00] ERROR: === could not generate xml for {"name"=>"XXXXXXXXX", "chef_environment"=>"int", "run_list"=>#<Chef::RunList:0x00000002be02b0 @run_list_items=[#<Chef::RunList::RunListItem:0x00000002ba4260 @version=nil, @type=:role, @name="base">, #<Chef::RunList::RunListItem:0x00000002ba40d0 @version=nil, @type=:role, @name="tomcat">, #<Chef::RunList::RunListItem:0x00000002ba4328 @version=nil, @type=:role, @name="backend">]>, "recipes"=>[], "roles"=>["base", "tomcat", "backend"], "fqdn"=>"XXXXXXXXX", "hostname"=>"XXXXXXXXX", "kernel_machine"=>"x86_64", "kernel_os"=>"GNU/Linux", "platform"=>"debian", "platform_version"=>"7.8", "tags"=>[]}: undefined methodunpack' for nil:NilClass

I have configured chef-rundeck like this in supervisord : [program:chef-rundeck-test] command=/usr/local/rvm/gems/ruby-2.2.0/wrappers/chef-rundeck -c /etc/chef/knife.rb -p 9981 --timeout 80 redirect_stderr=true stdout_logfile=/var/log/chef-rundeck-int.log

(It works perfectly when I start in in command line...)

Thanks a lot for your help and your great tool.

albundy83 commented 9 years ago

And is it possible to run 2 or 3 chef-rundeck instances in // ? Something like : /usr/local/rvm/gems/ruby-2.2.0/wrappers/chef-rundeck -c /etc/chef/knife-1.rb -p 9980 --timeout 80 /usr/local/rvm/gems/ruby-2.2.0/wrappers/chef-rundeck -c /etc/chef/knife-2.rb -p 9981 --timeout 80

jeunito commented 9 years ago

Happens to me too using upstart

jeunito commented 9 years ago

@albundy83 what did you end up doing? This worked for me via upstart:

script
exec su - ops -c "chef-rundeck -o 0.0.0.0 -c /path/to/knife.rb -t 3600"
end script
albundy83 commented 9 years ago

Hello, I have create an init.d script :

#/bin/sh
### BEGIN INIT INFO
# Provides:          chef-rundeck
# Required-Start:    
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts chef-rundeck at boot time
# Description:       Starts chef-rundeck at boot time 
### END INIT INFO

chefrundeck=/usr/local/rvm/gems/ruby-2.2.0/wrappers/chef-rundeck
keyspath=/etc/chef_servers/keys
pidpath=/var/lib/rundeck/var/run/chef-rundeck

case "$1" in
    start)
        echo "Starting chef-rundeck for all environments"
        nohup ${chefrundeck} -c ${keyspath}/vault13.gcn-lab.fr_knife.rb -p 9982 --timeout 80 -i dev -u root -P ${pidpath} 2>&1 >> /var/log/chefrundeck-dev.log &
        nohup ${chefrundeck} -c ${keyspath}/int-chef.gcn-eibp.com_knife.rb -p 9981 --timeout 80 -i int -u root -P ${pidpath} 2>&1 >> /var/log/chefrundeck-int.log &
        nohup ${chefrundeck} -c ${keyspath}/chef.gcn-eibp.com_knife.rb -p 9980 --timeout 80 -i prod -u root -P ${pidpath} 2>&1 >> /var/log/chefrundeck-prod.log &

        ;;
    stop)
        echo "Killing all chef-rundeck instances"
        for port in 9980 9981 9982
        do
            if [ -f ${pidpath}-${port}.pid ];
            then
                kill `cat ${pidpath}-${port}.pid`
            fi
        done

        ;;
    restart)
        $0 stop
        $0 start
        ;;
    status)
        echo "Current chef-rundeck running :"
        ;;
    *)
        echo 'Usage: $0 {start|stop|restart|status}'
        exit 1
esac 
nhuff commented 8 years ago

I just ran into this with runit and the problem turned out to be that chef-rundeck tries to get the username from the USER environment variable if you don't set it explicitly with -u. If USER is cleared or not set by the supervisor you get the above error unless you specify the user with -u.