From fc71dc5bb29e41ad1f5ee9bad7af162d9c2c82f4 Mon Sep 17 00:00:00 2001 From: ranl Date: Mon, 9 Dec 2013 13:46:58 +0200 Subject: [PATCH 1/3] salt-cloud: copying windows config after minion installation --- salt/utils/cloud.py | 49 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py index 6ddc7b1605..e3a85933b7 100644 --- a/salt/utils/cloud.py +++ b/salt/utils/cloud.py @@ -399,10 +399,34 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', # Shell out to smbclient to create C:\salt\conf\pki\minion win_cmd('smbclient {0}/c$ -c "mkdir salt; mkdir salt\\conf; mkdir salt\\conf\\pki; mkdir salt\\conf\\pki\\minion; exit;"'.format(creds)) # Shell out to smbclient to copy over minion keys - ## minion_pub, minion_pem, minion_conf + ## minion_pub, minion_pem kwargs = {'hostname': host, 'creds': creds} + if minion_pub: + smb_file('salt\\conf\\pki\\minion\\minion.pub', minion_pub, kwargs) + + if minion_pem: + smb_file('salt\\conf\\pki\\minion\\minion.pem', minion_pem, kwargs) + + # Shell out to smbclient to copy over win_installer + ## win_installer refers to a file such as: + ## /root/Salt-Minion-0.17.0-win32-Setup.exe + ## ..which exists on the same machine as salt-cloud + comps = win_installer.split('/') + local_path = '/'.join(comps[:-1]) + installer = comps[-1] + win_cmd('smbclient {0}/c$ -c "cd salttemp; prompt; lcd {1}; mput {2}; exit;"'.format( + creds, local_path, installer + )) + # Shell out to winexe to execute win_installer + ## We don't actually need to set the master and the minion here since + ## the minion config file will be set next via smb_file + win_cmd('winexe {0} "c:\\salttemp\\{1} /S /master={2} /minion-name={3}"'.format( + creds, installer, master, name + )) + + # Shell out to smbclient to copy over minion_conf if minion_conf: if not isinstance(minion_conf, dict): # Let's not just fail regarding this change, specially @@ -424,27 +448,7 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', salt_config_to_yaml(minion_conf, line_break='\r\n'), kwargs ) - - if minion_pub: - smb_file('salt\\conf\\pki\\minion\\minion.pub', minion_pub, kwargs) - - if minion_pem: - smb_file('salt\\conf\\pki\\minion\\minion.pem', minion_pem, kwargs) - - # Shell out to smbclient to copy over win_installer - ## win_installer refers to a file such as: - ## /root/Salt-Minion-0.17.0-win32-Setup.exe - ## ..which exists on the same machine as salt-cloud - comps = win_installer.split('/') - local_path = '/'.join(comps[:-1]) - installer = comps[-1] - win_cmd('smbclient {0}/c$ -c "cd salttemp; prompt; lcd {1}; mput {2}; exit;"'.format( - creds, local_path, installer - )) - # Shell out to winexe to execute win_installer - win_cmd('winexe {0} "c:\\salttemp\\{1} /S /master={2} /minion-name={3}"'.format( - creds, installer, master, name - )) + # Shell out to smbclient to delete C:\salttmp\ and installer file ## Unless keep_tmp is True if not keep_tmp: @@ -455,6 +459,7 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', win_cmd('smbclient {0}/c$ -c "rmdir salttemp; prompt; exit;"'.format( creds, )) + # Shell out to winexe to ensure salt-minion service started win_cmd('winexe {0} "sc start salt-minion"'.format( creds, From d8d6de7e211324717c464bca6b60411757c7aca7 Mon Sep 17 00:00:00 2001 From: ranl Date: Tue, 10 Dec 2013 11:22:26 +0200 Subject: [PATCH 2/3] salt-cloud: enforce mandatory windows config to windows minions --- salt/utils/cloud.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py index e3a85933b7..c67427e930 100644 --- a/salt/utils/cloud.py +++ b/salt/utils/cloud.py @@ -443,6 +443,15 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', salt_config_to_yaml(minion_grains, line_break='\r\n'), kwargs ) + # Add special windows minion configuration + # that must be in the minion config file + windows_minion_conf = { + 'ipc_mode': 'tcp', + 'root_dir': 'c:\salt', + 'pki_dir': '/conf/pki/minion', + 'multiprocessing': False, + } + minion_conf = dict(minion_conf, **windows_minion_conf) smb_file( 'salt\\conf\\minion', salt_config_to_yaml(minion_conf, line_break='\r\n'), From 68214b2c50686e0c4b0c61a617b43ad415d7d8e4 Mon Sep 17 00:00:00 2001 From: ranl Date: Tue, 10 Dec 2013 11:26:44 +0200 Subject: [PATCH 3/3] remove spaces from cloud utils --- salt/utils/cloud.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py index c67427e930..843361e68a 100644 --- a/salt/utils/cloud.py +++ b/salt/utils/cloud.py @@ -457,7 +457,6 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', salt_config_to_yaml(minion_conf, line_break='\r\n'), kwargs ) - # Shell out to smbclient to delete C:\salttmp\ and installer file ## Unless keep_tmp is True if not keep_tmp: @@ -468,7 +467,6 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', win_cmd('smbclient {0}/c$ -c "rmdir salttemp; prompt; exit;"'.format( creds, )) - # Shell out to winexe to ensure salt-minion service started win_cmd('winexe {0} "sc start salt-minion"'.format( creds,