Skip to content

Commit

Permalink
Merge pull request #36 from sleighzy/upgrade-github-actions
Browse files Browse the repository at this point in the history
Update GitHub actions for Node 16
  • Loading branch information
sleighzy authored Nov 29, 2023
2 parents 8940f73 + 6a33196 commit 9c444c6
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 74 deletions.
5 changes: 4 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ exclude_paths:
- ./molecule-venv/
- ./tests/roles/

mock_roles:
- sleighzy.zookeeper

skip_list:
- '106' # Role name does not match ``^[a-z][a-z0-9_]+$`` pattern
- '106' # Role name does not match ``^[a-z][a-z0-9_]+$`` pattern
5 changes: 4 additions & 1 deletion .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -31,3 +31,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
MARKDOWN_CONFIG_FILE: .markdownlint.json

- name: Ansible Lint
uses: ansible/ansible-lint@v6
6 changes: 3 additions & 3 deletions .github/workflows/molecule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ jobs:

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: 'sleighzy.kafka'

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

- name: Install test dependencies.
run: pip3 install ansible ansible-compat==0.5.0 ansible-lint yamllint docker molecule-docker "molecule[docker,lint]"
run: pip3 install ansible docker "molecule-plugins[docker]"

- name: Run Molecule tests.
run: molecule test
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ Linting should be done using [ansible-lint].
```sh
pip3 install ansible-lint --user

ansible-lint -c ./.ansible-lint .
```

## Testing
Expand Down Expand Up @@ -212,7 +214,7 @@ molecule destroy

## License

