Browse Source

Added gitit role which also handles installation of nginx config for gitit

Till Klocke 9 years ago
parent
commit
1eb71f81e5

+ 38 - 0
roles/internal/ffdo.gitit/README.md

@@ -0,0 +1,38 @@
+Role Name
+=========
+
+A brief description of the role goes here.
+
+Requirements
+------------
+
+Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
+
+Role Variables
+--------------
+
+A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
+
+Dependencies
+------------
+
+A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
+
+Example Playbook
+----------------
+
+Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+
+    - hosts: servers
+      roles:
+         - { role: username.rolename, x: 42 }
+
+License
+-------
+
+BSD
+
+Author Information
+------------------
+
+An optional section for the role authors to include contact information, or a website (HTML is not allowed).

+ 8 - 0
roles/internal/ffdo.gitit/defaults/main.yml

@@ -0,0 +1,8 @@
+---
+# defaults file for ffdo.gitit
+
+gitit_data_dir: /src/gitit
+gitit_user: gitit
+gitit_group: gitit
+gitit_wiki_title: Freifunk-Dortmund-Wiki
+gitit_wiki_repo: ""

+ 5 - 0
roles/internal/ffdo.gitit/handlers/main.yml

@@ -0,0 +1,5 @@
+---
+# handlers file for ffdo.gitit
+
+- name: Restart gitit
+  service: name=gitit state=reloaded

+ 136 - 0
roles/internal/ffdo.gitit/meta/main.yml

@@ -0,0 +1,136 @@
+---
+galaxy_info:
+  author: your name
+  description: 
+  company: your company (optional)
+  # If the issue tracker for your role is not on github, uncomment the
+  # next line and provide a value
+  # issue_tracker_url: http://example.com/issue/tracker
+  # Some suggested licenses:
+  # - BSD (default)
+  # - MIT
+  # - GPLv2
+  # - GPLv3
+  # - Apache
+  # - CC-BY
+  license: license (GPLv2, CC-BY, etc)
+  min_ansible_version: 1.2
+  #
+  # Below are all platforms currently available. Just uncomment
+  # the ones that apply to your role. If you don't see your 
+  # platform on this list, let us know and we'll get it added!
+  #
+  #platforms:
+  #- name: EL
+  #  versions:
+  #  - all
+  #  - 5
+  #  - 6
+  #  - 7
+  #- name: GenericUNIX
+  #  versions:
+  #  - all
+  #  - any
+  #- name: Fedora
+  #  versions:
+  #  - all
+  #  - 16
+  #  - 17
+  #  - 18
+  #  - 19
+  #  - 20
+  #  - 21
+  #  - 22
+  #- name: Windows
+  #  versions:
+  #  - all
+  #  - 2012R2
+  #- name: SmartOS
+  #  versions:
+  #  - all
+  #  - any
+  #- name: opensuse
+  #  versions:
+  #  - all
+  #  - 12.1
+  #  - 12.2
+  #  - 12.3
+  #  - 13.1
+  #  - 13.2
+  #- name: Amazon
+  #  versions:
+  #  - all
+  #  - 2013.03
+  #  - 2013.09
+  #- name: GenericBSD
+  #  versions:
+  #  - all
+  #  - any
+  #- name: FreeBSD
+  #  versions:
+  #  - all
+  #  - 8.0
+  #  - 8.1
+  #  - 8.2
+  #  - 8.3
+  #  - 8.4
+  #  - 9.0
+  #  - 9.1
+  #  - 9.1
+  #  - 9.2
+  #- name: Ubuntu
+  #  versions:
+  #  - all
+  #  - lucid
+  #  - maverick
+  #  - natty
+  #  - oneiric
+  #  - precise
+  #  - quantal
+  #  - raring
+  #  - saucy
+  #  - trusty
+  #  - utopic
+  #  - vivid
+  #- name: SLES
+  #  versions:
+  #  - all
+  #  - 10SP3
+  #  - 10SP4
+  #  - 11
+  #  - 11SP1
+  #  - 11SP2
+  #  - 11SP3
+  #- name: GenericLinux
+  #  versions:
+  #  - all
+  #  - any
+  #- name: Debian
+  #  versions:
+  #  - all
+  #  - etch
+  #  - jessie
+  #  - lenny
+  #  - squeeze
+  #  - wheezy
+  #
+  # Below are all categories currently available. Just as with
+  # the platforms above, uncomment those that apply to your role.
+  #
+  #categories:
+  #- cloud
+  #- cloud:ec2
+  #- cloud:gce
+  #- cloud:rax
+  #- clustering
+  #- database
+  #- database:nosql
+  #- database:sql
+  #- development
+  #- monitoring
+  #- networking
+  #- packaging
+  #- system
+  #- web
+dependencies: 
+- ffdo.mapserver-nginx

