This commit is contained in:
meaz 2022-07-27 20:35:57 +02:00
commit d88e4328b3
14 changed files with 663 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.vagrant
.vagrant/*
*log
share/

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
MIT License Copyright (c) 2021 "Stichting Disroot.org"
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

9
Playbooks/cstate.yml Normal file
View File

@ -0,0 +1,9 @@
---
- hosts: cstate
roles:
- nginx
- cstate
vars_files:
- ../defaults/main.yml

25
README.MD Normal file
View File

@ -0,0 +1,25 @@
# Cstate - Ansible role
This role covers deployment, configuration and software updates of Cstate. This role is released under MIT Licence and we give no warranty for this piece of software. Currently supported OS - Debian.
You can deploy test instance using `Vagrantfile` attached to the role.
`vagrant up`
`ansible-playbook -b Playbooks/cstate.yml`
Then you can access cstate from your computer on http://192.168.33.20
## Playbook
The playbook includes nginx role and deploys entire stack needed to run Cstate. Additional role is also available in the Ansible roles repos in git.
## Guide
If you don't provide your own already-built site (with `cstate_repo` in `defaults/main.yml`), then the role uses the cstate example repo to build one. You may then deploy your site by copying the `share/public/` directory to your production web server.
Once done, you can create issues files inside the `share/content/issues/` folder on your host. Then use `ansible-playbook -b Playbooks/cstate.yml --tags generate` to build those page in the `public/` directory.
## Issue with vagrant
You may have to add `sendfile off;` to your Nginx config when using the role with Vagrant and a shared folder. See [info](https://www.vagrantup.com/docs/synced-folders/virtualbox)
## CHANGELOG
- **06.06.2022** - Create the role

21
Vagrantfile vendored Normal file
View File

@ -0,0 +1,21 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
#config.ssh.insert_key = false
config.vm.define "cstate" do |cstate|
cstate.vm.box = "generic/debian11"
cstate.vm.provider :libvirt do |libvirt|
libvirt.memory = 256
end
cstate.vm.network "forwarded_port", guest: 80, host: 8884, host_ip: "192.168.33.20"
cstate.vm.network "forwarded_port", guest: 443, host: 4444, host_ip: "192.168.33.20"
cstate.vm.network "forwarded_port", guest: 8080, host: 8081, host_ip: "192.168.33.20"
cstate.vm.network "private_network", ip: "192.168.33.20"
cstate.vm.synced_folder "share", "/var/www/cstate", owner: "www-data", group: "www-data"
end
end

88
defaults/main.yml Normal file
View File

@ -0,0 +1,88 @@
---
cstate_update: 'no' # 'yes' to update your own built repo with latest cstate
cstate_apt:
- hugo
- git
cstate_username: 'www-data'
cstate_group: 'www-data'
cstate_repo: 'https://github.com/cstate/example.git' # Replace by your own cstate repo once built and hosted.
cstate_dir: '/var/www/cstate'
# Config file
cstate_title: 'Eggsample Status'
cstate_languageCode: 'en'
cstate_defaultContentLanguage: 'en'
cstate_baseURL: 'https://state.example.com'
cstate_categories:
- name: North Coast
description: The main servers are located here.
closed: true
- name: Empty Category
- name: Uncategorized
untitled: true
cstate_systems:
- name: Gateway
category: North Coast
- name: Backup Gateway
category: North Coast
- name: Website
description: The web frontend for the application.
category: Uncategorized
link: https://example.com/
- name: API
description: The guts of the application.
category: Uncategorized
- name: Media Proxy
description: This is the service responsible for serving images, audio, and video. It is reliant on our CDN.
category: Uncategorized
cstate_dateFormat: 'January 2, 2006 at 3:04 PM UTC'
cstate_shortDateFormat: 15:04 UTC — Jan 2
cstate_useRelativeTime: 'true'
cstate_skipSeconds: 'false'
cstate_enableLastMod: 'true'
cstate_incidentHistoryFormat: 'yearly'
cstate_useLargeHeaderDesign: 'false'
cstate_disableIncidentHistory: 'false'
cstate_disableDarkMode: 'false'
cstate_useLogo: 'true'
cstate_logo: 'logo.png'
cstate_description: 'We continuously monitor the status of our services and if there are any interruptions, a note will be posted here.'
cstate_disableComplexCalculations : 'false'
cstate_incidentPostsPerPage: 10
cstate_brand: "#0a0c0f"
cstate_ok: "#008000"
cstate_disrupted: "#cc4400"
cstate_down: "#e60000"
cstate_notice: "#24478f"
cstate_alwaysKeepBrandColor: 'true'
cstate_headerTextColor: 'white'
#NGINX SETUP
nginx_default_vhost_ssl: 'cstate'
nginx_default_vhost: 'cstate'
nginx_www_dir: '/var/www/'
nginx_HSTS_policy: 'true'
#NGINX VHOST
nginx_vhosts:
- name: 'cstate'
template: 'cstate'
upstream_proto: 'http'
upstream_port: '1313'
upstream_name: 'localhost'
proto: 'http'
listen: '80'
root: '{{ nginx_www_dir }}cstate/public'
index: 'index.html'
use_access_log: 'true'
use_error_log: 'true'
nginx_error_log_level: 'warn'
state: 'enable'
letsencrypt: 'false'

BIN
files/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

18
tasks/config.yml Normal file
View File

@ -0,0 +1,18 @@
---
- name: '[CONFIG] - Deploy config'
template:
src: var/www/cstate/config.yml.j2
dest: "{{ cstate_dir }}/config.yml"
owner: "{{ cstate_username }}"
group: "{{ cstate_group }}"
mode: 0644
trim_blocks: no # to be able to control indentation in template with {%- if %} (note the dash that removes the empty line among the keys)
- name: '[CONFIG] - Add your logo'
copy:
src: ''../files/{{ cstate_logo }}'
dest: '{{ cstate_dir }}/static/{{ cstate_logo }}'
owner: '{{ cstate_username }}'
group: '{{ cstate_group }}'
mode: 0775

8
tasks/generate.yml Normal file
View File

@ -0,0 +1,8 @@
---
- name: "[GENERATE] - Generate the public folder and files"
shell: hugo
args:
chdir: '{{ cstate_dir }}'
become: yes
become_user: '{{ cstate_username }}'

8
tasks/git.yml Normal file
View File

@ -0,0 +1,8 @@
---
- name: '[GIT] - Deploy source'
git:
repo: "{{ cstate_repo }}"
dest: "{{ cstate_dir }}"
force: yes
update: yes

6
tasks/installdeps.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: '[INSTALLDEPS] - Install dependencies'
apt:
name: "{{ cstate_apt }}"
update_cache: yes

18
tasks/main.yml Normal file
View File

@ -0,0 +1,18 @@
---
- name: Install dependencies
include: installdeps.yml
- name: Clone repo
include: git.yml
- name: Set personal config
include: config.yml
- name: Build webpages with hugo
include: generate.yml
tags: generate
- name: Update
include: update.yml
when: cstate_update == 'yes' and cstate_public_repo|length > 0

15
tasks/update.yml Normal file
View File

@ -0,0 +1,15 @@
---
- name: "[UPDATE] - Update the cState theme submodule"
shell: git submodule foreach git pull origin master
args:
chdir: '{{ cstate_dir }}'
become: yes
become_user: '{{ cstate_username }}'
# - name: "[UPDATE] - Update the cState theme"
# shell: git add -A; git commit -m "Update cState"; git push origin master; exit
# args:
# chdir: '{{ cstate_dir }}'
# become: yes
# become_user: '{{ cstate_username }}'

View File

@ -0,0 +1,424 @@
############################################################
# +------------------------------------------------------+ #
# | Notes | #
# +------------------------------------------------------+ #
############################################################
# Welcome to the cState configuration file!
#
# If you are using an earlier version, or one
# in the future, such as v8.0 you may see errors
# pop up when deploying a cState website.
#
# Now, onto the fun part.
#
# Hugo is used for building the status page,
# so this file can be used to change how
# your status page should behave or look.
#
# If you want to use special characters,
# such as accented letters, you MUST save
# the file as UTF-8, not ANSI.
#
# If cState does not load, ensure that:
# - No tabs are present;
# YAML only allows spaces
# - Indents are correct
# YAML hierarchy is based entirely on indentation
# - You have "escaped" all apostrophes
# in your text: If you want to write "don't",
# for example, write "don''t" instead!
# Note the doubled apostrophe.
# - Text with symbols is enclosed in single
# or double quotation marks.
#
# If you have problems, create an issue on GitHub:
# https://github.com/cstate/cstate/issues
############################################################
# +------------------------------------------------------+ #
# | Basic metadata | #
# +------------------------------------------------------+ #
############################################################
# What is your status page called?
# Shows up in the browser bar and meta tags
title: {{ cstate_title }}
# Should posts, which have a publish date
# from the future, be built? Useful for
# sharing upcoming maintenance, etc.
#
# We recommend to keep this at `true`.
# BOOLEAN; `true`, `false`
buildFuture: true
# What language do you want to use for the
# html[lang] definition?
#
# Does not change language of site
# itself.
#
# Default: `en`
# ISO 639-1 defines abbreviations.
#
# See: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
# Also: https://www.w3schools.com/tags/ref_language_codes.asp
languageCode: {{ cstate_languageCode }}
# What translation file should cState use?
# You can also define whether missing
# translations should get placeholders.
#
# For defaultContentLanguage—
# Default: `en`
#
# For enableMissingTranslationPlaceholders—
# do not set it to true for languages other
# than English! When tested with Lithuanian,
# it would add unnecesary placeholders to
# values that were intentionally empty.
defaultContentLanguage: {{ cstate_defaultContentLanguage }}
# What is the hostname or path to the root?
# Where is the site hosted?
#
# ❗ cState & Hugo dont support '/' in
# production use. It will break RSS
# feeds and breaks permalinks since
# version 3. If you are just testing,
# localhost should automatically work.
#
# Example:
# baseUrl: https://status.example.com/
#
# For testing:
# baseUrl: http://localhost
#
# Broken example:
# baseUrl: /
baseURL: {{ cstate_baseURL }}
# For features like Last modified, you
# need to use a Git repository. If you
# are using Netlify, you are already
# using Git (with GitHub, GitLab, etc)
#
# So, should Git information be used
# for this website?
#
# We recommend to keep this at `true`.
# BOOLEAN; `true`, `false`
enableGitInfo: true
############################################################
# +------------------------------------------------------+ #
# | Preferences | #
# +------------------------------------------------------+ #
############################################################
params:
# Before setting up your systems, you need
# to first define at least one category.
#
# Categories are shown in the order that
# you define in this config file.
#
# Categories can have a:
# - name
# - description
# - closed boolean `closed: true`
# That would collapse the category upon first load
# and the user can expand by clicking on the category
# (Requires JavaScript.)
# - untitled boolean `untitled: true`
# This would complerely hide the name of the category.
# This is useful, if you do not want to use categories
# because you need to set an 'Uncategorized' category.
# Or it can be used alongside other categories.
#
# These are case sensitive.
#
# For help, see the wiki:
# https://github.com/cstate/cstate/wiki/Customization
categories:
{%- for item in cstate_categories %}
- name: {{ item.name }}
{%- if item.description is defined %}
description: {{ item.description }}
{%- endif %}
{%- if item.closed is defined %}
closed: {{ item.closed }}
{%- endif %}
{%- if item.untitled is defined %}
untitled: {{ item.untitled }}
{%- endif %}
{%- endfor %}
# These are your systems. Change them to
# change the amount of components.
#
# These are case sensitive.
#
# For help, see the wiki:
# https://github.com/cstate/cstate/wiki/Customization
systems:
{%- for item in cstate_systems %}
- name: {{ item.name }}
{%- if item.displayName is defined %}
displayName: {{ item.displayName }}
{%- endif %}
{%- if item.category is defined %}
category: {{ item.category }}
{%- endif %}
{%- if item.description is defined %}
description: {{ item.description }}
{%- endif %}
{%- if item.link is defined %}
link: {{ item.link }}
{%- endif %}
{%- if item.partial is defined %}
partial: {{ item.partial }}
{%- endif %}
{%- endfor %}
# What date format to use?
#
# Hugo formatting docs:
# https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference
#
# Technical: GOLANG/HUGO .Date.Format & dateFormat
#
# dateFormat Default: "January 2, 2006 at 3:04 PM"
# shortDateFormat Default: "15:04 — Jan 2"
dateFormat: {{ cstate_dateFormat }}
shortDateFormat: {{ cstate_shortDateFormat }}
# Should relative time (x min ago) be used?
#
# IMPORTANT: In the frontmatter, the dates MUST be in
# the UTC time zone for this to work preperly. If you
# use Netlify CMS, all good — the CMS picks UTC time
# by default. Otherwise, there may be very inaccurate
# times if multiple time zones are in your issue files.
#
# FOR YOUR CONSIDERATION: This feature was introduced in
# v5. It may be a breaking change in the case when you
# wish to use relative time but old issues do not have
# UTC time (and therefore are out of sync by ±24 hours)
#
# Read the wiki for more:
# https://github.com/cstate/cstate/wiki/Customization#time
#
# If enabled, will display relative times in places like
# the incident history and summaries instead of using
# dateFormat and shortDateFormat (except for if you use
# the old shortcode).
#
# Default: `true`
# BOOLEAN; `true`, `false`
useRelativeTime: {{ cstate_useRelativeTime }}
# If enabled, doesn't show seconds on relative times.
#
# With option ON (true):
# "Last checked <1 min ago"
#
# With option OFF (false; default):
# "Last checked 20s ago"
#
# Default: `false`
# BOOLEAN; `true`, `false`
skipSeconds: {{ cstate_skipSeconds }}
# Should there be an automatic "Last updated"
# text shown below issues?
#
# Default: `true`
# BOOLEAN; `true`, `false`
enableLastMod: {{ cstate_enableLastMod }}
# What header design should we use?
#
# Default: `true`
# BOOLEAN; `true`, `false`
useLargeHeaderDesign: {{ cstate_useLargeHeaderDesign }}
# Should incident history be separated
# like in an archive view?
#
# Note: This WILL disable pagination.
#
# Default: `yearly`
# STRING; `monthly`, `yearly`, `none`
incidentHistoryFormat: "{{ cstate_incidentHistoryFormat }}"
# Should incident history be hidden?
#
# By disabling the incident history, you also disable
# the RSS feed. To ensure no incidents are shown, you
# should delete them after they are resolved. This option
# overrides any other options that tailor your incident
# historys look.
#
# Default: `false`
# BOOLEAN; `true`, `false`
disableIncidentHistory: {{ cstate_disableIncidentHistory }}
# Disable dark mode
#
# If your OS and browser support the
# `prefers-color-scheme` media query,
# cState will automatically switch to
# a darker user interface.
#
# cState uses its built-in colors for
# most of the interface to ensure
# a good user experience.
#
# Default: `false`
# BOOLEAN; `true`, `false`
disableDarkMode: {{ cstate_disableDarkMode }}
# Should we show the logo or the title
# of the status page?
#
# Default: `false`
# BOOLEAN; `true`, `false`
useLogo: {{ cstate_useLogo }}
# Where is the logo located, if one is
# present at all?
#
# Recommended: png is best used for
# images like logos.
#
# Recommended: png, bmp, jpg, or gif
# for best browser support!
logo: {{ cstate_logo }}
# This is the description that is shown
# on the footer and meta tags.
#
# Default: We continuously monitor the status of our services and if there are any interruptions, a note will be posted here.
description: {{ cstate_description }}
# Tabs on homepage
# Uncomment to enable.
#
# Format:
# customTabs:
# -
# name: Name
# link: https://example.com
# Disable complex server-side
# calculations that may impact
# your build performance
#
# Disables math calculations
# for average downtime on
# systems ("/affected/") pages
#
# Default: `false`
# BOOLEAN; `true`, `false`
disableComplexCalculations: {{ cstate_disableComplexCalculations }}
# Incident posts shown
# in one page
#
# NUMERIC; Default: `10`
incidentPostsPerPage: {{ cstate_incidentPostsPerPage }}
# Colors throughout cState
#
# We recommend using HEX
# (with the # symbol).
#
# Defaults:
#
# brand: "#0a0c0f"
# ok: "#008000"
# disrupted: "#cc4400"
# down: "#e60000"
# notice: "#24478f"
brand: "{{ cstate_brand }}"
ok: "{{ cstate_ok }}"
disrupted: "{{ cstate_disrupted }}"
down: "{{ cstate_down }}"
notice: "{{ cstate_notice }}"
# If the status page shows that
# there are disruptions or outages
# happening, should it keep the
# brand header color or drop it
# and use the status indication
# colors that were just defined?
#
# Default: `true`
# BOOLEAN; `true`, `false`
alwaysKeepBrandColor: {{ cstate_alwaysKeepBrandColor }}
# Introduced in v4.0.1 for consistent
# site title text color.
#
# If you do not use the logo, what color
# should the site text color be?
#
# Removing this option will not force
# any site text color. This is likely
# unwanted behavior.
#
# Default: `white`
# STRING; `white`, `black`, or nothing
headerTextColor: {{ cstate_headerTextColor }}
# Google Analytics tracking code
#
# By default, cState does not use
# Google Analytics. If you choose
# to use it, you may change the
# placeholder code below to your
# own and thereby enable the
# tracking service.
#
# To disable the analytics, change
# the value to the default:
#
# Default: UA-00000000-1
googleAnalytics: UA-00000000-1
# These options affect the core of cState.
# Please do not change them if you do not
# know what you are doing.
theme: cstate
preserveTaxonomyNames: true
taxonomies:
affected: affected
outputs:
page:
- html
- json
section:
- html
- json
- rss
home:
- html
- json
- rss
- svg
term:
- html
- json
- rss
- svg
outputFormats:
svg:
isPlainText: true
mediaType: image/svg+xml