Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
style: fix ansible-lint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashuste committed Jun 28, 2023
1 parent 316595a commit 0baf3fa
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Lint code.
run: |
pipenv run yamllint --strict --format colored .
pipenv run ansible-lint -v --force-color --exclude .cache/ . ./molecule
pipenv run ansible-lint -v --force-color --exclude=.cache/ . ./molecule
test:
name: Run Molecule tests.
Expand Down
15 changes: 6 additions & 9 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
---
- name: reload nginx
service:
- name: Reload nginx
ansible.builtin.service:
name: nginx
state: reloaded

- name: restart elasticsearch
service:
name: elasticsearch
state: restarted

- name: Set Elasticsearch server address
command: zammad run rails r "Setting.set('es_url', '{{ elasticsearch_url | quote }}')"
ansible.builtin.command: zammad run rails r "Setting.set('es_url', '{{ elasticsearch_url | quote }}')"
changed_when: true

- name: Build search index
command: zammad run rake searchindex:rebuild
ansible.builtin.command: zammad run rake searchindex:rebuild
changed_when: true

...
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ galaxy_info:
company: Helmholtz Association of German Research Centres
license: MIT
issue_tracker_url: https://github.com/Helmholtz-UFZ/ansible-role-zammad/issues
min_ansible_version: 2.9
min_ansible_version: "2.9"

platforms:
- name: Ubuntu
Expand Down
8 changes: 4 additions & 4 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
tasks:

- name: Get private key content
command: cat /etc/ssl/private/ssl-cert-snakeoil.key
ansible.builtin.command: cat /etc/ssl/private/ssl-cert-snakeoil.key
changed_when: false
check_mode: false
register: private_key

- name: Get SSL certificate content
command: cat /etc/ssl/certs/ssl-cert-snakeoil.pem
ansible.builtin.command: cat /etc/ssl/certs/ssl-cert-snakeoil.pem
changed_when: false
check_mode: false
register: certificate

- name: Pass SSL key pair to zammad role
set_fact:
ansible.builtin.set_fact:
zammad_ssl_key: "{{ private_key.stdout }}"
zammad_ssl_cert: "{{ certificate.stdout }}"

- name: "Include ansible-role-zammad"
include_role:
ansible.builtin.include_role:
name: "ansible-role-zammad"
6 changes: 3 additions & 3 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tasks:

- name: Install required packages
apt:
ansible.builtin.apt:
name:
- sudo
- gpg
Expand All @@ -26,9 +26,9 @@
update_cache: yes

- name: "Include geerlingguy.elasticsearch"
include_role:
ansible.builtin.include_role:
name: "geerlingguy.elasticsearch"

- name: "Include geerlingguy.postgresql"
include_role:
ansible.builtin.include_role:
name: "geerlingguy.postgresql"
2 changes: 1 addition & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all
tasks:
- name: Check that Zammad web interface is available
uri:
ansible.builtin.uri:
url: https://localhost
validate_certs: no
return_content: yes
Expand Down
18 changes: 10 additions & 8 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---

- when: ansible_distribution | lower == 'centos'
- name: "Configure Zammad repository for Centos-like"
when: ansible_distribution | lower == 'centos'
block:

- name: Install | Install EPEL repo
yum:
ansible.builtin.yum:
name: epel-release
state: present

- name: Install | Add Zammad yum repository
yum_repository:
ansible.builtin.yum_repository:
name: zammad
state: present
description: Repository for zammad/zammad ({{ zammad_release_channel }}) packages.
Expand All @@ -20,24 +21,25 @@
gpgkey: https://dl.packager.io/srv/zammad/zammad/key
mode: 0644

- when: ansible_distribution | lower == 'ubuntu'
- name: "Configure Zammad repository for Ubuntu"
when: ansible_distribution | lower == 'ubuntu'
block:

- name: Install | Add Zammad apt key
apt_key:
ansible.builtin.apt_key:
url: https://dl.packager.io/srv/zammad/zammad/key
state: present

- name: Install | Add Zammad DEB repository
apt_repository:
ansible.builtin.apt_repository:
repo: deb https://dl.packager.io/srv/deb/zammad/zammad/{{ zammad_release_channel }}/ubuntu {{ ansible_distribution_version }} main
state: present
filename: zammad
update_cache: yes
mode: 0644

- name: Install | Install Zammad package
package:
ansible.builtin.package:
name: zammad={{ zammad_version }}*
state: present
force: yes
Expand All @@ -46,7 +48,7 @@
- Build search index

- name: Install | Start and enable services
service:
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: yes
Expand Down
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---

- name: Install zammad
import_tasks: install.yml
ansible.builtin.import_tasks: install.yml

- name: Set up SSL/TLS
import_tasks: ssl.yml
ansible.builtin.import_tasks: ssl.yml

- name: Configure nginx
import_tasks: nginx-config.yml
ansible.builtin.import_tasks: nginx-config.yml

...
4 changes: 2 additions & 2 deletions tasks/nginx-config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---

- name: Nginx | Create config
template:
ansible.builtin.template:
src: nginx-zammad.conf.j2
dest: "{{ zammad_nginx_config_path }}"
mode: 0644
owner: root
group: root
notify: reload nginx
notify: Reload nginx

...
10 changes: 5 additions & 5 deletions tasks/ssl.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: SSL | Insert private key
blockinfile:
ansible.builtin.blockinfile:
path: "{{ zammad_ssl_key_path }}"
create: true
block: |
Expand All @@ -12,7 +12,7 @@
when: zammad_ssl_key is defined or zammad_ssl_key|length > 0

- name: SSL | Insert certificate
blockinfile:
ansible.builtin.blockinfile:
path: "{{ zammad_ssl_cert_path }}"
create: true
block: |
Expand All @@ -23,19 +23,19 @@
when: zammad_ssl_cert is defined or zammad_ssl_cert|length > 0

- name: SSL | Check if certificate is still valid, ignoring failures
openssl_certificate_info:
community.crypto.x509_certificate_info:
path: "{{ zammad_ssl_cert_path }}"
register: certificate
ignore_errors: "{{ ansible_check_mode }}"

- name: SSL | Ensure certificate and private key match
openssl_privatekey_info:
community.crypto.openssl_privatekey_info:
path: "{{ zammad_ssl_key_path }}"
register: private_key
ignore_errors: "{{ ansible_check_mode }}"

- name: SSL | Validate that certificate is still valid
assert:
ansible.builtin.assert:
that:
- not certificate.expired
- certificate.public_key == private_key.public_key
Expand Down

0 comments on commit 0baf3fa

Please sign in to comment.