+ 86 - 0
roles/internal/ffdo.gitit/tasks/main.yml

@@ -0,0 +1,86 @@
+---
+# tasks file for ffdo.gitit
+
+- name: Ensure group for gitit exists
+  group: name={{gitit_group}}
+
+- name: Ensure user for gitit exists
+  user: 
+    name: "{{gitit_user}}"
+    createhome: yes
+    home: "{{gitit_data_dir}}"
+    group: "{{gitit_group}}"
+
+- name: Ensure prerequisites for gitit are instaled
+  apt: name={{item}} state=present
+  with_items:
+  - git
+  - gitit
+
+- name: Install gitit configuration
+  template:
+    src: conf.j2
+    dest: "{{gitit_data_dir}}/gitit.conf"
+    owner: "{{gitit_user}}"
+  notify:
+  - Restart gitit
+
+- name: Ensure static content directories exists
+  file:
+    dest: "{{gitit_data_dir}}/static/{{item}}"
+    state: directory
+    owner: "{{gitit_user}}"
+  with_items:
+  - css
+  - img
+
+- name: Ensure template directory exists
+  file:
+    dest: "{{gitit_data_dir}}/templates"
+    state: directory
+    owner: "{{gitit_user}}"
+
+- name: Ensure custom footer exists
+  template:
+    src: footer.st.j2
+    dest: "{{gitit_data_dir}}/templates/footer.st"
+    owner: "{{gitit_user}}"
+
+- name: Ensure custom css exists
+  template:
+    src: custom.css.j2
+    dest: "{{gitit_data_dir}}/static/css/custom.css"
+    owner: "{{gitit_user}}"
+
+- name: Ensure wikidata directory exists
+  file:
+    dest: "{{gitit_data_dir}}/wikidata"
+    state: directory
+    owner: "{{gitit_user}}"
+
+- name: Clone wiki repo
+  git:
+    src: "{{gitit_wiki_repo}}"
+    dest: "{{gitit_data_dir}}/wikidata"
+
+# TODO restore user data
+
+- name: Install nginx configs
+  template:
+    src: "nginx.j2"
+    dest: "/etc/nginx/sites-available/wiki"
+  notify:
+  - Restart nginx
+
+- name: Install systemd unit
+  register: gitit_systemd_unit
+  template:
+    src: systemd.j2
+    dest: /etc/systemd/system/gitit.service
+
+- name: Systemd daemon-reload
+  when: gitit_systemd_unit|changed
+  shell: systemctl daemon-reload
+
+- name: Ensure gitit is started and enabled
+  service: name=gitit state=started enabled=yes

+ 261 - 0
roles/internal/ffdo.gitit/templates/conf.j2