[![MIT license]](https://lbesson.mit-license.org/)
![MIT license]

[ansible-lint]: https://docs.ansible.com/ansible-lint/
[ansible molecule]: https://molecule.readthedocs.io/
Expand Down
7 changes: 4 additions & 3 deletions handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
- name: Reload initd
command: initctl reload-configuration
ansible.builtin.command: initctl reload-configuration
changed_when: false

- name: Restart kafka service
service:
ansible.builtin.service:
name: kafka
state: restarted
when: kafka_restart

- name: Restart kafka systemd
systemd:
ansible.builtin.systemd:
name: kafka
state: restarted
daemon_reload: yes
Expand Down
6 changes: 3 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ galaxy_info:
platforms:
- name: EL
versions:
- 6
- 7
- 8
- '6'
- '7'
- '8'
- name: Debian
versions:
- buster
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

tasks:
- name: 'Test Kafka role'
include_role:
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
23 changes: 11 additions & 12 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ platforms:
ipv4_address: '172.40.10.1'
etc_hosts: "{'server-2': '172.40.10.2', 'server-3': '172.40.10.3'}"
pre_build_image: true
privileged: True
privileged: true
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
capabilities:
- SYS_ADMIN
command: /lib/systemd/systemd
groups:
- kafka-nodes
- zookeeper-nodes
- name: server-2
image: centos:7
image: rockylinux:8
networks:
- name: kafka
ipv4_address: '172.40.10.2'
Expand All @@ -42,8 +43,10 @@ platforms:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: '/sbin/init'
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: '/usr/lib/systemd/systemd'
pre_build_image: true
capabilities:
- SYS_ADMIN
groups:
Expand All @@ -55,12 +58,13 @@ platforms:
- name: kafka
ipv4_address: '172.40.10.3'
etc_hosts: "{'server-1': '172.40.10.1', 'server-2': '172.40.10.2'}"
privileged: True
privileged: true
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: '/usr/lib/systemd/systemd'
pre_build_image: true
capabilities:
Expand Down Expand Up @@ -88,10 +92,6 @@ provisioner:
zookeeper_id: 3
kafka_broker_id: 2
kafka_listener_hostname: server-3
lint: |
set -e
yamllint -c ./.yamllint.yaml .
ansible-lint -c ./.ansible-lint
verifier:
name: ansible
scenario:
Expand All @@ -114,7 +114,6 @@ scenario:
- prepare
- converge
test_sequence:
- lint
- destroy
- dependency
- syntax
Expand Down
15 changes: 11 additions & 4 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,32 @@

pre_tasks:
- name: Install Java 8 (OpenJDK) on RedHat/CentOS
yum:
ansible.builtin.yum:
name: java-1.8.0-openjdk
state: installed
when: ansible_os_family == "RedHat"

- name: Install Java 11 (OpenJDK) on Debian
apt:
ansible.builtin.apt:
name: openjdk-11-jdk
state: present
update_cache: yes
when: ansible_os_family == "Debian"

# The installation of this package into the Debian container means
# The installation of this package into the container means
# that the "ps" command is available for viewing the running process.
# Installing this package however also prevents an issue whereby the
# ZooKeeper service is constantly restarted by systemd which causes
# the Molecule tests to fail as the service is not started correctly.
- name: Install ps on Debian
apt:
ansible.builtin.apt:
name: procps
state: present
when: ansible_os_family == "Debian"

- name: Install ps on Rocky Linux
ansible.builtin.yum:
name: procps
state: present
use_backend: dnf
when: ansible_distribution == "Rocky" and ansible_distribution_major_version == "8"
30 changes: 15 additions & 15 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,64 @@

tasks:
- name: Get users
getent:
ansible.builtin.getent:
database: passwd

- name: Get groups
getent:
ansible.builtin.getent:
database: group

- name: Assert that user and group 'kafka' exists
assert:
ansible.builtin.assert:
that:
- "'kafka' in getent_passwd"
- "'kafka' in getent_group"

- name: Register '/opt/kafka_2.13-3.5.1' installation directory status
stat:
ansible.builtin.stat:
path: '/opt/kafka_2.13-3.5.1'
register: install_dir

- name: Assert that '/opt/kafka_2.13-3.5.1' directory is created
assert:
ansible.builtin.assert:
that:
- install_dir.stat.exists
- install_dir.stat.isdir
- install_dir.stat.pw_name == 'kafka'
- install_dir.stat.gr_name == 'kafka'

- name: Register '/opt/kafka' symlink directory status
stat:
ansible.builtin.stat:
path: '/opt/kafka'
register: kafka_dir

- name: Assert that '/opt/kafka' symlink is created
assert:
ansible.builtin.assert:
that:
- kafka_dir.stat.exists
- kafka_dir.stat.islnk
- kafka_dir.stat.lnk_target == '/opt/kafka_2.13-3.5.1'

- name: Register '/var/log/kafka' directory status
stat:
ansible.builtin.stat:
path: '/var/log/kafka'
register: kafka_log_dir

- name: Assert that '/var/log/kafka' directory is created
assert:
ansible.builtin.assert:
that:
- kafka_log_dir.stat.exists
- kafka_log_dir.stat.isdir
- kafka_log_dir.stat.pw_name == 'kafka'
- kafka_log_dir.stat.gr_name == 'kafka'

- name: Register '/opt/kafka/logs' symlink directory status
stat:
ansible.builtin.stat:
path: '/opt/kafka/logs'
register: application_logs_symlink

- name: Assert that '/opt/kafka/logs' symlink is created
assert:
ansible.builtin.assert:
that:
- application_logs_symlink.stat.exists
- application_logs_symlink.stat.islnk
Expand All @@ -69,23 +69,23 @@
- application_logs_symlink.stat.gr_name == 'kafka'

- name: Register '/etc/kafka' directory status
stat:
ansible.builtin.stat:
path: '/etc/kafka'
register: config_dir

- name: Assert that '/etc/kafka' directory is created
assert:
ansible.builtin.assert:
that:
- config_dir.stat.exists
- config_dir.stat.isdir
- config_dir.stat.pw_name == 'kafka'
- config_dir.stat.gr_name == 'kafka'

- name: Populate service facts
service_facts:
ansible.builtin.service_facts:

- name: Assert that Kafka service is installed, running, and enabled
assert:
ansible.builtin.assert:
that:
- "'kafka.service' in ansible_facts.services"
- ansible_facts.services['kafka.service'].state == 'running'
Expand Down
Loading

0 comments on commit 9c444c6

Please sign in to comment.