caktus / django-project-template

Django project template for startproject (Requires 2.2+)
211 stars 53 forks source link

Vagrant Setup #184

Closed mlavin closed 9 years ago

mlavin commented 9 years ago

Previously we were using the Salt provisioner in Vagrant to setup the box. This was installing the latest stable Salt rather than the version from the fabfile. This change makes it possible to setup the vagrant box using the same Salt bootstrap as staging/production. This revealed a few issues with how the minions were setup as well as how the deploy runs with the new margarita states. This also incorporates @copelco's changes from #180 and #181. It takes a few more commands to setup the vagrant box but it closely matches the live environments.

dpoirier commented 9 years ago

This isn't directly related to this pull, but for the GPG stuff to work, this change seems to be needed:

diff --git a/conf/master.conf b/conf/master.conf
index 2ff3128..f14d357 100644
--- a/conf/master.conf
+++ b/conf/master.conf
@@ -1,5 +1,7 @@
 state_output: mixed

+renderer: jinja | yaml | gpg
+
 fileserver_backend:
   - roots
mlavin commented 9 years ago

Currently that is declared in the pillar itself rather than globally https://github.com/caktus/django-project-template/blob/master/conf/pillar/staging.sls#L1 What error are you seeing with this branch that needs this update?

dpoirier commented 9 years ago

Oh, the #!yaml|gpg at the top of staging.sls? I was converting advisorhq's vagrant config so I didn't have that.

I was reading https://docs.saltstack.com/en/latest/ref/renderers/all/salt.renderers.gpg.html and it said you needed to add this to master.conf.

Without it, Salt tries to use the values without decrypting them and you get weird syntax errors.

mlavin commented 9 years ago

Let's just make this update.

dpoirier commented 9 years ago

Did we want to remove the GPG keys changes from this pull and consider them separately (after we've caught up with Salt bugs & releases)?

mlavin commented 9 years ago

Yes that's probably a good idea.

dpoirier commented 9 years ago

Can't figure this one out:

[09:40:43]dpoirier@caktus015:~/clients/caktus/django-project-template
$ fab vagrant margarita
[localhost] local: vagrant ssh-config
[127.0.0.1:2222] sudo: salt -G 'roles:salt-master' -linfo state.sls margarita 
[127.0.0.1:2222] out: vagrant-ubuntu-trusty-64:
[127.0.0.1:2222] out:     Data failed to compile:
[127.0.0.1:2222] out: ----------
[127.0.0.1:2222] out:     No matching sls found for 'margarita' in env 'base'
[127.0.0.1:2222] out: 

We do seem to have a margarita.sls under conf/salt.

mlavin commented 9 years ago

Haven't seen that one. I'll see if I can reproduce.

mlavin commented 9 years ago

Latest updates:

dpoirier commented 9 years ago

One more error I hit when deploying with no devs defined can be fixed with

diff --git a/conf/salt/project/devs.sls b/conf/salt/project/devs.sls
index be9b880..4cbaa14 100644
--- a/conf/salt/project/devs.sls
+++ b/conf/salt/project/devs.sls
@@ -1,7 +1,7 @@
 include:
   - users.groups

-{% if 'users' in pillar %}
+{% if 'users' in pillar  and pillar['users'] %}
 {% for user, args in pillar['users'].iteritems() %}
 {{ user }}:
   user.present:
dpoirier commented 9 years ago

:+1: after the fixes previously mentioned.

There are still issues, but I don't think they're related to these changes.

With 2015.5.2 (as currently in the fabfile), on the first deploy, I hit the familiar "any() takes exactly one argument (5 given)" error.

With 2015.5.3 (editing the fabfile), on the second deploy, I get a rabbit error:

"Error: vhost_already_exists: example_local"

which I'm guessing is the new off-by-one error.

mlavin commented 9 years ago

Yes I commented on the related Salt ticket which is half fixed on the 2015.5 branch but still broken in 2015.5.3. Merging this change and moving on to getting the RabbitMQ issues fixed.