Skip to content

Commit

Permalink
patch: Misc improvs (#3)
Browse files Browse the repository at this point in the history
* Rollback version

* Use parameterized tests

* Modify internal var of dcgm_exporter to make it work with version_bumper

* Remove unnecessary preflight tasks

* Add pre-commit config
---------

Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri authored Feb 26, 2024
1 parent 6cb28c1 commit 2c9b71e
Show file tree
Hide file tree
Showing 21 changed files with 299 additions and 350 deletions.
3 changes: 3 additions & 0 deletions .config/molecule/config-podman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ platforms:
command: /lib/systemd/systemd
verifier:
name: testinfra
directory: ${MOLECULE_SCENARIO_DIRECTORY}/tests
options:
rootdir: "${MOLECULE_SCENARIO_DIRECTORY}"
provisioner:
playbooks:
converge: ${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/converge.yml
3 changes: 3 additions & 0 deletions .config/molecule/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ platforms:
command: /lib/systemd/systemd
verifier:
name: testinfra
directory: ${MOLECULE_SCENARIO_DIRECTORY}/tests
options:
rootdir: "${MOLECULE_SCENARIO_DIRECTORY}"
provisioner:
playbooks:
converge: ${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/converge.yml
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
repos:
- repo: https://github.com/ansible/ansible-lint.git
rev: v24.2.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
name: Ansible Lint
description: Run configurations on .ansible-lint file
verbose: true
2 changes: 1 addition & 1 deletion .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rules:
hyphens:
level: error
line-length:
max: 260
max: 200
truthy:
check-keys: false

Expand Down
9 changes: 0 additions & 9 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
=====================================
mahendrapaipuri.Ansible Release Notes
=====================================

.. contents:: Topics

v0.1.0
======

9 changes: 0 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,3 @@ Remember: Code is generally read much more often than written.
### Use Markdown

Wherever possible, please refrain from any other formats and stick to simple markdown.

## Requirements regarding roles design

We are trying to create the best and most secure installation method for non-containerized prometheus stack components.
To accomplish this all roles need to support:

- current and at least one previous ansible version
- systemd as the only available process manager
- at least latest debian and CentOS distributions
16 changes: 0 additions & 16 deletions changelogs/.plugin-cache.yaml

This file was deleted.

5 changes: 2 additions & 3 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
ancestor: null
releases:
0.1.0:
release_date: '2024-02-24'
releases: {}
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace: mahendrapaipuri
# The name of the collection. Has the same character restrictions as 'namespace'
name: ansible
# The version of the collection. Must be compatible with semantic versioning
version: 0.1.0
version: 0.0.0
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,44 @@

import os
import testinfra.utils.ansible_runner
import pytest

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_directories(host):
dirs = [
"/var/lib/ceems_api_server",
"/tmp/ceems_api_server"
]
for dir in dirs:
d = host.file(dir)
assert d.is_directory
assert d.exists


def test_files(host):
files = [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
]
for file in files:
f = host.file(file)
assert f.exists
assert f.is_file


def test_permissions_didnt_change(host):
dirs = [
"/etc",
"/root",
"/usr",
"/var"
]
for file in dirs:
f = host.file(file)
assert f.exists
assert f.is_directory
assert f.user == "root"
assert f.group == "root"
@pytest.mark.parametrize("dir", [
"/var/lib/ceems_api_server",
"/tmp/ceems_api_server"
])
def test_directories(host, dir):
d = host.file(dir)
assert d.is_directory
assert d.exists


@pytest.mark.parametrize("file", [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
])
def test_files(host, file):
f = host.file(file)
assert f.exists
assert f.is_file


@pytest.mark.parametrize("dir", [
"/etc",
"/root",
"/usr",
"/var"
])
def test_permissions_didnt_change(host, dir):
f = host.file(dir)
assert f.exists
assert f.is_directory
assert f.user == "root"
assert f.group == "root"


def test_user(host):
Expand Down Expand Up @@ -72,10 +70,9 @@ def test_systemd_properties(host):
assert p.get("Environment") == "foo=bar"


def test_socket(host):
sockets = [
"tcp://127.0.0.1:8080"
]
for socket in sockets:
s = host.socket(socket)
assert s.is_listening
@pytest.mark.parametrize("socket", [
"tcp://127.0.0.1:8080"
])
def test_socket(host, socket):
s = host.socket(socket)
assert s.is_listening
79 changes: 38 additions & 41 deletions roles/ceems_api_server/molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,43 @@

import os
import testinfra.utils.ansible_runner
import pytest

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_directories(host):
dirs = [
"/var/lib/ceems_api_server"
]
for dir in dirs:
d = host.file(dir)
assert d.is_directory
assert d.exists


def test_files(host):
files = [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
]
for file in files:
f = host.file(file)
assert f.exists
assert f.is_file


def test_permissions_didnt_change(host):
dirs = [
"/etc",
"/root",
"/usr",
"/var"
]
for file in dirs:
f = host.file(file)
assert f.exists
assert f.is_directory
assert f.user == "root"
assert f.group == "root"
@pytest.mark.parametrize("dir", [
"/var/lib/ceems_api_server"
])
def test_directories(host, dir):
d = host.file(dir)
assert d.is_directory
assert d.exists


@pytest.mark.parametrize("file", [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
])
def test_files(host, file):
f = host.file(file)
assert f.exists
assert f.is_file


@pytest.mark.parametrize("dir", [
"/etc",
"/root",
"/usr",
"/var"
])
def test_permissions_didnt_change(host, dir):
f = host.file(dir)
assert f.exists
assert f.is_directory
assert f.user == "root"
assert f.group == "root"


def test_user(host):
Expand Down Expand Up @@ -70,10 +68,9 @@ def test_protecthome_property(host):
assert p.get("ProtectHome") == "yes"


def test_socket(host):
sockets = [
"tcp://127.0.0.1:9020"
]
for socket in sockets:
s = host.socket(socket)
assert s.is_listening
@pytest.mark.parametrize("socket", [
"tcp://127.0.0.1:9020"
])
def test_socket(host, socket):
s = host.socket(socket)
assert s.is_listening
79 changes: 38 additions & 41 deletions roles/ceems_api_server/molecule/latest/tests/test_latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,43 @@

import os
import testinfra.utils.ansible_runner
import pytest

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_directories(host):
dirs = [
"/var/lib/ceems_api_server"
]
for dir in dirs:
d = host.file(dir)
assert d.is_directory
assert d.exists


def test_files(host):
files = [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
]
for file in files:
f = host.file(file)
assert f.exists
assert f.is_file


def test_permissions_didnt_change(host):
dirs = [
"/etc",
"/root",
"/usr",
"/var"
]
for file in dirs:
f = host.file(file)
assert f.exists
assert f.is_directory
assert f.user == "root"
assert f.group == "root"
@pytest.mark.parametrize("dir", [
"/var/lib/ceems_api_server"
])
def test_directories(host, dir):
d = host.file(dir)
assert d.is_directory
assert d.exists


@pytest.mark.parametrize("file", [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
])
def test_files(host, file):
f = host.file(file)
assert f.exists
assert f.is_file


@pytest.mark.parametrize("dir", [
"/etc",
"/root",
"/usr",
"/var"
])
def test_permissions_didnt_change(host, dir):
f = host.file(dir)
assert f.exists
assert f.is_directory
assert f.user == "root"
assert f.group == "root"


def test_user(host):
Expand Down Expand Up @@ -70,10 +68,9 @@ def test_protecthome_property(host):
assert p.get("ProtectHome") == "yes"


def test_socket(host):
sockets = [
"tcp://127.0.0.1:9020"
]
for socket in sockets:
s = host.socket(socket)
assert s.is_listening
@pytest.mark.parametrize("socket", [
"tcp://127.0.0.1:9020"
])
def test_socket(host, socket):
s = host.socket(socket)
assert s.is_listening
Loading

0 comments on commit 2c9b71e

Please sign in to comment.