diff --git a/salt/cloud/clouds/cloudstack.py b/salt/cloud/clouds/cloudstack.py index bb9325e9c2..87bbfb667b 100644 --- a/salt/cloud/clouds/cloudstack.py +++ b/salt/cloud/clouds/cloudstack.py @@ -267,7 +267,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/digital_ocean.py b/salt/cloud/clouds/digital_ocean.py index 5278da29ba..09d7cdaef7 100644 --- a/salt/cloud/clouds/digital_ocean.py +++ b/salt/cloud/clouds/digital_ocean.py @@ -340,7 +340,8 @@ def create(vm_): 'script': deploy_script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index ee35581f57..9aa0b1099a 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -1281,7 +1281,8 @@ def create(vm_=None, call=None): 'username': username, 'key_filename': key_filename, 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'tty': config.get_config_value( 'tty', vm_, __opts__, default=True diff --git a/salt/cloud/clouds/gogrid.py b/salt/cloud/clouds/gogrid.py index e547c8f531..36d1164dab 100644 --- a/salt/cloud/clouds/gogrid.py +++ b/salt/cloud/clouds/gogrid.py @@ -178,7 +178,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/joyent.py b/salt/cloud/clouds/joyent.py index a8953688d7..9a15c8e5d9 100644 --- a/salt/cloud/clouds/joyent.py +++ b/salt/cloud/clouds/joyent.py @@ -303,7 +303,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'tty': True, 'start_action': __opts__['start_action'], diff --git a/salt/cloud/clouds/libcloud_aws.py b/salt/cloud/clouds/libcloud_aws.py index 1a2fdacbdb..5121380757 100644 --- a/salt/cloud/clouds/libcloud_aws.py +++ b/salt/cloud/clouds/libcloud_aws.py @@ -456,7 +456,8 @@ def create(vm_): 'username': username, 'key_filename': key_filename, 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'tty': config.get_config_value( 'tty', vm_, __opts__, default=True diff --git a/salt/cloud/clouds/linode.py b/salt/cloud/clouds/linode.py index ea69d44024..cd3f59eb3c 100644 --- a/salt/cloud/clouds/linode.py +++ b/salt/cloud/clouds/linode.py @@ -185,7 +185,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/nova.py b/salt/cloud/clouds/nova.py index f51c7d22f1..d84417d1b0 100644 --- a/salt/cloud/clouds/nova.py +++ b/salt/cloud/clouds/nova.py @@ -556,7 +556,8 @@ def create(vm_): 'name': vm_['name'], 'sock_dir': __opts__['sock_dir'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/openstack.py b/salt/cloud/clouds/openstack.py index 17116fa798..2fbe81a17b 100644 --- a/salt/cloud/clouds/openstack.py +++ b/salt/cloud/clouds/openstack.py @@ -648,7 +648,8 @@ def create(vm_): 'name': vm_['name'], 'sock_dir': __opts__['sock_dir'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/parallels.py b/salt/cloud/clouds/parallels.py index ba923da949..c94c69aa1c 100644 --- a/salt/cloud/clouds/parallels.py +++ b/salt/cloud/clouds/parallels.py @@ -354,7 +354,8 @@ def create(vm_): 'script': deploy_script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/rackspace.py b/salt/cloud/clouds/rackspace.py index a0f1c19a6d..4724575ddb 100644 --- a/salt/cloud/clouds/rackspace.py +++ b/salt/cloud/clouds/rackspace.py @@ -351,7 +351,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/saltify.py b/salt/cloud/clouds/saltify.py index e40fcb23e8..2252cc07b5 100644 --- a/salt/cloud/clouds/saltify.py +++ b/salt/cloud/clouds/saltify.py @@ -98,7 +98,8 @@ def create(vm_): 'script': deploy_script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/softlayer-hw.py b/salt/cloud/clouds/softlayer-hw.py index f3d91095da..97cc717de9 100644 --- a/salt/cloud/clouds/softlayer-hw.py +++ b/salt/cloud/clouds/softlayer-hw.py @@ -551,7 +551,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/clouds/softlayer.py b/salt/cloud/clouds/softlayer.py index 81c35424e5..9b256c4928 100644 --- a/salt/cloud/clouds/softlayer.py +++ b/salt/cloud/clouds/softlayer.py @@ -382,7 +382,8 @@ def create(vm_): 'script': deploy_script.script, 'name': vm_['name'], 'deploy_command': config.get_config_value( - 'deploy_command', vm_, __opts__, default='/tmp/deploy.sh' + 'deploy_command', vm_, __opts__, + default='/tmp/.saltcloud/deploy.sh', ), 'start_action': __opts__['start_action'], 'parallel': __opts__['parallel'], diff --git a/salt/cloud/utils/__init__.py b/salt/cloud/utils/__init__.py index 3d91061f92..c326f7eb0e 100644 --- a/salt/cloud/utils/__init__.py +++ b/salt/cloud/utils/__init__.py @@ -391,7 +391,8 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', minion_pub=None, minion_pem=None, minion_conf=None, keep_tmp=False, script_args=None, script_env=None, port_timeout=15, preseed_minion_keys=None, - win_installer=None, master=None, **kwargs): + win_installer=None, master=None, tmp_dir='C:\salttmp', + **kwargs): ''' Copy the install files to a remote Windows box, and execute them ''' @@ -484,7 +485,6 @@ def deploy_windows(host, port=445, timeout=900, username='Administrator', def deploy_script(host, port=22, timeout=900, username='root', password=None, key_filename=None, script=None, - deploy_command='/tmp/deploy.sh', sudo=False, tty=None, name=None, pub_key=None, sock_dir=None, provider=None, conf_file=None, start_action=None, make_master=False, master_pub=None, master_pem=None, master_conf=None, @@ -492,7 +492,9 @@ def deploy_script(host, port=22, timeout=900, username='root', keep_tmp=False, script_args=None, script_env=None, ssh_timeout=15, make_syndic=False, make_minion=True, display_ssh_output=True, preseed_minion_keys=None, - parallel=False, sudo_password=None, **kwargs): + parallel=False, sudo_password=None, sudo=False, tty=None, + deploy_command='/tmp/.saltcloud/deploy.sh', + tmp_dir='/tmp/.saltcloud/', **kwargs): ''' Copy a deploy script to a remote server, execute it, and remove it ''' @@ -548,13 +550,17 @@ def deploy_script(host, port=22, timeout=900, username='root', root_cmd(subsys_command, tty, sudo, **kwargs) root_cmd('service sshd restart', tty, sudo, **kwargs) + root_cmd('mkdir -p {0}'.format(tmp_dir), tty, sudo, **kwargs) + root_cmd('chmod 700 {0}'.format(tmp_dir), tty, sudo, **kwargs) + # Minion configuration if minion_pem: - scp_file('/tmp/minion.pem', minion_pem, kwargs) - root_cmd('chmod 600 /tmp/minion.pem', tty, sudo, **kwargs) + scp_file('{0}/minion.pem'.format(tmp_dir), minion_pem, kwargs) + root_cmd('chmod 600 {0}/minion.pem'.format(tmp_dir), + tty, sudo, **kwargs) if minion_pub: - scp_file('/tmp/minion.pub', minion_pub, kwargs) + scp_file('{0}/minion.pub'.format(tmp_dir), minion_pub, kwargs) if minion_conf: if not isinstance(minion_conf, dict): @@ -568,23 +574,24 @@ def deploy_script(host, port=22, timeout=900, username='root', minion_grains = minion_conf.pop('grains', {}) if minion_grains: scp_file( - '/tmp/grains', + '{0}/grains'.format(tmp_dir), salt_config_to_yaml(minion_grains), kwargs ) scp_file( - '/tmp/minion', + '{0}/minion'.format(tmp_dir), salt_config_to_yaml(minion_conf), kwargs ) # Master configuration if master_pem: - scp_file('/tmp/master.pem', master_pem, kwargs) - root_cmd('chmod 600 /tmp/master.pem', tty, sudo, **kwargs) + scp_file('{0}/master.pem'.format(tmp_dir), master_pem, kwargs) + root_cmd('chmod 600 {0}/master.pem'.format(tmp_dir), + tty, sudo, **kwargs) if master_pub: - scp_file('/tmp/master.pub', master_pub, kwargs) + scp_file('{0}/master.pub'.format(tmp_dir), master_pub, kwargs) if master_conf: if not isinstance(master_conf, dict): @@ -597,13 +604,14 @@ def deploy_script(host, port=22, timeout=900, username='root', ) scp_file( - '/tmp/master', + '{0}/master'.format(tmp_dir), salt_config_to_yaml(master_conf), kwargs ) # XXX: We need to make these paths configurable - preseed_minion_keys_tempdir = '/tmp/preseed-minion-keys' + preseed_minion_keys_tempdir = '{0}/preseed-minion-keys'.format( + tmp_dir) if preseed_minion_keys is not None: # Create remote temp dir root_cmd( @@ -639,8 +647,9 @@ def deploy_script(host, port=22, timeout=900, username='root', # The actual deploy script if script: - scp_file('/tmp/deploy.sh', script, kwargs) - root_cmd('chmod +x /tmp/deploy.sh', tty, sudo, **kwargs) + scp_file('{0}/deploy.sh'.format(tmp_dir), script, kwargs) + root_cmd('chmod +x {0}/deploy.sh'.format(tmp_dir), + tty, sudo, **kwargs) newtimeout = timeout - (time.mktime(time.localtime()) - starttime) queue = None @@ -662,7 +671,7 @@ def deploy_script(host, port=22, timeout=900, username='root', # Run the deploy script if script: if 'bootstrap-salt' in script: - deploy_command += ' -c /tmp/' + deploy_command += ' -c {0}'.format(tmp_dir) if make_syndic is True: deploy_command += ' -S' if make_master is True: @@ -696,16 +705,18 @@ def deploy_script(host, port=22, timeout=900, username='root', # Upload our environ setter wrapper scp_file( - '/tmp/environ-deploy-wrapper.sh', + '{0}/environ-deploy-wrapper.sh'.format(tmp_dir), '\n'.join(environ_script_contents), kwargs ) root_cmd( - 'chmod +x /tmp/environ-deploy-wrapper.sh', + 'chmod +x {0}/environ-deploy-wrapper.sh'.format(tmp_dir), tty, sudo, **kwargs ) # The deploy command is now our wrapper - deploy_command = '/tmp/environ-deploy-wrapper.sh' + deploy_command = '{0}/environ-deploy-wrapper.sh'.format( + tmp_dir, + ) if root_cmd(deploy_command, tty, sudo, **kwargs) != 0: raise SaltCloudSystemExit( @@ -717,42 +728,57 @@ def deploy_script(host, port=22, timeout=900, username='root', # Remove the deploy script if not keep_tmp: - root_cmd('rm -f /tmp/deploy.sh', tty, sudo, **kwargs) - log.debug('Removed /tmp/deploy.sh') + root_cmd('rm -f {0}/deploy.sh'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/deploy.sh'.format(tmp_dir)) if script_env: root_cmd( - 'rm -f /tmp/environ-deploy-wrapper.sh', + 'rm -f {0}/environ-deploy-wrapper.sh'.format( + tmp_dir + ), tty, sudo, **kwargs ) - log.debug('Removed /tmp/environ-deploy-wrapper.sh') + log.debug( + 'Removed {0}/environ-deploy-wrapper.sh'.format( + tmp_dir + ) + ) if keep_tmp: - log.debug('Not removing deployment files from /tmp/') - - # Remove minion configuration - if not keep_tmp: + log.debug( + 'Not removing deployment files from {0}/'.format(tmp_dir) + ) + else: + # Remove minion configuration if minion_pub: - root_cmd('rm -f /tmp/minion.pub', tty, sudo, **kwargs) - log.debug('Removed /tmp/minion.pub') + root_cmd('rm -f {0}/minion.pub'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/minion.pub'.format(tmp_dir)) if minion_pem: - root_cmd('rm -f /tmp/minion.pem', tty, sudo, **kwargs) - log.debug('Removed /tmp/minion.pem') + root_cmd('rm -f {0}/minion.pem'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/minion.pem'.format(tmp_dir)) if minion_conf: - root_cmd('rm -f /tmp/grains', tty, sudo, **kwargs) - log.debug('Removed /tmp/grains') - root_cmd('rm -f /tmp/minion', tty, sudo, **kwargs) - log.debug('Removed /tmp/minion') + root_cmd('rm -f {0}/grains'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/grains'.format(tmp_dir)) + root_cmd('rm -f {0}/minion'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/minion'.format(tmp_dir)) # Remove master configuration if master_pub: - root_cmd('rm -f /tmp/master.pub', tty, sudo, **kwargs) - log.debug('Removed /tmp/master.pub') + root_cmd('rm -f {0}/master.pub'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/master.pub'.format(tmp_dir)) if master_pem: - root_cmd('rm -f /tmp/master.pem', tty, sudo, **kwargs) - log.debug('Removed /tmp/master.pem') + root_cmd('rm -f {0}/master.pem'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/master.pem'.format(tmp_dir)) if master_conf: - root_cmd('rm -f /tmp/master', tty, sudo, **kwargs) - log.debug('Removed /tmp/master') + root_cmd('rm -f {0}/master'.format(tmp_dir), + tty, sudo, **kwargs) + log.debug('Removed {0}/master'.format(tmp_dir)) # Remove pre-seed keys directory if preseed_minion_keys is not None: