feat(ghost): add ghost ansible role

This commit is contained in:
Vincent Wilke 2020-09-03 14:59:41 +02:00 committed by Johanna Dorothea Reichmann
parent 6fc32a0d70
commit 2372548767
No known key found for this signature in database
GPG key ID: 03624C433676E465
11 changed files with 199 additions and 0 deletions

29
roles/ghost/.travis.yml Normal file
View file

@ -0,0 +1,29 @@
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

1
roles/ghost/CODEOWNERS Normal file
View file

@ -0,0 +1 @@
* @Ratzupaltuff

22
roles/ghost/LICENSE Normal file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2020 aboveops.com
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 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.

34
roles/ghost/README.md Normal file
View file

@ -0,0 +1,34 @@
Role Name
=========
Role installs a [Ghost](https://ghost.org/) blog engine in Docker container
Requirements
------------
Target host should have Docker container engine running
Role Variables
--------------
Please check [default variables](./defaults/main.yml).
You can add your email config as follows:
```
blog_env_extra:
mail__transport: SMTP
mail__from: "'Example Blog' <info@example.com>"
mail__options__host: 127.0.0.1
mail__options__port: 2525
blog_container_labels: {}
```
License
-------
[MIT](./LICENSE)
Author Information
------------------
Brought to you by [AboveOps](https://aboveops.com) team

View file

@ -0,0 +1,42 @@
---
# All variables in this role are prefixed with 'blog_'
#
# Default task prefix to display during play
blog_task_prefix: "=== GHOST BLOG ==="
# Domain settings
blog_domain_name: "blog.example.com"
blog_url: "https://{{ blog_domain_name }}"
# Ghost blog local data directory
blog_path_base: "/opt/ghost"
blog_path_data: "{{ blog_path_base }}/data"
blog_path_env: "{{ blog_path_base }}/ghost.env"
# Template
blog_template_env: "ghost.env.j2"
# Container settings
ghost_version: "3.25.0"
blog_container_image: "ghost:{{ ghost_version }}"
blog_container_name: "ghost-blog"
blog_container_pull: "no"
blog_container_recreate: "no"
blog_container_restart_policy: "always"
blog_container_state: "started"
blog_container_labels_complete: "{{ blog_container_labels_base | combine(blog_container_labels) }}"
blog_container_labels_base:
version: "{{ ghost_version }}"
blog_container_port: '2368'
blog_container_data: "/var/lib/ghost/content"
blog_container_ports:
- "{{ blog_bind_addr }}:{{ blog_bind_port }}:{{ blog_container_port }}"
# Environment variables settings
blog_env_url: "{{ blog_url }}"
# User defined variable settings:
blog_env_extra: {}
# Listen settings
blog_bind_addr: '127.0.0.1'
blog_bind_port: '2368'

View file

@ -0,0 +1,2 @@
---
# TODO: nginx handler

31
roles/ghost/meta/main.yml Normal file
View file

@ -0,0 +1,31 @@
dependencies: []
galaxy_info:
author: AboveOps
role_name: ghost
description: Role installs Ghost blog in Docker container
company: AboveOps
license: MIT
min_ansible_version: 2.9
platforms:
- name: EL
versions:
- 7
- 8
- name: Fedora
versions:
- all
- name: Debian
versions:
- stretch
- buster
- name: Ubuntu
versions:
- xenial
- bionic
galaxy_tags:
- ghost
- blog
- publishing
- web
- cms
- content

View file

@ -0,0 +1,27 @@
---
- name: "{{ blog_task_prefix }} Create directories"
file:
path: "{{ item }}"
state: directory
loop:
- "{{ blog_path_base }}"
- "{{ blog_path_data }}"
- name: "{{ blog_task_prefix }} Install .env file"
template:
src: "{{ blog_template_env }}"
dest: "{{ blog_path_env }}"
- name: "{{ blog_task_prefix }} Provision container"
docker_container:
env_file: "{{ blog_path_env }}"
image: "{{ blog_container_image }}"
name: "{{ blog_container_name }}"
ports: "{{ blog_container_ports }}"
labels: "{{ blog_container_labels_complete }}"
pull: "{{ blog_container_pull }}"
recreate: "{{ blog_container_recreate }}"
restart_policy: "{{ blog_container_restart_policy }}"
state: "{{ blog_container_state }}"
volumes:
- "{{ blog_path_data }}:{{ blog_container_data }}"

View file

@ -0,0 +1,4 @@
url={{ blog_env_url }}
{% for key, value in blog_env_extra.items() %}
{{ key }}={{ value }}
{% endfor %}

View file

@ -0,0 +1,2 @@
localhost

View file

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- ansible-role-ghost