-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from punktDe/ansible-lint-molecule
Add molecule testing, add ansible-lint commit hook, fix linting errors
- Loading branch information
Showing
20 changed files
with
377 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
skip_list: | ||
- 'risky-shell-pipe' | ||
- 'role-name' | ||
|
||
warn_list: | ||
- package-latest | ||
- unnamed-task | ||
- command-instead-of-shell | ||
- no-handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: Test | ||
run-name: Run molecule tests on the role | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies. | ||
run: pip install yamllint ansible-lint ansible | ||
|
||
- name: Run ansible-lint | ||
run: "ansible-lint" | ||
|
||
molecule: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies. | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install ansible docker molecule molecule-plugins | ||
- name: Install Galaxy dependencies. | ||
run: ansible-galaxy collection install community.docker community.mysql | ||
|
||
- name: Run molecule | ||
run: "molecule test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
*.pyc | ||
__pycache__ | ||
files/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/ansible/ansible-lint.git | ||
rev: v6.22.1 | ||
hooks: | ||
- id: ansible-lint | ||
files: \.(yaml|yml)$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
# Based on ansible-lint config | ||
extends: default | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
colons: | ||
max-spaces-after: -1 | ||
level: error | ||
commas: | ||
max-spaces-after: -1 | ||
level: error | ||
comments: disable | ||
comments-indentation: disable | ||
document-start: disable | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
indentation: disable | ||
key-duplicates: enable | ||
line-length: disable | ||
new-line-at-end-of-file: disable | ||
new-lines: | ||
type: unix | ||
trailing-spaces: disable | ||
truthy: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
--- | ||
- name: Start MariaDB | ||
service: | ||
ansible.builtin.service: | ||
name: "{{ mariadb.service }}" | ||
state: started | ||
register: mysqld_service_result | ||
|
||
- name: Restart MariaDB | ||
throttle: 1 | ||
service: | ||
ansible.builtin.service: | ||
name: "{{ mariadb.service }}" | ||
state: restarted | ||
when: not (mysqld_service_result is defined and mysqld_service_result.changed) | ||
|
||
- name: Restart garb | ||
service: | ||
ansible.builtin.service: | ||
name: garb | ||
state: restarted | ||
when: not mariadb_service_garb_start_result.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
--- | ||
dependencies: [] | ||
|
||
galaxy_info: | ||
author: "Punkt.de" | ||
license: "MIT" | ||
description: "MariaDB role for Proserver" | ||
role_name: "proserver_mariadb" | ||
namespace: "punktde" | ||
min_ansible_version: "2.15" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
tasks: | ||
- name: "Include ansible-proserver-mariadb" | ||
ansible.builtin.include_role: | ||
name: "ansible-proserver-mariadb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: geerlingguy/docker-ubuntu2204-ansible | ||
command: /lib/systemd/systemd | ||
pre_build_image: true | ||
privileged: true | ||
cgroupns_mode: host | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
provisioner: | ||
name: ansible | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: Example assertion | ||
ansible.builtin.assert: | ||
that: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
--- | ||
- name: Confiure garb (garb.cnf) | ||
when: mariadb.galera.arbitrator | ||
template: | ||
ansible.builtin.template: | ||
src: garb.cnf | ||
dest: /etc/default/garb | ||
owner: root | ||
mode: "0644" | ||
notify: Restart garb |
Oops, something went wrong.