@@ -0,0 +1,261 @@
+# gitit wiki configuration file
+
+address: 127.0.0.1
+
+port: 55001
+# sets the port on which the web server will run.
+
+wiki-title: {{gitit_wiki_title}}
+# the title of the wiki.
+
+repository-type: Git
+# specifies the type of repository used for wiki content.
+# Options are Git, Darcs, and Mercurial.
+
+repository-path: wikidata
+# specifies the path of the repository directory.  If it does not
+# exist, gitit will create it on startup.
+
+require-authentication: modify
+# if 'none', login is never required, and pages can be edited anonymously.
+# if 'modify', login is required to modify the wiki (edit, add, delete
+# pages, upload files).
+# if 'read', login is required to see any wiki pages.
+
+authentication-method: form
+# 'form' means that users will be logged in and registered
+# using forms in the gitit web interface.  'http' means
+# that gitit will assume that HTTP authentication is in
+# place and take the logged in username from the "Authorization"
+# field of the HTTP request header (in addition,
+# the login/logout and registration links will be
+# suppressed).  'generic' means that gitit will assume that
+# some form of authentication is in place that directly
+# sets REMOTE_USER to the name of the authenticated user
+# (e.g. mod_auth_cas on apache).  'rpx' means that gitit
+# will attempt to log in through https://rpxnow.com.
+# This requires that 'rpx-domain', 'rpx-key', and 'base-url'
+# be set below, and that 'curl' be in the system path.
+
+user-file: gitit-users
+# specifies the path of the file containing user login information.
+# If it does not exist, gitit will create it (with an empty user list).
+# This file is not used if 'http' is selected for authentication-method.
+
+session-timeout: 60
+# number of minutes of inactivity before a session expires.
+
+static-dir: wikidata/_NOWIKI/static
+# specifies the path of the static directory (containing javascript,
+# css, and images).  If it does not exist, gitit will create it
+# and populate it with required scripts, stylesheets, and images.
+
+default-page-type: Markdown
+# specifies the type of markup used to interpret pages in the wiki.
+# Possible values are Markdown, RST, LaTeX, HTML, Markdown+LHS, RST+LHS,
+# and LaTeX+LHS. (The +LHS variants treat the input as
+# literate Haskell. See pandoc's documentation for more details.) If
+# Markdown is selected, pandoc's syntax extensions (for footnotes,
+# delimited code blocks, etc.) will be enabled. Note that pandoc's
+# reStructuredText parser is not complete, so some pages may not be
+# rendered correctly if RST is selected. The same goes for LaTeX and
+# HTML.
+
+math: MathML
+# specifies how LaTeX math is to be displayed.  Possible values
+# are MathML, raw, mathjax, jsMath, and google.  If mathml is selected,
+# gitit will convert LaTeX math to MathML and link in a script,
+# MathMLinHTML.js, that allows the MathML to be seen in Gecko browsers, IE +
+# mathplayer, and Opera. In other browsers you may get a jumble of characters.
+# If raw is selected, the LaTeX math will be displayed as raw LaTeX math.
+# If mathjax is selected, gitit will link to the remote mathjax script.
+# If jsMath is selected, gitit will link to the script /js/jsMath/easy/load.js,
+# and will assume that jsMath has been installed into the js/jsMath directory.
+# This is the most portable solution. If google is selected, the google chart
+# API is called to render the formula as an image. This requires a connection
+# to google, and might raise a technical or a privacy problem.
+
+show-lhs-bird-tracks: no
+# specifies whether to show Haskell code blocks in "bird style",
+# with "> " at the beginning of each line.
+
+templates-dir: wikidata/_NOWIKI/templates
+# specifies the path of the directory containing page templates.
+# If it does not exist, gitit will create it with default templates.
+# Users may wish to edit the templates to customize the appearance of
+# their wiki. The template files are HStringTemplate templates.
+# Variables to be interpolated appear between $'s. Literal $'s must be
+# backslash-escaped.
+
+log-file: gitit.log
+# specifies the path of gitit's log file.  If it does not exist,
+# gitit will create it. The log is in Apache combined log format.
+
+log-level: ERROR
+# determines how much information is logged.
+# Possible values (from most to least verbose) are DEBUG, INFO,
+# NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY.
+
+front-page: Front Page
+# specifies which wiki page is to be used as the wiki's front page.
+# Gitit creates a default front page on startup, if one does not exist
+# already.
+
+no-delete: Front Page, Help
+# specifies pages that cannot be deleted through the web interface.
+# (They can still be deleted directly using git or darcs.)
+# A comma-separated list of page names.  Leave blank to allow
+# every page to be deleted.
+
+no-edit: Help
+# specifies pages that cannot be edited through the web interface.
+# Leave blank to allow every page to be edited.
+
+default-summary:
+# specifies text to be used in the change description if the author
+# leaves the "description" field blank.  If default-summary is blank
+# (the default), the author will be required to fill in the description
+# field.
+
+table-of-contents: yes
+# specifies whether to print a tables of contents (with links to
+# sections) on each wiki page.
+
+plugins:
+# specifies a list of plugins to load.  Plugins may be specified
+# either by their path or by their module name.  If the plugin name
+# starts with Gitit.Plugin., gitit will assume that the plugin is
+# an installed module and will not try to find a source file.
+# Examples:
+# plugins: plugins/DotPlugin.hs, CapitalizeEmphasisPlugin.hs
+# plugins: plugins/DotPlugin
+# plugins: Gitit.Plugin.InterwikiLinks
+
+use-cache: no
+# specifies whether to cache rendered pages.  Note that if use-feed
+# is selected, feeds will be cached regardless of the value of use-cache.
+
+cache-dir: cache
+# directory where rendered pages will be cached
+
+max-upload-size: 100K
+# specifies an upper limit on the size (in bytes) of files uploaded
+# through the wiki's web interface.
+# To disable uploads, set this to 0K.
+# This will result in the uploads link disappearing
+# and the _upload url becoming inactive.
+
+max-page-size: 100K
+# specifies an upper limit on the size (in bytes) of pages
+
+debug-mode: no
+# if "yes", causes debug information to be logged while gitit is running.
+
+compress-responses: no
+# specifies whether HTTP responses should be compressed.
+
+mime-types-file: /etc/mime.types
+# specifies the path of a file containing mime type mappings.
+# Each line of the file should contain two fields, separated by
+# whitespace. The first field is the mime type, the second is a
+# file extension.  For example:
+# video/x-ms-wmx                    wmx
+# If the file is not found, some simple defaults will be used.
+
+use-recaptcha: no
+# if "yes", causes gitit to use the reCAPTCHA service
+# (http://recaptcha.net) to prevent bots from creating accounts.
+
+recaptcha-private-key:
+recaptcha-public-key:
+# specifies the public and private keys for the reCAPTCHA service.
+# To get these, you need to create an account at http://recaptcha.net.
+
+access-question:
+access-question-answers:
+# specifies a question that users must answer when they attempt to create
+# an account, along with a comma-separated list of acceptable answers.
+# This can be used to institute a rudimentary password for signing up as
+# a user on the wiki, or as an alternative to reCAPTCHA.
+# Example:
+# access-question:  What is the code given to you by Ms. X?
+# access-question-answers:  RED DOG, red dog
+
+rpx-domain:
+rpx-key:
+# Specifies the domain and key of your RPX account.  The domain is
+# just the prefix of the complete RPX domain, so if your full domain
+# is 'https://foo.rpxnow.com/', use 'foo' as the value of rpx-domain.
+
+mail-command: sendmail %s
+# specifies the command to use to send notification emails.
+# '%s' will be replaced by the destination email address.
+# The body of the message will be read from stdin.
+# If this field is left blank, password reset will not be offered.
+
+reset-password-message:
+  > From: nobody@$hostname$
+  > To: $useremail$
+  > Subject: Wiki password reset
+  >
+  > Dear $username$:
+  >
+  > To reset your password, please follow the link below:
+  > http://$hostname$:$port$$resetlink$
+  >
+  > Yours sincerely,
+  > The Wiki Master
+
+# gives the text of the message that will be sent to the user should she
+# want to reset her password, or change other registration info.
+# The lines must be indented, and must begin with '>'.  The initial
+# spaces and '> ' will be stripped off. $username$ will be replaced
+# by the user's username, $useremail$ by her email address,
+# $hostname$ by the hostname on which the wiki is running (as
+# returned by the hostname system call), $port$ by the port on
+# which the wiki is running, and $resetlink$ by the
+# relative path of a reset link derived from the user's existing
+# hashed password. If your gitit wiki is being proxied to a location
+# other than the root path of $port$, you should change the link to
+# reflect this: for example, to
+# http://$hostname$/path/to/wiki$resetlink$ or
+# http://gitit.$hostname$$resetlink$
+
+use-feed: no
+# specifies whether an ATOM feed should be enabled (for the site and for
+# individual pages)
+
+base-url:
+# the base URL of the wiki, to be used in constructing feed IDs
+# and RPX token_urls.  Set this if use-feed is 'yes' or
+# authentication-method is 'rpx'.
+
+absolute-urls: yes
+# make wikilinks absolute with respect to the base-url.
+# So, for example, in a wiki served at the base URL '/wiki', on a page
+# Sub/Page, the wikilink '[Cactus]()' will produce a link to
+# '/wiki/Cactus' if absolute-urls is 'yes', and a relative link to 'Cactus'
+# (referring to '/wiki/Sub/Cactus') if absolute-urls is 'no'.
+
+feed-days: 14
+# number of days to be included in feeds.
+
+feed-refresh-time: 60
+# number of minutes to cache feeds before refreshing
+
+pdf-export: no
+# if yes, PDF will appear in export options. PDF will be created using
+# pdflatex, which must be installed and in the path. Note that PDF
+# exports create significant additional server load.
+
+pandoc-user-data:
+# if a directory is specified, this will be searched for pandoc
+# customizations. These can include a templates/ directory for custom
+# templates for various export formats, an S5 directory for custom
+# S5 styles, and a reference.odt for ODT exports. If no directory is
+# specified, $HOME/.pandoc will be searched. See pandoc's README for
+# more information.
+
+xss-sanitize: yes
+# if yes, all HTML (including that produced by pandoc) is filtered
+# through xss-sanitize.  Set to no only if you trust all of your users.

