1
- ======
1
+ .. _readme :
2
+
2
3
django
3
4
======
4
5
6
+ |img_travis | |img_sr |
7
+
8
+ .. |img_travis | image :: https://travis-ci.com/saltstack-formulas/django-formula.svg?branch=master
9
+ :alt: Travis CI Build Status
10
+ :scale: 100%
11
+ :target: https://travis-ci.com/saltstack-formulas/django-formula
12
+ .. |img_sr | image :: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
13
+ :alt: Semantic Release
14
+ :scale: 100%
15
+ :target: https://github.com/semantic-release/semantic-release
16
+
5
17
Set up and configure the Django web application framework.
6
18
7
- .. note ::
19
+ .. contents :: **Table of Contents**
20
+
21
+ General notes
22
+ -------------
23
+
24
+ See the full `SaltStack Formulas installation and usage instructions
25
+ <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html> `_.
26
+
27
+ If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section
28
+ <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas> `_.
29
+
30
+ If you want to use this formula, please pay attention to the ``FORMULA `` file and/or ``git tag ``,
31
+ which contains the currently released version. This formula is versioned according to `Semantic Versioning <http://semver.org/ >`_.
8
32
9
- See the full `Salt Formulas installation and usage instructions
10
- <http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html> `_.
33
+ See `Formula Versioning Section <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning >`_ for more details.
34
+
35
+ If you need (non-default) configuration, please pay attention to the ``pillar.example `` file and/or `Special notes `_ section.
36
+
37
+ Contributing to this repo
38
+ -------------------------
39
+
40
+ **Commit message formatting is significant!! **
41
+
42
+ Please see `How to contribute <https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst >`_ for more details.
43
+
44
+ Special notes
45
+ -------------
46
+
47
+ None
11
48
12
49
Available states
13
- ================
50
+ ----------------
14
51
15
52
.. contents ::
16
- :local:
53
+ :local:
17
54
18
55
``django ``
19
- ----------
56
+ ^^^^^^^^^^
20
57
21
58
Install Django from the system package manager. Note, the Django version
22
59
available varies by platform.
@@ -35,7 +72,7 @@ Example usage::
35
72
- pkg: django
36
73
37
74
``django.pip ``
38
- --------------
75
+ ^^^^^^^^^^^^^^
39
76
40
77
Install Django via pip.
41
78
@@ -54,7 +91,7 @@ Example usage::
54
91
55
92
56
93
Full-stack App Deployment
57
- =========================
94
+ -------------------------
58
95
59
96
This formula also provides an example of how Salt can be used to deploy a
60
97
Django app in a single command, using the `OverState System `_. It installs
@@ -148,10 +185,10 @@ following command:
148
185
149
186
150
187
Other Tips
151
- ==========
188
+ ----------
152
189
153
190
Create ``settings.py `` using data from Pillar
154
- ---------------------------------------------
191
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
155
192
156
193
The easiest way to create Django's ``settings.py `` file using data from Pillar
157
194
is to simply transform a dictionary in YAML into a dictionary in Python.
@@ -199,7 +236,7 @@ is to simply transform a dictionary in YAML into a dictionary in Python.
199
236
STATIC_ROOT: /var/www/mysite/django-tutorial/staticroot
200
237
201
238
Create ``settings.py `` with a template file
202
- -------------------------------------------
239
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
203
240
204
241
A more traditional (and flexible) method of creating the ``settings.py `` file
205
242
is to actually create the file as a template.
@@ -263,7 +300,7 @@ is to actually create the file as a template.
263
300
STATIC_ROOT = /var/www/mysite/django-tutorial/staticroot
264
301
265
302
Run ``syncdb `` or ``collectstatic `` automatically
266
- -------------------------------------------------
303
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
267
304
268
305
A wait state can be used to trigger ``django-admin.py syncdb `` or
269
306
``django-admin.py collectstatic `` automatically. The following example runs
@@ -302,3 +339,48 @@ project is updated.
302
339
- pythonpath: /path/to/mysite_project # optional
303
340
- watch:
304
341
- git: mysite
342
+
343
+ Testing
344
+ -------
345
+
346
+ Linux testing is done with ``kitchen-salt ``.
347
+
348
+ Requirements
349
+ ^^^^^^^^^^^^
350
+
351
+ * Ruby
352
+ * Docker
353
+
354
+ .. code-block :: bash
355
+
356
+ $ gem install bundler
357
+ $ bundle install
358
+ $ bin/kitchen test [platform]
359
+
360
+ Where ``[platform] `` is the platform name defined in ``kitchen.yml ``,
361
+ e.g. ``debian-9-2019-2-py3 ``.
362
+
363
+ ``bin/kitchen converge ``
364
+ ^^^^^^^^^^^^^^^^^^^^^^^^
365
+
366
+ Creates the docker instance and runs the ``django.pip `` main state, ready for testing.
367
+
368
+ ``bin/kitchen verify ``
369
+ ^^^^^^^^^^^^^^^^^^^^^^
370
+
371
+ Runs the ``inspec `` tests on the actual instance.
372
+
373
+ ``bin/kitchen destroy ``
374
+ ^^^^^^^^^^^^^^^^^^^^^^^
375
+
376
+ Removes the docker instance.
377
+
378
+ ``bin/kitchen test ``
379
+ ^^^^^^^^^^^^^^^^^^^^
380
+
381
+ Runs all of the stages above in one go: i.e. ``destroy `` + ``converge `` + ``verify `` + ``destroy ``.
382
+
383
+ ``bin/kitchen login ``
384
+ ^^^^^^^^^^^^^^^^^^^^^
385
+
386
+ Gives you SSH access to the instance for manual testing.
0 commit comments