Permalink
Browse files

Catch upload_template error to display user-friendlier error message

Needs fabric fix to be finised
  • Loading branch information...
1 parent 5910c61 commit ab244426f798695d4f28a0a475e6adae856c5e96 @tobami committed Apr 30, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 littlechef/solo.py
View
@@ -90,9 +90,15 @@ def configure(current_node=None):
'environment': current_node.get('chef_environment', '_default'),
'verbose': "true" if env.verbose else "false"
}
- with hide('running', 'stdout'):
- upload_template(os.path.join(BASEDIR, 'solo.rb'), '/etc/chef/',
- context=data, use_sudo=True, backup=False, mode=0400)
+ with settings(hide('everything')):
+ try:
+ upload_template(os.path.join(BASEDIR, 'solo.rb'), '/etc/chef/',
+ context=data, use_sudo=True, backup=False, mode=0400)
+ except SystemExit:
+ error = ("Failed to upload '/etc/chef/solo.rb'\n"
+ "This can happen when the deployment user does not have a "
+ "home directory, which is needed as a temporary location")
+ abort(error)
with hide('stdout'):
sudo('chown root:root {0}'.format('/etc/chef/solo.rb'))

0 comments on commit ab24442

Please sign in to comment.