Page MenuHomeDevCentral

D3013.id7714.diff
No OneTemporary

D3013.id7714.diff

diff --git a/map.jinja b/map.jinja
--- a/map.jinja
+++ b/map.jinja
@@ -175,7 +175,7 @@
'bats': 'bats-core',
'boost': 'boost-all',
'certbot': 'py39-certbot',
- 'composer': 'php-composer',
+ 'composer': 'php82-composer2',
'cppunit': 'cppunit',
'djvulibre': 'djvulibre',
'exiftool': 'p5-Image-ExifTool-devel',
diff --git a/roles/webserver-alkane/alkane/files/alkane.conf b/roles/webserver-alkane/alkane/files/alkane.conf
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/alkane.conf
@@ -0,0 +1,21 @@
+# -------------------------------------------------------------
+# Alkane :: Configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: BSD-2-Clause
+# Source file: roles/webserver-alkane/alkane/files/alkane.conf
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+roots:
+ db: /var/db/alkane
+ sites: /var/wwwroot
+ recipes: /usr/local/libexec/alkane
+
+site_directory_template: "%domain%.%tld%/%subdomain%"
diff --git a/roles/webserver-alkane/alkane/files/alkane.rc b/roles/webserver-alkane/alkane/files/alkane.rc
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/alkane.rc
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------
+# Alkane :: Nasqueron PaaS for static and PHP sites
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/alkane.rc
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+alkane_enable=YES
+alkane_address={{ address }}
diff --git a/roles/webserver-alkane/alkane/files/recipes/_lib/git-clone.sh b/roles/webserver-alkane/alkane/files/recipes/_lib/git-clone.sh
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/recipes/_lib/git-clone.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Nasqueron PaaS :: Alkane :: Recipe for deployment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/recipes/_lib/git-clone.sh
+# Action: init
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+GIT_DEFAULT_BRANCH=main
+
+# -------------------------------------------------------------
+# Parse context
+# - URL
+# - branch
+#
+# Formats:
+# - JSON payload {"url": "...", "branch": "production
+# - String, will only parse it as URL
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ "$(printf %.1s "$ALKANE_SITE_CONTEXT")" = "{" ]; then
+ # Parses JSON object
+ GIT_URL=$(echo "$ALKANE_SITE_CONTEXT" | jq .url)
+ GIT_BRANCH=$(echo "$ALKANE_SITE_CONTEXT" | jq .branch)
+
+ if [ "$GIT_BRANCH" = "null" ]; then
+ GIT_BRANCH=$GIT_DEFAULT_BRANCH
+ fi
+else
+ GIT_URL=$ALKANE_SITE_CONTEXT
+ GIT_BRANCH=$GIT_DEFAULT_BRANCH
+fi
+
+# -------------------------------------------------------------
+# Ensure directory doesn't exist
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ -d "$ALKANE_SITE_PATH/.git" ]; then
+ echo "$ALKANE_SITE_PATH repository already exists." >&2
+ exit 1
+fi
+
+# -------------------------------------------------------------
+# Update Git repository
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+git clone "$GIT_URL" "$ALKANE_SITE_PATH"
+cd "$ALKANE_SITE_PATH"
+git switch "$GIT_BRANCH"
diff --git a/roles/webserver-alkane/alkane/files/recipes/_lib/git-pull.sh b/roles/webserver-alkane/alkane/files/recipes/_lib/git-pull.sh
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/recipes/_lib/git-pull.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Nasqueron PaaS :: Alkane :: Recipe for deployment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/recipes/_lib/git-pull.sh
+# Action: update
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+# -------------------------------------------------------------
+# Update Git repository
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+cd "$ALKANE_SITE_PATH"
+git diff-index --quiet HEAD && git pull
diff --git a/roles/webserver-alkane/alkane/files/recipes/_lib/install-packages.sh b/roles/webserver-alkane/alkane/files/recipes/_lib/install-packages.sh
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/recipes/_lib/install-packages.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Nasqueron PaaS :: Alkane :: Recipe for deployment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/recipes/_lib/install-package.sh
+# Action: init
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+cd "$ALKANE_SITE_PATH"
+
+if [ -f "composer.json" ]; then
+ if [ -d "$ALKANE_SITE_PATH/vendor" ]; then
+ echo "$ALKANE_SITE_PATH/vendor directory already exists." >&2
+ exit 1
+ fi
+
+ composer install
+fi
+
+if [ -f "package.json" ]; then
+ if [ -d "$ALKANE_SITE_PATH/node_modules" ]; then
+ echo "$ALKANE_SITE_PATH/node_modules directory already exists." >&2
+ exit 1
+ fi
+
+ yarn install
+fi
diff --git a/roles/webserver-alkane/alkane/files/recipes/_lib/standard-init.sh b/roles/webserver-alkane/alkane/files/recipes/_lib/standard-init.sh
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/recipes/_lib/standard-init.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Nasqueron PaaS :: Alkane :: Recipe for deployment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/recipes/_lib/standard-init.sh
+# Action: init
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+sh "$ALKANE_RECIPES_PATH/_lib/git-clone.sh"
+sh "$ALKANE_RECIPES_PATH/_lib/install-packages.sh"
diff --git a/roles/webserver-alkane/alkane/files/recipes/_lib/standard-update.sh b/roles/webserver-alkane/alkane/files/recipes/_lib/standard-update.sh
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/recipes/_lib/standard-update.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Nasqueron PaaS :: Alkane :: Recipe for deployment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/recipes/_lib/standard-update.sh
+# Action: update
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+sh "$ALKANE_RECIPES_PATH/_lib/git-pull.sh"
+sh "$ALKANE_RECIPES_PATH/_lib/update-packages.sh"
diff --git a/roles/webserver-alkane/alkane/files/recipes/_lib/update-packages.sh b/roles/webserver-alkane/alkane/files/recipes/_lib/update-packages.sh
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/files/recipes/_lib/update-packages.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Nasqueron PaaS :: Alkane :: Recipe for deployment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/webserver-alkane/alkane/files/recipes/_lib/update-package.sh
+# Action: update
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+cd "$ALKANE_SITE_PATH"
+
+if [ -f "composer.json" ]; then
+ if [ ! -d "$ALKANE_SITE_PATH/vendor" ]; then
+ echo "$ALKANE_SITE_PATH/vendor directory doesn't exist." >&2
+ exit 2
+ fi
+
+ composer update
+fi
+
+if [ -f "package.json" ]; then
+ if [ ! -d "$ALKANE_SITE_PATH/node_modules" ]; then
+ echo "$ALKANE_SITE_PATH/node_modules directory doesn't exist." >&2
+ exit 2
+ fi
+
+ yarn install
+fi
diff --git a/roles/webserver-alkane/alkane/init.sls b/roles/webserver-alkane/alkane/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/alkane/init.sls
@@ -0,0 +1,78 @@
+# -------------------------------------------------------------
+# Salt :: Alkane :: Nasqueron PaaS for static and PHP sites
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs, packages, services with context %}
+{% set network = salt['node.resolve_network']() %}
+
+# -------------------------------------------------------------
+# Software
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+alkane_software:
+ pkg.installed:
+ - name: alkane
+
+{{ dirs.etc }}/alkane.conf:
+ file.managed:
+ - source: salt://roles/webserver-alkane/alkane/files/alkane.conf
+
+# -------------------------------------------------------------
+# Recipes
+#
+# The _lib/ directoy offers ready-to-use solution for init or update
+# You can use them with:
+#
+# alkane_recipes:
+# foo.domain.tld:
+# init: git-clone.sh
+# update: git-pull.sh
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+recipes_dependencies:
+ pkg.installed:
+ - pkgs:
+ - {{ packages.composer }}
+ - git
+ - jq
+ - yarn
+
+/usr/local/libexec/alkane:
+ file.recurse:
+ - source: salt://roles/webserver-alkane/alkane/files/recipes
+ - dir_mode: 755
+ - file_mode: 555
+
+{% for site_name, recipes in pillar.get("alkane_recipes", {}).items() %}
+/usr/local/libexec/alkane/{{ site_name }}:
+ file.directory
+
+{% for action, recipe in recipes.items() %}
+/usr/local/libexec/alkane/{{ site_name }}/{{ action }}:
+ file.symlink:
+ - target: /usr/local/libexec/alkane/_lib/{{ recipe }}
+{% endfor %}
+
+{% endfor %}
+
+# -------------------------------------------------------------
+# Service
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if services.manager == "rc" %}
+
+/etc/rc.conf.d/alkane:
+ file.managed:
+ - source: salt://roles/webserver-alkane/alkane/files/alkane.rc
+ - template: jinja
+ - context:
+ address: {{ network["private_ipv4_address"] | default("localhost") }}
+
+alkane_service:
+ service.running:
+ - name: alkane
+
+{% endif %}
diff --git a/roles/webserver-alkane/init.sls b/roles/webserver-alkane/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/webserver-alkane/init.sls
@@ -0,0 +1,9 @@
+# -------------------------------------------------------------
+# Salt :: Alkane :: Nasqueron PaaS for static and PHP sites
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+include:
+ - .alkane
diff --git a/top.sls b/top.sls
--- a/top.sls
+++ b/top.sls
@@ -25,6 +25,7 @@
- roles/dbserver-mysql
- roles/dbserver-pgsql
- roles/devserver
+ - roles/webserver-alkane
- roles/webserver-core
- roles/webserver-legacy
'cloudhugger':
@@ -43,3 +44,4 @@
- roles/shellserver
'web-001':
- roles/webserver-core
+ - roles/webserver-alkane

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 19:30 (19 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2258761
Default Alt Text
D3013.id7714.diff (13 KB)

Event Timeline