Skip to content

Commit

Permalink
Merge pull request #137 from Oefenweb/pr-136
Browse files Browse the repository at this point in the history
WIP - Consistency changes
  • Loading branch information
tersmitten authored Sep 3, 2022
2 parents bbff0f7 + d385bdd commit 1dea964
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
warn_list:
- '106'
- ignore-errors
- role-name
- name
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip install ansible-lint[community,yamllint]
run: |
pip install ansible-lint
ansible-galaxy install -r requirements.yml
- name: Lint code
run: |
Expand All @@ -42,8 +44,6 @@ jobs:
fail-fast: false
matrix:
include:
- distro: ubuntu1604
ansible-version: '>=2.9, <2.10'
- distro: ubuntu1604
ansible-version: '>=2.10, <2.11'
- distro: ubuntu1604
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
FROM ubuntu:16.04
FROM ubuntu:18.04
MAINTAINER Mischa ter Smitten <[email protected]>

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# python
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal python-dev curl && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-minimal python3-dev curl && \
apt-get clean
RUN curl -sL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python -
RUN curl -sL https://bootstrap.pypa.io/pip/3.6/get-pip.py | python3 -
RUN rm -rf $HOME/.cache

# ansible
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-apt && \
apt-get clean
RUN pip install ansible==2.9.15
RUN pip3 install ansible==2.10.7
RUN rm -rf $HOME/.cache

# provision
Expand Down
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# handlers file
---
- name: restart haproxy
service:
ansible.builtin.service:
name: haproxy
state: "{{ haproxy_restart_handler_state }}"
when: service_default_state | default('started') == 'started'
5 changes: 2 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# meta file
---
galaxy_info:
namespace: oefenweb
author: oefenweb
role_name: haproxy
author: Mischa ter Smitten
company: Oefenweb.nl B.V.
description: Set up the latest version of HAProxy in Ubuntu systems
license: MIT
min_ansible_version: 2.9.0
min_ansible_version: 2.10.0
platforms:
- name: Ubuntu
versions:
Expand Down
6 changes: 6 additions & 0 deletions molecule/default/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
collections:
- name: community.docker
version: '>=1.2.0,<2'
- name: community.general
version: '>=2,<3'
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
roles:
- ../../../
3 changes: 3 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# requirements file
---
collections: []
4 changes: 2 additions & 2 deletions tasks/acl.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: acl | create directories
file:
ansible.builtin.file:
path: "{{ item.dest | dirname }}"
state: directory
owner: "{{ item.owner | default('root') }}"
Expand All @@ -12,7 +12,7 @@
- haproxy-acl-create-directories

- name: acl | update files
template:
ansible.builtin.template:
src: etc/haproxy/acl.j2
dest: "{{ item.dest }}"
owner: "{{ item.owner | default('root') }}"
Expand Down
6 changes: 3 additions & 3 deletions tasks/certificates.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: certificates | create directories
file:
ansible.builtin.file:
path: "{{ item.dest | dirname }}"
state: directory
owner: "{{ item.owner | default('root') }}"
Expand All @@ -13,7 +13,7 @@
- haproxy-certificates-create-directories

- name: certificates | copy files
copy:
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "{{ item.owner | default('root') }}"
Expand All @@ -26,7 +26,7 @@
- haproxy-certificates-copy-files

- name: certificates | remove files
file:
ansible.builtin.file:
path: "{{ item.dest }}"
state: absent
with_items: "{{ haproxy_ssl_map }}"
Expand Down
6 changes: 3 additions & 3 deletions tasks/configuration.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: configuration | warn or fail
fail:
- name: configuration | warn or fail # noqa: ignore-errors
ansible.builtin.fail:
msg: "haproxy_global_nbproc is deprecated"
ignore_errors: "{{ haproxy_version is version('2.5', '<') }}"
when:
Expand All @@ -11,7 +11,7 @@
- haproxy-configuration-warn-or-fail

- name: configuration | update file
template:
ansible.builtin.template:
src: "{{ haproxy_conf_template }}"
dest: /etc/haproxy/haproxy.cfg
owner: root
Expand Down
8 changes: 4 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: install | dependencies (pre)
apt:
ansible.builtin.apt:
name: "{{ haproxy_dependencies_pre }}"
state: "{{ apt_install_state | default('latest') }}"
update_cache: true
Expand All @@ -10,23 +10,23 @@
- haproxy-repository-install-dependencies

- name: install | add repository from PPA and install its signing key
apt_repository:
ansible.builtin.apt_repository:
repo: "{{ haproxy_ppa }}"
update_cache: true
when: haproxy_use_ppa | bool
tags:
- haproxy-install-add-repository

- name: install | dependencies
apt:
ansible.builtin.apt:
name: "{{ item.name }}"
state: "{{ item.state }}"
with_items: "{{ haproxy_dependencies }}"
tags:
- haproxy-install-dependencies

- name: install | additional
apt:
ansible.builtin.apt:
name: "{{ haproxy_install }}"
state: "{{ apt_install_state | default('latest') }}"
tags:
Expand Down
6 changes: 3 additions & 3 deletions tasks/letsencrypt.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: letsencrypt | copy SSL deploy script
template:
ansible.builtin.template:
src: "{{ haproxy_letsencrypt_ssl_deploy_template }}"
dest: "{{ haproxy_letsencrypt_ssl_deploy }}"
owner: root
Expand All @@ -11,7 +11,7 @@
- haproxy-letsencrypt-ssl-deploy

- name: letsencrypt | copy OCSP deploy script
template:
ansible.builtin.template:
src: "{{ haproxy_letsencrypt_ocsp_deploy_template }}"
dest: "{{ haproxy_letsencrypt_ocsp_deploy }}"
owner: root
Expand All @@ -21,7 +21,7 @@
- haproxy-letsencrypt-ocsp-deploy

- name: letsencrypt | configure (cron) job for OCSP deploy
cron:
ansible.builtin.cron:
name: haproxy-letsencrypt-ocsp-deploy
job: "{{ haproxy_letsencrypt_ocsp_deploy }}"
state: "{{ haproxy_letsencrypt_ocsp_deploy_job.state | default('absent') }}"
Expand Down
14 changes: 7 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# tasks file
---
- name: check version support
fail:
ansible.builtin.fail:
msg: "HAProxy version {{ haproxy_version }} is not supported"
when: haproxy_version | string not in haproxy_versions_supported
tags:
- configuration
- haproxy
- haproxy-check-version-support

- import_tasks: install.yml
- ansible.builtin.import_tasks: install.yml
tags:
- configuration
- haproxy
- haproxy-install

- import_tasks: certificates.yml
- ansible.builtin.import_tasks: certificates.yml
tags:
- configuration
- haproxy
- haproxy-certificates

- import_tasks: acl.yml
- ansible.builtin.import_tasks: acl.yml
tags:
- configuration
- haproxy
- haproxy-acl

- import_tasks: configuration.yml
- ansible.builtin.import_tasks: configuration.yml
tags:
- configuration
- haproxy
- haproxy-configuration

- import_tasks: letsencrypt.yml
- ansible.builtin.import_tasks: letsencrypt.yml
tags:
- configuration
- haproxy
- haproxy-letsencrypt

- name: start and enable service
service:
ansible.builtin.service:
name: haproxy
state: "{{ service_default_state | default('started') }}"
enabled: "{{ service_default_enabled | default(true) | bool }}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml"
roles:
- ../../
2 changes: 1 addition & 1 deletion tests/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml"
roles:
- ../../

0 comments on commit 1dea964

Please sign in to comment.