I'm trying to follow the guide, Provisioning a Rails Server Using Chef, deploy my setup my rails server using Chef Solo. When I try to run the setup_vps.sh in part the server keeps asking me for the root password. When I ctl-c
out of that it ask me for the password for deploy
user and doesn't accept that password either. Both the user have already been ssh-copy-id
previously and shouldn't even ask for the password.
{
"group": "wheel",
"port": 22,
"user": {
"name": "deploy",
"password": "$1$mywonderfullpassword/x/"
},
"run_list": [
"recipe[main]",
"recipe[main::users]",
"recipe[main::ssh]",
"recipe[main::nodejs]",
"recipe[main::rbenv]",
"recipe[main::redis]",
"recipe[main::nginx]",
"recipe[main::app]"
]
}
#!/bin/sh
# check for correct number of arguments
if [ $# -ne 3 ]; then
echo "Usage: $0 <user> <ip> <port>"
exit 1
fi
# set variables
USER=$1
IP=$2
PORT=$3
# upload key for root
# ssh-copy-id -i ~/.ssh/id_rsa.pub root@$IP
# install chef
cd config/chef && knife solo prepare root@$IP
# execute the run list
knife solo cook root@$IP
# upload key for user
# ssh-copy-id -i ~/.ssh/id_rsa.pub -p $PORT $USER@$IP
# upload app
cd ../.. && cap production setup:all
# restart nginx
ssh -p $PORT -t $USER@$IP 'sudo service nginx restart'
# create www directory
directory '/var/www' do
user node['user']['name']
group node['group']
mode 0755
end
# create shared directory structure for app
path = "/var/www/#{node['app']}/shared/config"
execute "mkdir -p #{path}" do
user node['user']['name']
group node['group']
creates path
end
# create database.yml file
template "#{path}/database.yml" do
source 'database.yml.erb'
mode 0640
owner node['user']['name']
group node['group']
end
puma_config "#{node['app']}"
# # set unicorn config
# template "/etc/init.d/puma_#{node['app']}" do
# source 'puma.sh.erb'
# mode 0755
# owner node['user']['name']
# group node['group']
# end
#
# # add init script link
# execute "update-rc.d puma_#{node['app']} defaults" do
# not_if "ls /etc/rc2.d | grep puma_#{node['app']}"
# end
./setup_server.sh: line 18: cd: config/chef: No such file or directory
/usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/chef-11.18.12/lib/chef/data_bag_item.rb:161: warning: circular argument reference - data_bag
Running Chef on 0.0.0.0...
Checking Chef version...
/usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:67:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
/usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:84:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
root@0.0.0.0's password:
Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.
deploy@0.0.0.0's password:
Permission denied, please try again.
deploy@0.0.0.0's password:
Permission denied, please try again.
deploy@0.0.0.0's password:
That guide is very out of date and not recommended. See https://github.com/poise/application_examples/blob/master/recipes/todo_rails.rb for a more modern example.