Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provision With Salt #32

Merged
merged 49 commits into from
May 13, 2013
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c735f03
Strip out argyle/provisioning pieces of the fabfile.
Apr 26, 2013
6c1bb1d
Adding provision command which bootstraps Salt mininion.
Apr 26, 2013
b74d715
Update deploy to handle the initial clone. Don't SSH as the project u…
Apr 26, 2013
4361f3e
No longer using users here. Users will be created/managed by Salt.
Apr 26, 2013
16df2fa
Pull in common states from margarita repo. Add additional directory t…
Apr 26, 2013
551f3b8
Set the minion id and configure the pillar tree based on the current …
Apr 26, 2013
da434fd
Starting on local Salt states.
Apr 26, 2013
9c6e170
Adding environment pillars.
Apr 26, 2013
7673f87
Project and dev user pillars. Create web related directories in the w…
Apr 26, 2013
3982f52
Adding top pillar to include project name, dev users, current environ…
Apr 26, 2013
65f3b0b
Update root directory to match web state.
Apr 26, 2013
1d1991d
add nginx conf
copelco Apr 26, 2013
4c7d407
add supervisor conf
copelco Apr 26, 2013
7b73778
Remove old templates and package declarations.
Apr 26, 2013
1ba7d2d
Adding example secrets file and ignoring the actual files.
Apr 26, 2013
20582e6
Update Vagrantfile for 1.0 and Ubuntu 12.04
Apr 26, 2013
b35f569
Updating local db state file to create project user/db.
Apr 26, 2013
08b2b84
Updating README notes on new provisioning.
Apr 26, 2013
8e46ff1
Another minor README note.
Apr 26, 2013
6a3fb48
don't die on which calls; install git if it doesn't exist; fix salt_root
copelco Apr 26, 2013
7bff7d9
fix indent of example
copelco Apr 26, 2013
8357f0a
update Vagrantfile to work with new vagrant
copelco Apr 27, 2013
200d43c
fix virtualenv path; append source to activate script
copelco Apr 27, 2013
5dc4b32
add vagrant user
copelco Apr 27, 2013
22b2ad3
use info logging and pty=False
copelco Apr 27, 2013
3665a49
use daily version
copelco Apr 27, 2013
4eaf5cf
Upgrade to the latest Fabric.
Apr 29, 2013
6944a8d
Rsync excludes are always assumed to be relative.
Apr 29, 2013
656d8c0
add env_secrets state
copelco Apr 29, 2013
e4227cb
Merge branch 'salt-provision' of github.com:caktus/django-project-tem…
copelco Apr 29, 2013
b1d79e9
fix pillar top to load secrets properly
copelco Apr 29, 2013
a1e4ef0
Fix requirement in the activate script state and remove the nested pi…
Apr 29, 2013
3c104c8
Clean up tmp directories on the provision and don't set the default p…
Apr 29, 2013
b08c0d3
Update directory permissions for deployment.
May 3, 2013
b9b12dd
Add project path to the Python path on initial checkout.
May 3, 2013
2e46834
Update how gunicorn is run and how it gets the environment secrets.
May 3, 2013
ab52fbc
Restart Nginx/Supervisor when files change.
May 3, 2013
7554a6d
Install lessc command from NPM.
May 3, 2013
f14fe4a
Adding docs on server setup. See #30
May 3, 2013
3658382
Remove unused pieces of the fabfile.
May 3, 2013
2dea080
Update settings and Nginx configuration to store static and media res…
May 3, 2013
0ea01b6
Abort the deploy command if env.repo has not been set.
May 3, 2013
9ee1785
Include postgres version in the docs.
May 3, 2013
804cb85
Make it clear that the public SSH key should be added to the devs pil…
May 3, 2013
e17dfa2
Update /var/www directory structure and related configurations to mak…
May 4, 2013
e8a9067
Can't have duplicate extend declarations.
May 6, 2013
9a48dd0
Capture JSON output of the highstate call and look for states which d…
May 6, 2013
0a1ec51
Typos and other trival copy-editing
dpoirier May 6, 2013
10c598d
Open HTTP and HTTPS ports on the webserver by default. Fixes #29
May 10, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*/settings/local.py
public/static/
public/media/
secrets.sls
90 changes: 1 addition & 89 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,98 +57,10 @@ You should now be able to run the development server::
python manage.py runserver


Setup repository
------------------------

Before your project can be deployed to a server, the code needs to be
accessible in a git repository.

1. Add your project code to a git repo, hosted somewhere your server can clone it from.

2. Edit ``fabfile.py`` near the top and insert your repo's URL. E.g., change this::

env.repo = u'' # FIXME: Add repo URL

to this::

env.repo = u'[email protected]:account/reponame.git'



Server Provisioning
------------------------

The first step in creating a new server is to create users on the remote server. You
will need root user access with passwordless sudo. How you specify this user will vary
based on the hosting provider. EC2 and Vagrant use a private key file. Rackspace and
Linode use a user/password combination.

1. For each developer, put a file in the ``conf/users`` directory
containing their public ssh key, and named exactly the same as the
user to create on the server, which should be the same as the userid
on the local development system. (E.g. for user "dickens", the filename
must be "dickens", not "dickens.pub" or "user_dickens".)

2. Run this command to create users on the server::

fab -H <fresh-server-ip> -u <root-user> create_users

This will create a project user and users for all the developers.

3. Lock down SSH connections: disable password login and move
the default port from 22 to ``env.ssh_port``::

fab -H <fresh-server-ip> configure_ssh

4. Add the IP to the appropriate environment
function and provision it for its role. You can provision a new server with the
``setup_server`` fab command. It takes a list of roles for this server
('app', 'db', 'lb') or you can say 'all'::

fab staging setup_server:all


Vagrant Testing
------------------------

You can test the provisioning/deployment using `Vagrant <http://vagrantup.com/>`_.
Using the Vagrantfile you can start up the VM. This requires the ``lucid32`` box::

vagrant up

With the VM up and running, you can create the necessary users.
Put the developers' keys in ``conf/users`` as before, then
use these commands to create the users. The location of the key file
(/usr/lib/ruby/gems/1.8/gems/vagrant-1.0.2/keys/vagrant)
may vary on your system. Running ``locate keys/vagrant`` might
help find it::

fab -H 33.33.33.10 -u vagrant -i /usr/lib/ruby/gems/1.8/gems/vagrant-1.0.2/keys/vagrant create_users
fab vagrant setup_server:all
fab vagrant deploy

It is not necessary to reconfigure the SSH settings on the vagrant box.

The vagrant box forwards
port 80 in the VM to port 8080 on the host box. You can view the site
by visiting localhost:8080 in your browser.

You may also want to add::

33.33.33.10 dev.example.com

to your hosts (/etc/hosts) file.

You can stop the VM with ``vagrant halt`` and
destroy the box completely to retest the provisioning with ``vagrant destroy``.

For more information please review the Vagrant documentation.


Deployment
------------------------

For future deployments, you can deploy changes to a particular environment with
You can deploy changes to a particular environment with
the ``deploy`` command. This takes an optional branch name to deploy. If the branch
is not given, it will use the default branch defined for this environment in
``env.branch``::
Expand Down
11 changes: 6 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
config.vm.forward_port 80, 8080
config.vm.network :hostonly, "33.33.33.10"
Vagrant.configure("2") do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, guest: 80, host: 8089
config.vm.network :private_network, ip: "33.33.33.10"
end
Loading