Skip to content

Commit

Permalink
Update project dependencies (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak authored Oct 27, 2023
1 parent d5d088d commit b78d0d8
Show file tree
Hide file tree
Showing 28 changed files with 1,579 additions and 421 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file contains ignores rule violations for ansible-lint
meta/main.yml schema[meta]
36 changes: 20 additions & 16 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
---
name: Lint
name: lint

on:
push:
branches-ignore:

pull_request:
branches:
- master

defaults:

run:
working-directory: 'nephelaiio.rabbitmq'
working-directory: 'nephelaiio.mongos'

jobs:

lint:
name: Lint

name: lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
- name: Check out the codebase
uses: actions/checkout@v4
with:
path: 'nephelaiio.rabbitmq'
path: 'nephelaiio.mongos'

- name: Set up Python 3.
uses: actions/setup-python@v2
- name: Set up python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint ansible-lint
- name: Update ubuntu repositories
run: sudo apt-get update

- name: Install make
run: sudo apt-get install -y make

- name: Lint code.
run: |
yamllint .
ansible-lint .
- name: Lint code
run: make lint
68 changes: 0 additions & 68 deletions .github/workflows/main.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: molecule

on:

pull_request:
branches:
- master
schedule:
- cron: "0 5 * * 5"

defaults:

run:
working-directory: 'nephelaiio.mongos'

jobs:

molecule:

name: molecule
runs-on: ubuntu-latest
strategy:
matrix:
scenario:
- name: default
image:
- name: ubuntu2204
command: /lib/systemd/systemd
- name: ubuntu2004
command: /lib/systemd/systemd
- name: debian12
command: /lib/systemd/systemd
- name: debian11
command: /lib/systemd/systemd
steps:
- name: Check out the codebase
uses: actions/checkout@v4
with:
path: 'nephelaiio.mongos'

- name: Set up python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Update ubuntu repositories
run: sudo apt-get update

- name: Install make
run: sudo apt-get install -y make

- name: Install dependencies
run: make install

- name: Debug test environment
run: make debug

- name: Run molecule tests.
run: make test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DOCKER_IMAGE: ${{ matrix.image.name }}
MOLECULE_DOCKER_COMMAND: ${{ matrix.image.command }}
MOLECULE_SCENARIO: ${{ matrix.scenario.name }}
30 changes: 20 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,38 @@ on:
- "*"

defaults:

run:
working-directory: 'nephelaiio.rabbitmq'
working-directory: 'nephelaiio.mongos'

jobs:

release:

name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: 'nephelaiio.rabbitmq'
path: 'nephelaiio.mongos'

- name: Set up Python 3.
uses: actions/setup-python@v2
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Ansible.
run: pip3 install ansible-base
- name: Update ubuntu repositories
run: sudo apt-get update

- name: Install make
run: sudo apt-get install -y make

- name: Install dependencies
run: make install

- name: Trigger a new import on Galaxy.
run: >-
ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo $GITHUB_REPOSITORY | cut -d/ -f1) $(echo $GITHUB_REPOSITORY | cut -d/ -f2)
- name: Trigger a new import on galaxy
run: make publish
env:
GALAXY_API_KEY: "${{ secrets.GALAXY_API_KEY }}"
GITHUB_REPOSITORY: "${{ github.repository }}"
7 changes: 7 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fileignoreconfig:
- filename: poetry.lock
ignore_detectors: [filecontent]
- filename: .github/workflows/release.yml
ignore_detectors: [filecontent]
- filename: molecule/default/molecule.yml
ignore_detectors: [filecontent]
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.PHONY: all ${MAKECMDGOALS}

MOLECULE_SCENARIO ?= default
MOLECULE_DOCKER_IMAGE ?= ubuntu2204
GALAXY_API_KEY ?=
GITHUB_REPOSITORY ?= $$(git config --get remote.origin.url | cut -d: -f 2 | cut -d. -f 1)
GITHUB_ORG = $$(echo ${GITHUB_REPOSITORY} | cut -d/ -f 1)
GITHUB_REPO = $$(echo ${GITHUB_REPOSITORY} | cut -d/ -f 2)
REQUIREMENTS = requirements.yml