+ 4 - 0
roles/internal/ffdo.gitit/templates/custom.css.j2

@@ -0,0 +1,4 @@
+@import url("screen.css"); /* default gitit screen styles */
+@import url("hk-pyg.css"); /* for syntax highlighting */
+
+/* Put your custom style modifications here: */

roles/internal/ffdo.mapserver-nginx/templates/nginx-wiki.conf.j2 → roles/internal/ffdo.gitit/templates/nginx.j2


+ 14 - 0
roles/internal/ffdo.gitit/templates/systemd.j2

@@ -0,0 +1,14 @@
+[program:gitit]
+Environment=LANG=de_DE.UTF-8
+Environment=LC_ALL=de_DE.UTF-8
+Environment=LC_LANG=de_DE.UTF-8
+command=/usr/bin/gitit -f {{gitit_data_dir}}/gitit.conf -l 127.0.0.1
+autostart=true
+autorestart=true
+startretries=10
+user={{gitit_user}}
+directory={{gitit_data_dir}}
+redirect_stderr=true
+stdout_logfile={{gluon_collector_log_path}}
+stdout_logfile_maxbytes=5MB
+stdout_logfile_backups=10

+ 2 - 0
roles/internal/ffdo.gitit/vars/main.yml

@@ -0,0 +1,2 @@
+---
+# vars file for ffdo.gitit

