Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add molecule tests #20

Merged
merged 4 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ None. But, Grafana Agent's configuration file has had some breaking changes rece

See an example playbook I run for my home-lab [here](https://github.com/nleiva/ansible-home/blob/main/grafana-cloud.yml).

## Testing

The role is tested using [Molecule](https://molecule.readthedocs.io/en/latest/). Dependencies for testing are `podman` and its plugin for Molecule.

Run `molecule test` in the repository root to test the role.

## License

GPL-3.0 License
Expand Down
22 changes: 22 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Converge
hosts: all

vars:
# Bogus values to avoid failure in
# Grafana agent template rendering
prometheus_user: alice
grafana_api_key: bob

pre_tasks:
# Update the APT cache to prevent
# failue when installing unzip
- name: Update APT cache
when: ansible_os_family == "Debian"
ansible.builtin.apt:
update_cache: true

tasks:
- name: "Include ansible-role-grafana_agent"
ansible.builtin.include_role:
name: "ansible-role-grafana_agent"
24 changes: 24 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
dependency:
name: galaxy

driver:
name: podman

platforms:
- name: debian
image: quay.io/nleiva/grafana-agent-role-debian
pre_build_image: true
command: /lib/systemd/systemd
privileged: true
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro

provisioner:
name: ansible

verifier:
name: ansible
2 changes: 1 addition & 1 deletion templates/grafana-agent.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description=Grafana Cloud agent

[Service]
Type=simple
ExecStart={{ agent_location }}/agent-linux-{{ grafana_agent_type[ansible_architecture] }} --config.file={{ config_location }}/agent-config.yaml
ExecStart={{ agent_location }}/grafana-agent-linux-{{ grafana_agent_type[ansible_architecture] }} --config.file={{ config_location }}/agent-config.yaml
Restart=always

[Install]
Expand Down