all: install version lint test

install:
@type poetry >/dev/null || pip3 install poetry
@poetry install

lint: install
poetry run yamllint .
poetry run ansible-lint .
poetry run molecule syntax

roles:
[ -f ${REQUIREMENTS} ] && yq '.$@[] | .name' -r < ${REQUIREMENTS} \
| xargs -L1 poetry run ansible-galaxy role install --force || exit 0

collections:
[ -f ${REQUIREMENTS} ] && yq '.$@[]' -r < ${REQUIREMENTS} \
| xargs -L1 echo poetry run ansible-galaxy -vvv collection install --force || exit 0

requirements: roles collections

dependency create prepare converge idempotence side-effect verify destroy login reset:
MOLECULE_DOCKER_IMAGE=${MOLECULE_DOCKER_IMAGE} poetry run molecule $@ -s ${MOLECULE_SCENARIO}

ignore:
poetry run ansible-lint --generate-ignore

clean: destroy reset
@poetry env remove $$(which python) >/dev/null 2>&1 || exit 0

publish:
@echo publishing repository ${GITHUB_REPOSITORY}
@echo GITHUB_ORGANIZATION=${GITHUB_ORG}
@echo GITHUB_REPOSITORY=${GITHUB_REPO}
@poetry run ansible-galaxy role import \
--api-key ${GALAXY_API_KEY} ${GITHUB_ORG} ${GITHUB_REPO}

version:
@poetry run molecule --version

debug: version
@poetry export --dev --without-hashes
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ Please refer to the [defaults file](/defaults/main.yml) for an up to date list o
- hosts: servers
roles:
- role: rabbitmq
rabbitmq_packages_state: latest
rabbitmq_package_state: latest


## Testing

Please make sure your environment has [docker](https://www.docker.com) installed in order to run role validation tests. Additional python dependencies are listed in the [requirements file](https://github.com/nephelaiio/ansible-role-requirements/blob/master/requirements.txt)

Role is tested against the following distributions (docker images):
* Ubuntu Xenial
* Ubuntu Bionic
* CentOS 7
* Debian Stretch
* Arch Linux
* Ubuntu 22.04
* Ubuntu 20.04
* Debian 12
* Debian 11

You can test the role directly from sources using command ` molecule test `

Expand Down
20 changes: 5 additions & 15 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
---
# rabbitmq_packages:

rabbitmq_packages_state: present

# rabbitmq_service_names:

rabbitmq_service_status: started

rabbitmq_service_enabled: yes

# rabbitmq_package:
# rabbitmq_service_name:
# rabbitmq_vhost: ''

# rabbitmq_user_name: ''

rabbitmq_package_state: present
rabbitmq_service_status: started
rabbitmq_service_enabled: true
rabbitmq_user_pass: ''

rabbitmq_user_perm_conf: '.*'

rabbitmq_user_perm_write: '.*'

rabbitmq_user_perm_read: '.*'

rabbitmq_user_tags: []
19 changes: 12 additions & 7 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
- name: remove default vhost
command: rabbitmqctl delete_vhost /
when:
- rabbitmq_vhost is defined
- name: Remove default vhost
ansible.builtin.command: rabbitmqctl delete_vhost /
listen: vhost_remove
when: rabbitmq_vhost is defined
changed_when: true

- name: remove guest user
command: rabbitmqctl delete_user guest
when: "'guest' in rabbitmq_users.stdout"
- name: Remove guest user
ansible.builtin.command: rabbitmqctl delete_user guest
listen: guest_remove
vars:
_output: guest
when: _output in rabbitmq_users.stdout
changed_when: true
Loading

0 comments on commit b78d0d8

Please sign in to comment.