Skip to content

Commit

Permalink
Possible fix for #78
Browse files Browse the repository at this point in the history
  • Loading branch information
tobami committed Jan 22, 2012
1 parent 3465f74 commit e1f53f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions littlechef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions littlechef/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion littlechef/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e1f53f0

Please sign in to comment.