Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated tests #4

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/[email protected]
with:
command: lint
test:
needs:
- lint
runs-on: ubuntu-latest
strategy:
matrix:
image:
- geerlingguy/docker-ubuntu2004-ansible:latest
- geerlingguy/docker-ubuntu1804-ansible:latest
- geerlingguy/docker-ubuntu1604-ansible:latest
- geerlingguy/docker-centos8-ansible:latest
- geerlingguy/docker-centos7-ansible:latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/[email protected]
with:
image: "${{ matrix.image }}"
options: parallel
env:
MOLECULE_DOCKER_IMAGE: "${{ matrix.image }}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Ansible role: letsencrypt

![.github/workflows/molecule.yml](https://github.com/AcroMedia/ansible-role-letsencrypt/workflows/.github/workflows/molecule.yml/badge.svg)

For use on shared hosting servers. The role:
- Installs LetsEncrypt,
- Makes a `/.well-known/acme-challenge` virtual directory available to all virtual hosts on the server (including the default site), so all sites can regsiter and renew LE SSL certificates,
Expand Down
22 changes: 22 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*******
Docker driver installation guide
*******

Requirements
============

* Docker Engine

Install
=======

Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.

.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site

.. code-block:: bash

$ pip install 'molecule[docker]'
10 changes: 10 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Converge
hosts: all
become: true

vars:
- default_mail_recipient: [email protected]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use fictional values instead.


roles:
- role: ansible-role-letsencrypt
17 changes: 17 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_DOCKER_IMAGE:-'geerlingguy/docker-ubuntu1804-ansible:latest'}
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
33 changes: 33 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
- name: Install nginx
hosts: all
# connection: local
become: no
gather_facts: yes
tasks:

- name: Update yum
yum:
update_cache: yes
when: ansible_os_family == 'RedHat'

- name: Ensure nginx is installed
package:
name:
- nginx
state: present
when: ansible_os_family == 'RedHat'

- name: Ensure python is installed
package:
name:
- python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chithrak07 You might need python3 here? Python2 is Dead/EOL. This is just a guess. You'll need to find out for sure what the package name is for RH/CentOS.

state: present
when: ansible_os_family == 'RedHat'

- name: Ensure nginx is installed for Debian
apt: pkg=nginx state=present update_cache=true
when: ansible_os_family == 'Debian'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this task happens to fail, just update apt's cache first by itself before trying to install anything.


- name: Ensure python is installed for Debian
apt: pkg=python state=present update_cache=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here - Python without a version is generally python2 ... we want python3.

when: ansible_os_family == 'Debian'