+ 7 - 2
roles/internal/ffdo.mapserver-nginx/templates/nginx-default.conf.j2

@@ -36,7 +36,7 @@ server {
                 gzip_vary on;
   }
 
-        location /grafana {
+  location /grafana {
     if ($scheme != "https") {
       rewrite ^ https://map.ffdo.de$request_uri permanent;
     }
@@ -45,7 +45,7 @@ server {
                 rewrite  ^/grafana/(.*)  /$1 break;
                 proxy_set_header Host $host;
 
-        }
+  }
 
   location /data {
     alias /srv/ffmap-data;
@@ -55,6 +55,11 @@ server {
     gzip_vary on;
   }
 
+  location /data-announced {
+    proxy_pass  http://127.0.0.1:{{gluon_collector_http_port}};
+    proxy_redirect  off;
+  }
+
 # location /wiki {
 #   if ($scheme = http){
 #                 rewrite ^ https://map.do.freifunk.ruhr$request_uri? permanent;

+ 1 - 0
roles/internal/ffdo.mapserver/meta/main.yml

@@ -19,5 +19,6 @@ galaxy_info:
   - web
 dependencies:
 - dereulenspiegel.alfred
+- ffdo.gluon-collector
 - ffdo.mapserver-nginx
 - ffdo.meshviewer

+ 1 - 0
roles/internal/ffdo.meshviewer/meta/main.yml

@@ -50,4 +50,5 @@ galaxy_info:
   - monitoring
   - web
 dependencies:
+- ffmap-backend
 - laggyluke.nodejs