Changing location of salt-cloud deploy.sh script

69 views
Skip to first unread message

Dhruv Malik

unread,
Jun 18, 2021, 5:14:22 AM6/18/21
to Salt-users
Hi all,

I am baking my AMI and setting no exec on /tmp. This restricts execution of scripts on /tmp.

Is there a way I can change the location of deploy.sh from /tmp  to /home/ec2-user ?

Dhruv Malik

unread,
Jun 24, 2021, 1:25:16 PM6/24/21
to Salt-users
No one?

Max Arnold

unread,
Jun 24, 2021, 5:28:51 PM6/24/21
to salt-...@googlegroups.com
You can't change the location of a cloud deploy shell script, but you can tweak the deploy command by specifying "deploy_command: sh /tmp/.saltcloud/deploy.sh" in a cloud profile:




пт, 25 июн. 2021 г. в 00:25, Dhruv Malik <dhruv...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/57a97a87-627c-4818-82cf-7a4c64144e81n%40googlegroups.com.

Dhruv Malik

unread,
Jun 25, 2021, 2:54:28 PM6/25/21
to Salt-users
hey Thank you!

The problem I am not facing is, salt-cloud uses random uuid in the deployment folder and the profile has /tmp/.saltcloud/deploy.sh and is unable to find it
This is the deployment folder of salt-cloud :
/tmp/.saltcloud-28b7ffeb-5fe8-4215-b3d6-8b56dfd438f1/deploy.sh

sftp> put  /tmp/tmp10r9lyzg /tmp/.saltcloud-28b7ffeb-5fe8-4215-b3d6-8b56dfd438f1/deploy.sh
Uploading /tmp/tmp10r9lyzg to /tmp/.saltcloud-28b7ffeb-5fe8-4215-b3d6-8b56dfd438f1/deploy.sh
/tmp/tmp10r9lyzg                                                                                                                                                                 100%  296KB  24.2MB/s   00:00
Warning: Permanently added '10.36.108.9' (ECDSA) to the list of known hosts.
Authorized users only. All activity will be monitored and reported.
Connection to 10.36.108.9 closed.
Warning: Permanently added '10.36.108.9' (ECDSA) to the list of known hosts.
Authorized users only. All activity will be monitored and reported.
Connection to 10.36.108.9 closed.
sh: /tmp/.saltcloud/deploy.sh: No such file or directory

Max Arnold

unread,
Jun 26, 2021, 2:01:53 AM6/26/21
to salt-...@googlegroups.com
A quick and dirty solution for this random uuid folder problem would be using a wildcard:

deploy_command: "sh /tmp/.saltcloud-*/deploy.sh"

Another option is to upload the bootstrap script into a different folder. Run "salt-cloud -u", then add something like this to your cloud profile:

myprofile:
  file_map:
    /etc/salt/cloud.deploy.d/bootstrap-salt.sh: /bootstrap-salt.sh
  deploy_command: "sh /bootstrap-salt.sh"

There are plenty of other pre/post install hooks in salt-cloud: https://twitter.com/SaltTips/status/1207967192903487489

However, because you are baking your own AMI anyway, it makes sense to embed salt-minion into it, disable the deploy script completely https://docs.saltproject.io/en/latest/topics/cloud/deploy.html#skipping-the-deploy-script and accept keys in some other way (automatically, based on grains https://docs.saltproject.io/en/latest/topics/tutorials/autoaccept_grains.html#tutorial-autoaccept-grains, or through salt-api). It will significantly speed up the VM provisioning time and allow using Terraform or other tools in addition to or instead of salt-cloud.

сб, 26 июн. 2021 г. в 01:54, Dhruv Malik <dhruv...@gmail.com>:

Dhruv Malik

unread,
Jun 28, 2021, 2:23:30 PM6/28/21
to Salt-users
Thank you so much! This wild card helped me fix the issue
Reply all
Reply to author
Forward
0 new messages