add ansible
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
lint: |
|
||||
set -e
|
||||
yamllint .
|
||||
flake8
|
||||
|
||||
platforms:
|
||||
- name: instance
|
||||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1804}-ansible:latest"
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
privileged: true
|
||||
pre_build_image: true
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
scenario:
|
||||
name: default
|
||||
verifier:
|
||||
name: testinfra
|
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- ansible-role-promtail
|
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Ensure that net-tools is available
|
||||
package:
|
||||
name: net-tools
|
||||
state: present
|
||||
when: ansible_os_family == 'RedHat'
|
@@ -0,0 +1,64 @@
|
||||
import os
|
||||
import pytest
|
||||
import yaml
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def AnsibleDefaults():
|
||||
with open("./defaults/main.yml", 'r') as stream:
|
||||
return yaml.full_load(stream)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dir", [
|
||||
"/opt/promtail",
|
||||
"/etc/promtail",
|
||||
"/etc/promtail/file_sd",
|
||||
"/var/lib/promtail",
|
||||
])
|
||||
def test_directories(host, dir):
|
||||
d = host.file(dir)
|
||||
assert d.is_directory
|
||||
assert d.exists
|
||||
|
||||
|
||||
@pytest.mark.parametrize("files", [
|
||||
"/etc/systemd/system/promtail.service",
|
||||
"/usr/local/bin/promtail",
|
||||
"/etc/promtail/promtail.yml"
|
||||
])
|
||||
def test_files(host, files):
|
||||
f = host.file(files)
|
||||
assert f.exists
|
||||
assert f.is_file
|
||||
|
||||
|
||||
def test_user(host):
|
||||
assert host.group("promtail").exists
|
||||
assert host.user("promtail").exists
|
||||
|
||||
|
||||
def test_service(host):
|
||||
s = host.service("promtail")
|
||||
assert s.is_running
|
||||
|
||||
|
||||
def test_http_socket(host):
|
||||
s = host.socket("tcp://0.0.0.0:9080")
|
||||
assert s.is_listening
|
||||
|
||||
|
||||
def test_grpc_socket(host):
|
||||
s = host.socket("tcp://0.0.0.0:9095")
|
||||
assert s.is_listening
|
||||
|
||||
|
||||
def test_version(host, AnsibleDefaults):
|
||||
version = os.getenv('PROMTAIL', AnsibleDefaults['promtail_version'])
|
||||
out = host.run("/usr/local/bin/promtail --version").stdout
|
||||
assert version in out
|
||||
assert "promtail" in out
|
Reference in New Issue
Block a user