Skip to content
This repository
Browse code

Possible fix for #78

  • Loading branch information...
commit e1f53f0f4d146d100e11f3e1fe05a588c7a8ae9f 1 parent 3465f74
Miquel Torres authored January 22, 2012
14  littlechef/chef.py
@@ -69,15 +69,21 @@ def sync_node(node):
69 69
     It also injects the ipaddress to the node's config file if not already
70 70
     existent.
71 71
     """
  72
+    # Get merged attributes
  73
+    current_node = _build_node_data_bag()
72 74
     with lib.credentials():
73  
-        # Get merged attributes
74  
-        current_node = _build_node_data_bag()
75 75
         # Always configure Chef Solo
76 76
         solo.configure(current_node)
77  
-        # Everything was configured alright, so save the node configuration
78  
-        filepath = save_config(node, _get_ipaddress(node))
  77
+        ipaddress = _get_ipaddress(node)
  78
+    # Everything was configured alright, so save the node configuration
  79
+    # This is done without credentials, so that we keep the node name used
  80
+    # by the user and not the hostname or IP translated by .ssh/config
  81
+    filepath = save_config(node, ipaddress)
  82
+    with lib.credentials():
79 83
         try:
  84
+            # Synchronize the kitchen directory
80 85
             _synchronize_node(filepath)
  86
+            # Execute Chef Solo
81 87
             _configure_node()
82 88
         finally:
83 89
             _remove_local_node_data_bag()
4  littlechef/lib.py
@@ -453,4 +453,8 @@ def credentials(*args, **kwargs):
453 453
     if credentials.get('key_filename'):
454 454
         credentials['key_filename'] = os.path.expanduser(
455 455
                                         credentials['key_filename'])
  456
+    # If ssh config defines a different Hostname string (be it domain or IP),
  457
+    # override 'host_string'
  458
+    if 'hostname' in credentials:
  459
+        credentials['host_string'] = credentials['hostname'] 
456 460
     return settings(*args, **credentials)
3  littlechef/runner.py
@@ -118,7 +118,8 @@ def node(*nodes):
118 118
     if not(littlechef.__cooking__ and
119 119
             'node:' not in sys.argv[-1] and
120 120
             'nodes_with_role:' not in sys.argv[-1]):
121  
-        # If user didn't type recipe:X, role:Y or deploy_chef, just run configure
  121
+        # If user didn't type recipe:X, role:Y or deploy_chef,
  122
+        # configure the nodes
122 123
         for hostname in env.hosts:
123 124
             env.host = hostname
124 125
             env.host_string = hostname

0 notes on commit e1f53f0

Please sign in to comment.
Something went wrong with that request. Please try again.