Permalink
Browse files

Possible fix for #78

  • Loading branch information...
1 parent 3465f74 commit e1f53f0f4d146d100e11f3e1fe05a588c7a8ae9f @tobami committed Jan 22, 2012
Showing with 16 additions and 5 deletions.
  1. +10 −4 littlechef/chef.py
  2. +4 −0 littlechef/lib.py
  3. +2 −1 littlechef/runner.py
View
@@ -69,15 +69,21 @@ def sync_node(node):
It also injects the ipaddress to the node's config file if not already
existent.
"""
+ # Get merged attributes
+ current_node = _build_node_data_bag()
with lib.credentials():
- # Get merged attributes
- current_node = _build_node_data_bag()
# Always configure Chef Solo
solo.configure(current_node)
- # Everything was configured alright, so save the node configuration
- filepath = save_config(node, _get_ipaddress(node))
+ ipaddress = _get_ipaddress(node)
+ # Everything was configured alright, so save the node configuration
+ # This is done without credentials, so that we keep the node name used
+ # by the user and not the hostname or IP translated by .ssh/config
+ filepath = save_config(node, ipaddress)
+ with lib.credentials():
try:
+ # Synchronize the kitchen directory
_synchronize_node(filepath)
+ # Execute Chef Solo
_configure_node()
finally:
_remove_local_node_data_bag()
View
@@ -453,4 +453,8 @@ def credentials(*args, **kwargs):
if credentials.get('key_filename'):
credentials['key_filename'] = os.path.expanduser(
credentials['key_filename'])
+ # If ssh config defines a different Hostname string (be it domain or IP),
+ # override 'host_string'
+ if 'hostname' in credentials:
+ credentials['host_string'] = credentials['hostname']
return settings(*args, **credentials)
View
@@ -118,7 +118,8 @@ def node(*nodes):
if not(littlechef.__cooking__ and
'node:' not in sys.argv[-1] and
'nodes_with_role:' not in sys.argv[-1]):
- # If user didn't type recipe:X, role:Y or deploy_chef, just run configure
+ # If user didn't type recipe:X, role:Y or deploy_chef,
+ # configure the nodes
for hostname in env.hosts:
env.host = hostname
env.host_string = hostname

0 comments on commit e1f53f0

Please sign in to comment.