Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3766573
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
29 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d11b4cf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,6 @@
+all: generate-webcontent-index
+
+generate-webcontent-index:
+ tmpfile=`mktemp /tmp/make-rOPS-generate-webcontent-index.XXXXXX` ; \
+ utils/generate-webcontent-index.py > "$$tmpfile" ;\
+ mv "$$tmpfile" roles/webserver-content/init.sls
diff --git a/_modules/node.py b/_modules/node.py
index 8cc3a0a..91c86ff 100644
--- a/_modules/node.py
+++ b/_modules/node.py
@@ -1,171 +1,175 @@
# -*- coding: utf-8 -*-
# -------------------------------------------------------------
# Salt — Node execution module
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2017-10-21
# Description: Functions related to the nodes pillar entry
# License: BSD-2-Clause
# -------------------------------------------------------------
from salt.exceptions import CommandExecutionError, SaltCloudConfigError
def _get_all_nodes():
return __pillar__.get('nodes', {})
def get_all_properties(nodename=None):
'''
A function to get a node pillar configuration.
CLI Example:
salt * node.get_all_properties
'''
if nodename is None:
nodename = __grains__['id']
all_nodes = _get_all_nodes()
if nodename not in all_nodes:
raise CommandExecutionError(
SaltCloudConfigError(
"Node {0} not declared in pillar.".format(nodename)
)
)
return all_nodes[nodename]
def get(key, nodename=None):
'''
A function to get a node pillar configuration key.
CLI Example:
salt * node.get hostname
'''
return _get_property(key, nodename, None)
def _explode_key(k): return k.split(':')
def _get_first_key(k): return _explode_key(k)[0]
def _strip_first_key(k): return ':'.join(_explode_key(k)[1:])
def _get_property(key, nodename, default_value, parent=None):
if parent is None:
parent = get_all_properties(nodename)
if ':' in key:
first_key = _get_first_key(key)
if first_key in parent:
return _get_property(
_strip_first_key(key), nodename,
default_value, parent[first_key]
)
elif key in parent:
return parent[key]
return default_value
def list(key, nodename=None):
'''
A function to get a node pillar configuration.
Returns a list if found, or an empty list if not found.
CLI Example:
salt * node.list network:ipv4_aliases
'''
return _get_property(key, nodename, [])
def has(key, nodename=None):
'''
A function to get a node pillar configuration.
Returns a boolean, False if not found.
CLI Example:
salt * node.has network:ipv6_tunnel
'''
value = _get_property(key, nodename, False)
return bool(value)
def has_role(role, nodename=None):
'''
A function to determine if a node has the specified role.
Returns a boolean, False if not found.
CLI Example:
salt * node.has_role devserver
'''
return role in list('roles', nodename)
def filter_by_role(pillar_key, nodename=None):
'''
A function to filter a dictionary by roles.
The dictionary must respect the following structure:
- keys are role to check the current node against
- values are list of items
Returns a list, extending all the filtered lists.
CLI Example:
salt * node.filter_by_role web_content_sls
'''
roles = list('roles', nodename)
dictionary = __pillar__.get(pillar_key, {})
filtered_list = []
for role, items in dictionary.iteritems():
if role in roles:
filtered_list.extend(items)
return filtered_list
+def has_web_content(content, nodename=None):
+ return content in filter_by_role('web_content_sls', nodename)
+
+
def get_wwwroot(nodename=None):
'''
A function to determine the wwwroot folder to use.
Returns a string depending of the FQDN.
CLI Example:
salt * node.get_wwwroot
'''
hostname = _get_property("hostname", nodename, None)
if hostname is None:
raise CommandExecutionError(
SaltCloudConfigError(
"Node {0} doesn't have a hostname property".format(nodename)
)
)
if hostname.count('.') < 2:
return "wwwroot/{0}/www".format(hostname)
fqdn = hostname.split(".")
return "wwwroot/{1}/{0}".format(
".".join(fqdn[0:-2]),
".".join(fqdn[-2:])
)
diff --git a/_tests/data/forests.yaml b/_tests/data/forests.yaml
index 5b6f5a0..57ab359 100644
--- a/_tests/data/forests.yaml
+++ b/_tests/data/forests.yaml
@@ -1,41 +1,47 @@
forests:
- brethil
- fangorn
- lothlorien
nodes:
egladil:
forest: lothlorien
hostname: egladil.lothlorien.forest
roles:
- treecity
entwash:
forest: fangorn
hostname: entwash.node
roles:
- border
items_by_role:
treecity:
- Caras Galadhon
border:
- Onodlo
shellgroups_ubiquity:
- ubiquity
shellgroups_by_forest:
lothlorien:
- caras_galadhon
shellgroups:
ubiquity: {}
caras_galadhon:
members:
- amdir
- amroth
shellusers:
amdir: {}
amroth: {}
galadriel: {}
+
+web_content_sls:
+ treecity:
+ - .ll/carasgaladhon
+ border:
+ - .arda/onodlo
diff --git a/_tests/modules/test_node.py b/_tests/modules/test_node.py
index 9afa72a..e5afba5 100644
--- a/_tests/modules/test_node.py
+++ b/_tests/modules/test_node.py
@@ -1,46 +1,54 @@
import imp
import unittest
salt_test_case = imp.load_source('salt_test_case', "salt_test_case.py")
node = imp.load_source('node', "../_modules/node.py")
class Testinstance(unittest.TestCase, salt_test_case.SaltTestCase):
def setUp(self):
self.initialize_mocks()
self.instance = node
self.mock_pillar('data/forests.yaml')
self.mock_grains()
self.grains['id'] = 'egladil'
def test_get_wwwroot(self):
self.assertEqual("wwwroot/lothlorien.forest/egladil",
node.get_wwwroot())
self.assertEqual("wwwroot/entwash.node/www",
node.get_wwwroot('entwash'))
+ def test_has_web_content(self):
+ self.assertTrue(node.has_web_content('.ll/carasgaladhon'))
+ self.assertFalse(node.has_web_content('.arda/onodlo'))
+
+ self.assertTrue(node.has_web_content('.arda/onodlo', 'entwash'))
+
+ self.assertFalse(node.has_web_content('notexisting'))
+
def test_filter_by_role(self):
node_key = self.grains['id']
self.assertEqual(['Caras Galadhon'],
node.filter_by_role('items_by_role'))
self.assertEqual(['Onodlo'],
node.filter_by_role('items_by_role', 'entwash'))
# No role
self.pillar['nodes'][node_key]['roles'] = []
self.assertEqual([],
node.filter_by_role('items_by_role'))
# More than one role
self.pillar['nodes'][node_key]['roles'] = [
'border',
'treecity'
]
self.assertEqual(['Caras Galadhon', 'Onodlo'],
sorted(node.filter_by_role('items_by_role')))
diff --git a/pillar/top.sls b/pillar/top.sls
index d8228a4..4dcc090 100644
--- a/pillar/top.sls
+++ b/pillar/top.sls
@@ -1,21 +1,21 @@
# -------------------------------------------------------------
# Salt configuration for Nasqueron servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2016-04-10
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
base:
'*':
- core.hostnames
- core.users
- core.groups
- certificates.certificates
- nodes.nodes
- nodes.forests
+ - webserver.sites
ysul:
- paas-jails.jails
- - webserver-legacy.sites
- viperserv.bots
- viperserv.fantoir
diff --git a/pillar/webserver-legacy/sites.sls b/pillar/webserver/sites.sls
similarity index 82%
rename from pillar/webserver-legacy/sites.sls
rename to pillar/webserver/sites.sls
index 2c204f3..26a6be8 100644
--- a/pillar/webserver-legacy/sites.sls
+++ b/pillar/webserver/sites.sls
@@ -1,65 +1,79 @@
# -------------------------------------------------------------
# Salt — Sites to provision on the legacy web server
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
# -------------------------------------------------------------
# Domains we deploy
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
web_domains:
#
# Directly managed by Nasqueron
#
nasqueron:
- nasqueron.org
#
# Nasqueron members
#
nasqueron_members:
- dereckson.be
#
# Wolfplex
#
wolfplex:
- wolfplex.be
# -------------------------------------------------------------
# Static sites
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
web_static_sites:
nasqueron.org:
- www
- assets
- docker
- ftp
- trustspace
# -------------------------------------------------------------
# PHP sites
#
# Username must be unique and use max 31 characters.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
php_fpm_instances:
# PHP 7.1, generally installed as package/port
prod:
command: /usr/local/sbin/php-fpm
web_php_sites:
www.dereckson.be:
user: web-be-dereckson-www
source: wwwroot/dereckson.be/www
target: /var/wwwroot/dereckson.be/www
autochmod: True
php-fpm: prod
+# -------------------------------------------------------------
+# States
+#
+# Sites with states documenting how to build them
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+web_content_sls:
+ shellserver:
+ - .com/paysannerebelle
+ - .org/eglide
+ webserver-legacy:
+ - .be/dereckson
+ - .org/nasqueron/docs
+
# -------------------------------------------------------------
# Tweaks
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
web_autochmod:
- /var/wwwroot/dereckson.be/www
diff --git a/roles/shellserver/web-hosting/init.sls b/roles/shellserver/web-hosting/init.sls
index df1c467..2a3bf81 100644
--- a/roles/shellserver/web-hosting/init.sls
+++ b/roles/shellserver/web-hosting/init.sls
@@ -1,50 +1,63 @@
# -------------------------------------------------------------
# Salt — nginx configuration
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Eglide
# Created: 2016-11-08
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
{% from "map.jinja" import dirs with context %}
+{% set wwwgroup = "www-data" %}
# -------------------------------------------------------------
# Nginx configuration files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nginx_config_files:
file.recurse:
- name: {{ dirs.etc }}/nginx
- source: salt://roles/shellserver/web-hosting/files/{{ grains['id'] }}/nginx
- include_empty: True
- clean: False
- dir_mode: 755
- file_mode: 644
cmd.run:
- name: nginx -s reload
- onchanges:
- file: nginx_config_files
# -------------------------------------------------------------
# Nginx logs
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/var/log/www:
file.directory:
- user: root
- - group: www-data
+ - group: {{ wwwgroup }}
+ - dir_mode: 750
+
+/var/log/www/eglide.org:
+ file.directory:
+ - user: root
+ - group: {{ wwwgroup }}
+ - dir_mode: 750
+
+/var/log/www/paysannerebelle.com:
+ file.directory:
+ - user: hlp
+ - group: {{ wwwgroup }}
- dir_mode: 750
# -------------------------------------------------------------
# Site to serve when Host: header doesn't match a known vhost
#
# Typically, this occurs when a domain is configured in DNS,
# but not in nginx.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unknown_domain_files:
file.recurse:
- name: /var/wwwroot/unknown_domains
- source: salt://roles/shellserver/web-hosting/files/{{ grains['id'] }}/wwwroot-unknown
- dir_mode: 755
- file_mode: 644
diff --git a/roles/webserver-content/README.md b/roles/webserver-content/README.md
new file mode 100644
index 0000000..f4d8d42
--- /dev/null
+++ b/roles/webserver-content/README.md
@@ -0,0 +1,65 @@
+# Webserver content
+
+## Goal of this role
+
+This role provisions the `/var/wwwroot` folder with the website content,
+when there is a custom logic to prepare it, like a specific Git repository
+to clone, or a build process to follow.
+
+This roles does NOT describe web server configuration,
+which is done in other `webserver-` roles.
+
+## Structure
+
+This role doesn't follow the role/unit folder hierarchy.
+
+Instead, it follows a tld/domain/subdomain.sls logic.
+
+For example, the folder for the `*.acme.tld` sites will be `tld/acme`.
+This structure goal is to play nice with the Salt include syntax, as dots
+are a directory spearator.
+
+The bipbip.acme.tld site will be described in `tld/acme/bipbip.sls` file.
+
+## Add a new domain
+
+ 1. Create a new folder hierarchy for the domain
+ 2. Include a `init.sls` file for your subdomains
+ 3. Declare the new domain in pillar/webserver/sites.sls
+ 4. Regenerate the role index with utils/generate-webcontent-index.py (or make)
+ utils/generate-webcontent-index.py > roles/webserver-content/init.sls
+
+For example the tld/acme/init.sls file could be:
+```
+include:
+ - .www
+ - .acme
+```
+
+Alphabetical order is followed, but www is generally first.
+
+In the pillar file, website are assigned to a role.
+
+If you wish to deploy all the sites on one role, you can directly include
+the folder, and your init.sls will do the rest.
+
+If not, two strategies exist: you can use node.filter_by_role in your
+init.sls too or perhaps more simply you can document in init.sls this
+roles can't be deployed directly, and make references to sls files in
+the pillar (without final .sls extension).
+
+For example to deploy bipbip.acme.tld (`tld/acme/bipbip.sls`) on servers
+with the shellserver role:
+
+```
+shellserver:
+ - .tld/acme/bibpip
+```
+
+## Prune old files
+
+If you need to prune a former website, you can add
+the directory to the /hotfixes/old-directories.sls state.
+
+There is no need to revert your commit when the
+directories or files are deleted.
diff --git a/roles/webserver-legacy/be/dereckson/assets.sls b/roles/webserver-content/be/dereckson/assets.sls
similarity index 92%
rename from roles/webserver-legacy/be/dereckson/assets.sls
rename to roles/webserver-content/be/dereckson/assets.sls
index 4daae9b..dbd479e 100644
--- a/roles/webserver-legacy/be/dereckson/assets.sls
+++ b/roles/webserver-content/be/dereckson/assets.sls
@@ -1,25 +1,29 @@
# -------------------------------------------------------------
# Salt — Provision assets.dereckson.be website
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: DcK Area
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+{% if salt['node.has_web_content'](".org/nasqueron/assets") %}
+
# -------------------------------------------------------------
# Deploy /opt/staging/wwwroot/d.be/assets to assets.d.be
#
# !!! WARNING !!!
# This folder could contain non staged resources. As such,
# clean must be let at False.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/var/wwwroot/dereckson.be/assets:
file.recurse:
- source: salt://wwwroot/dereckson.be/assets
- exclude_pat: E@.git
- include_empty: True
- clean: False
- dir_mode: 755
- file_mode: 644
- user: dereckson.be
- group: web
+
+{% endif %}
diff --git a/roles/webserver-legacy/be/dereckson/init.sls b/roles/webserver-content/be/dereckson/init.sls
similarity index 97%
copy from roles/webserver-legacy/be/dereckson/init.sls
copy to roles/webserver-content/be/dereckson/init.sls
index 82322bf..ba4a3ab 100644
--- a/roles/webserver-legacy/be/dereckson/init.sls
+++ b/roles/webserver-content/be/dereckson/init.sls
@@ -1,10 +1,9 @@
# -------------------------------------------------------------
# Salt — Provision *.dereckson.be sites
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: DcK Area
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
include:
- .assets
- - .www
diff --git a/roles/webserver-legacy/be/dereckson/init.sls b/roles/webserver-content/com/paysannerebelle/init.sls
similarity index 68%
copy from roles/webserver-legacy/be/dereckson/init.sls
copy to roles/webserver-content/com/paysannerebelle/init.sls
index 82322bf..1392b31 100644
--- a/roles/webserver-legacy/be/dereckson/init.sls
+++ b/roles/webserver-content/com/paysannerebelle/init.sls
@@ -1,10 +1,9 @@
# -------------------------------------------------------------
-# Salt — Provision *.dereckson.be sites
+# Salt — Provision *.paysannerebelle.com sites
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Project: DcK Area
+# Project: Collectif des paysannes et paysans rebelles
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
include:
- - .assets
- - .www
+ - .robot
diff --git a/roles/webserver-content/com/paysannerebelle/robot.sls b/roles/webserver-content/com/paysannerebelle/robot.sls
new file mode 100644
index 0000000..5566158
--- /dev/null
+++ b/roles/webserver-content/com/paysannerebelle/robot.sls
@@ -0,0 +1,24 @@
+# -------------------------------------------------------------
+# Salt — Provision robot.paysannerebelle.com website
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Collectif des paysannes et paysans rebelles
+# Created: 2017-04-16
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% if salt['node.has_web_content'](".com/paysannerebelle") %}
+
+{% set wwwgroup = "www-data" %}
+
+# -------------------------------------------------------------
+# Site directory
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/var/wwwroot/paysannerebelle.com/robot:
+ file.directory:
+ - user: hlp
+ - group: {{ wwwgroup }}
+ - dir_mode: 711
+ - makedirs: True
+
+{% endif %}
diff --git a/roles/webserver-legacy/be/dereckson/init.sls b/roles/webserver-content/init.sls
similarity index 60%
rename from roles/webserver-legacy/be/dereckson/init.sls
rename to roles/webserver-content/init.sls
index 82322bf..8d50cdb 100644
--- a/roles/webserver-legacy/be/dereckson/init.sls
+++ b/roles/webserver-content/init.sls
@@ -1,10 +1,13 @@
# -------------------------------------------------------------
-# Salt — Provision *.dereckson.be sites
+# Salt — Webserver content
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Project: DcK Area
+# Project: Eglide
+# Created: 2017-11-23
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
include:
- - .assets
- - .www
+ - .be/dereckson
+ - .com/paysannerebelle
+ - .org/eglide
+ - .org/nasqueron/docs
diff --git a/roles/webserver-legacy/org/nasqueron/init.sls b/roles/webserver-content/org/eglide/init.sls
similarity index 75%
copy from roles/webserver-legacy/org/nasqueron/init.sls
copy to roles/webserver-content/org/eglide/init.sls
index 10c4a70..54989e1 100644
--- a/roles/webserver-legacy/org/nasqueron/init.sls
+++ b/roles/webserver-content/org/eglide/init.sls
@@ -1,9 +1,9 @@
# -------------------------------------------------------------
-# Salt — Provision *.nasqueron.org sites
+# Salt — Provision *.eglide.org sites
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# Project: Nasqueron
+# Project: Eglide
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
include:
- - .docs
+ - .www
diff --git a/roles/shellserver/eglide-website/init.sls b/roles/webserver-content/org/eglide/www.sls
similarity index 67%
rename from roles/shellserver/eglide-website/init.sls
rename to roles/webserver-content/org/eglide/www.sls
index f78802f..8373e32 100644
--- a/roles/shellserver/eglide-website/init.sls
+++ b/roles/webserver-content/org/eglide/www.sls
@@ -1,57 +1,38 @@
# -------------------------------------------------------------
# Salt — Provision www.eglide.org website
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Eglide
# Created: 2016-09-12
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+{% if salt['node.has_web_content'](".org/eglide") %}
+
# -------------------------------------------------------------
# Deploy /opt/staging/wwwroot/eglide.org/www to www.eglide.org
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{% set wwwroot = salt['node.get_wwwroot']() %}
{% set wwwuser = "www-data" %}
{% set wwwgroup = "www-data" %}
/var/{{ wwwroot }}:
file.directory:
- user: {{ wwwuser }}
- group: {{ wwwgroup }}
- dir_mode: 711
- makedirs: True
wwwroot_server:
file.recurse:
- name: /var/{{ wwwroot }}
- source: salt://{{ wwwroot }}
- exclude_pat: E@.git
- include_empty: True
- clean: True
- user: {{ wwwuser }}
- group: {{ wwwgroup }}
- dir_mode: 711
- file_mode: 644
-/var/wwwroot/paysannerebelle.com/robot/:
- file.directory:
- - user: hlp
- - group: {{ wwwgroup }}
- - dir_mode: 711
- - makedirs: True
-
-# -------------------------------------------------------------
-# Nginx logs
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-/var/log/www/eglide.org:
- file.directory:
- - user: root
- - group: {{ wwwgroup }}
- - dir_mode: 750
-
-/var/log/www/paysannerebelle.com:
- file.directory:
- - user: hlp
- - group: {{ wwwgroup }}
- - dir_mode: 750
+{% endif %}
diff --git a/roles/webserver-legacy/org/nasqueron/docs.sls b/roles/webserver-content/org/nasqueron/docs.sls
similarity index 95%
rename from roles/webserver-legacy/org/nasqueron/docs.sls
rename to roles/webserver-content/org/nasqueron/docs.sls
index 2a2a230..df89e49 100644
--- a/roles/webserver-legacy/org/nasqueron/docs.sls
+++ b/roles/webserver-content/org/nasqueron/docs.sls
@@ -1,46 +1,50 @@
# -------------------------------------------------------------
# Salt — Provision docs.nasqueron.org website
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+{% if salt['node.has_web_content'](".org/nasqueron/docs") %}
+
{% from "map.jinja" import packages with context %}
# -------------------------------------------------------------
# Base directroy
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/var/wwwroot/nasqueron.org/docs:
file.directory:
- user: deploy
- group: web
- dir_mode: 755
# -------------------------------------------------------------
# Deploy a rSW docs dir HTML build to docs.n.o/salt-wrapper
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/var/wwwroot/nasqueron.org/docs/salt-wrapper:
file.directory:
- user: deploy
- group: web
- dir_mode: 755
salt_wrapper_doc_build:
cmd.script:
- source: salt://roles/webserver-legacy/org/nasqueron/files/build-docs-salt-wrapper.sh
- args: /var/wwwroot/nasqueron.org/docs/salt-wrapper
- cwd: /tmp
- runas: deploy
- require:
- file: /var/wwwroot/nasqueron.org/docs/salt-wrapper
- pkg: sphinx
# -------------------------------------------------------------
# Software to build the docs
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sphinx:
pkg.installed:
- name: {{ packages.sphinx }}
+
+{% endif %}
diff --git a/roles/webserver-legacy/org/nasqueron/files/build-docs-salt-wrapper.sh b/roles/webserver-content/org/nasqueron/files/build-docs-salt-wrapper.sh
similarity index 100%
rename from roles/webserver-legacy/org/nasqueron/files/build-docs-salt-wrapper.sh
rename to roles/webserver-content/org/nasqueron/files/build-docs-salt-wrapper.sh
diff --git a/roles/webserver-legacy/org/nasqueron/init.sls b/roles/webserver-content/org/nasqueron/init.sls
similarity index 66%
rename from roles/webserver-legacy/org/nasqueron/init.sls
rename to roles/webserver-content/org/nasqueron/init.sls
index 10c4a70..421b6bd 100644
--- a/roles/webserver-legacy/org/nasqueron/init.sls
+++ b/roles/webserver-content/org/nasqueron/init.sls
@@ -1,9 +1,11 @@
# -------------------------------------------------------------
# Salt — Provision *.nasqueron.org sites
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
-include:
- - .docs
+# This section is intentionally left blank.
+
+# As Nasqueron sites are distributed among several servers,
+# per domain files should be directly included instead.
diff --git a/top.sls b/top.sls
index 5c2ae1a..12f4e5a 100644
--- a/top.sls
+++ b/top.sls
@@ -1,42 +1,42 @@
# -------------------------------------------------------------
# Salt configuration for Nasqueron servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2016-04-10
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
base:
'*':
- roles/core/rc
- roles/core/hostname
- roles/core/network
- roles/core/motd
- roles/core/rsyslog
- roles/core/salt
- roles/core/sshd
- roles/core/sysctl
- roles/core/users
+ - roles/webserver-content
'local':
- roles/saltmaster
'ysul':
- roles/paas-jails
- roles/dbserver-mysql
- roles/devserver
- roles/viperserv
- roles/webserver-core
- roles/webserver-legacy
- roles/webserver-varnish
'dwellers':
- roles/paas-docker/docker
- roles/paas-lxc/lxc
- roles/mastodon
'eglide':
- roles/webserver-core
- roles/shellserver/userland-software
- - roles/shellserver/eglide-website
- roles/shellserver/vhosts
- roles/shellserver/web-hosting
- roles/shellserver/database
- roles/shellserver/odderon
- roles/shellserver/bonjour-chaton
diff --git a/utils/generate-webcontent-index.py b/utils/generate-webcontent-index.py
new file mode 100755
index 0000000..195b7d0
--- /dev/null
+++ b/utils/generate-webcontent-index.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+
+# -------------------------------------------------------------
+# rOPS — regenerate roles/webserver-content/init.sls
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2017-11-24
+# Description: Read the web_content_sls pillar entry
+# and regenerate the webserver-content include.
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+
+import yaml
+
+
+# -------------------------------------------------------------
+# Table of contents
+# -------------------------------------------------------------
+#
+# :: Configuration
+# :: Update code
+# :: Run task
+#
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+pillar_file = "pillar/webserver/sites.sls"
+file_to_update = "roles/webserver-content/init.sls"
+
+
+# -------------------------------------------------------------
+# Update code
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def do_update(pillar_file, file_to_update):
+ print_header(file_to_update)
+ print("\ninclude:")
+ for site in get_sites(pillar_file):
+ print(" - {}".format(site))
+
+
+def get_pillar_entry(pillar_file, key):
+ with open(pillar_file) as fd:
+ pillar = yaml.load(fd.read())
+ return pillar[key]
+
+
+def get_sites(pillar_file):
+ sites = get_pillar_entry(pillar_file, 'web_content_sls')
+ return sorted([site for sublist in
+ [sites[role] for role in sites]
+ for site in sublist])
+
+
+def print_header(file_to_update):
+ with open(file_to_update) as fd:
+ for line in fd:
+ if not line.startswith("#"):
+ break
+ print(line, end="")
+
+
+# -------------------------------------------------------------
+# Run task
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+if __name__ == "__main__":
+ do_update(pillar_file, file_to_update)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Nov 24, 19:01 (5 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2258718
Default Alt Text
(29 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment