I need to have two project. One is to set up the server. The other is the web app. I’m trying to use SaltStack to do this via Vagrant. What I want to happen is that after the server is provisioned, I want to be able to call to the folder where the web app project lives and look for a salt stack and start a new provisioning. I maybe off on the logo here, but the short of it is right now I can make the server. That only way to get the app in there is to pollute the server salt folders with
.sls
and pillars and such with the app’s. I need to do something more like,Vagrant.configure("2") do |config| #sample vagrant salt config.vm.synced_folder "provision/salt", "/srv/salt" config.vm.provision :salt do |salt| salt.bootstrap_script = 'provision/bootstrap_salt.sh' salt.install_type = install_type salt.verbose = verbose_output salt.minion_config = "provision/salt/minions/vag.conf" salt.run_highstate = true end end
which would run normal, but then at the last
.sls
, lets call itfinal.sls
, we make a call out to a folder that is containing the app and the salt stack that would deploy it’s state. Something like:|-/www - the www host folder that comes with this project | |-/{project name} - the project folder | |--/html - | the web root for this project | |--/provision - | the provisioner folder for the project to run after the server base | |--/salt - | the salt provisioner | |--/minions - | salt minions folder | |--/pillar - | salt pillar folder | |--top.sls - | salt top file that sets things in line | |--/stage - | staging folder for installers
Which that would be a
PROJECT
that is in the www folder of the server project that looks like|-/server_base - the server base | |--/provision - | the provisioner folder for the server base | |--/salt - | the salt provisioner | |--/minions - | salt minions folder | |--/pillar - | salt pillar folder | |--top.sls - | salt top file that sets things in line | |--/www - | www folder that holds the project shown above
What I would think I would do is call maybe ?
highstate
? as acwd.run
from the last.sls
that thetop.sls
defines. So right before the end of the salt provisioning, it starts a sub provisioning from thewww/{project}
folder.
Answer
BEGIN EDIT
As per the comments section below, I have not answered the question which is the following: How to pull from two different sources in salt. Here’s an example of how to do that in salt.
project1: <- Id declaration
file.recurse:
- source: Location of your project's source
- name: Destination in which you want to put your project's source
project2: <- Second unique id declaration
file.recurse
- source: Location of your second project's source
- name: Destination in which you want to put your second project's source
- require: <- Optional, ensure project2 doesn't copy files over until project1 has copied over
file.recurse: project1
You can find more details here.
END EDIT
I think you are asking the following question. How do I ensure that I install and configure my server and then install my app? Salt has a built-in mechanism known as requisites which will guarantee that one salt state will run after another. So instead of running two separate salt calls to run first.sls and second.sls, you might use a simplified setup like the following.
You would have something like the following to install your server.
apache:
pkg.installed
And then, in the state file for your app, you would just require that the server be installed before you copy over your project directory.
myapp:
file.recurse:
- source: location of your www folder
- name: Destination for your www folder
- require:
- pkg.installed: apache
- other_requirement: other_requirement
The above sample would guarantee that apache is installed before your project source directory is copied over to the appropriate location and you would only need to have salt run highstate once.
Attribution
Source : Link , Question Author : Quantum , Answer Author : Jason Zhu