Skip to content
Snippets Groups Projects
Commit d96ac848 authored by nimrod's avatar nimrod
Browse files

- Forked from the example Ansible role.

- Seems to work but lacks tests.
parent 4132c3f9
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,5 @@ __pycache__
.vagrant/
*.log
*.retry
id_rsa
id_rsa.pub
Example
#######
pelican-gitreceive
##################
.. image:: https://travis-ci.org/adarnimrod/example.svg?branch=master
:target: https://travis-ci.org/adarnimrod/example
An (empty) example Ansible role complete with working tests out of the box. For
more information read the `blog post
<https://www.shore.co.il/blog/ansible-example-role/>`_.
Publish a Pelican blog with gitreceive. Run :code:`git remote add publish
git@hostname:blog` to add the git remote and run :code:`git push publish` to
publish changes. This role does not configure a webserver.
Requirements
------------
......@@ -61,3 +58,8 @@ Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website
<https://www.shore.co.il/>`_. Patches are welcome via `git send-email
<http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located
at: https://www.shore.co.il/git/.
TODO
----
- Tests.
---
# defaults file for example
# defaults file for pelican-gitreceive
pelican_gitreceive_output: '{{ pelican_gitreceive_www_root[ansible_os_family] }}/blog'
pelican_gitreceive_public_keys: []
---
# handlers file for example
# handlers file for pelican-gitreceive
galaxy_info:
author: Nimrod Adar
description: An example Ansible role
description: Publish a Pelican blog with gitreceive
company: Shore technologies
license: MIT
min_ansible_version: 2.0
......@@ -11,5 +11,13 @@ galaxy_info:
- name: Ubuntu
versions:
- xenial
- trusty
- name: Debian
versions:
- jessie
galaxy_tags: [ ansible ]
dependencies: []
dependencies:
- src: adarnimrod.python27
- src: adarnimrod.gitreceive
gitreceive_receiver_script: "{{ lookup('template', 'receiver.sh') }}"
gitreceive_public_keys: '{{ pelican_gitreceive_public_keys }}'
......@@ -19,7 +19,7 @@ vagrant:
- name: xenial
box: ubuntu/xenial64
instances:
- name: example
- name: pelican-gitreceive
options:
append_platform_to_hostname: yes
raw_config_args:
......@@ -30,7 +30,7 @@ vagrant:
docker:
containers:
- name: example-xenial
- name: pelican-gitreceive-xenial
image: ubuntu
image_version: xenial
command: /sbin/init
......@@ -42,3 +42,22 @@ docker:
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
- name: pelican-gitreceive-trusty
image: ubuntu-upstart
image_version: trusty
command: /sbin/init
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
- name: pelican-gitreceive-jessie
image: debian
image_version: jessie
command: /sbin/init
cap_add:
- SYS_ADMIN
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
---
# tasks file for example
# tasks file for pelican-gitreceive
- name: Assertions
assert:
that:
- ansible_os_family in ['OpenBSD', 'Debian']
- ansible_distribution_release in ['6.0', 'xenial']
- ansible_distribution_release in ['6.0', 'xenial', 'trusty', 'jessie']
- pelican_gitreceive_public_keys is iterable
- pelican_gitreceive_output is defined
- name: pip install
with_items:
- pelican
- fabric
pip:
name: '{{ item }}'
state: present
- name: Create directory structure
file:
path: /var/www/htdocs/www.shore.co.il/blog/
owner: git
group: git
state: directory
mode: 0o0755
#!/bin/sh
set -eu
echo Recieving blog...
tempdir="$(mktemp -d)"
cd $tempdir
tar -xf -
echo Fetching Git submodules
git submodule update --init --recursive
echo Building blog...
fab build
echo Syncing blog...
rsync -Prv --delete --cvs-exclude output/ {{ pelican_gitreceive_output }}
echo Cleanup...
cd -
rm -r "$tempdir"
echo Successfully finished...
---
- hosts: example-openbsd
- hosts: pelican-gitreceive-openbsd
gather_facts: false
roles: [adarnimrod.openbsd-bootstrap]
- hosts: example-xenial
- hosts: pelican-gitreceive-xenial
gather_facts: false
roles: [adarnimrod.debian-bootstrap]
- hosts: all
pre_tasks:
- name: Create SSH keypair
become: False
local_action: command ssh-keygen -t rsa -N '' -f files/id_rsa
run_once: True
args:
creates: files/id_rsa
roles:
- role: example
- role: adarnimrod.nginx
- role: pelican-gitreceive
pelican_gitreceive_public_keys: ['{{ lookup("file", "id_rsa.pub") }}']
---
- src: adarnimrod.openbsd-bootstrap
- src: adarnimrod.debian-bootstrap
- src: adarnimrod.nginx
---
# vars file for example
# vars file for pelican-gitreceive
pelican_gitreceive_www_root:
Debian: /var/www
OpenBSD: /var/www/htdocs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment