-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
596fb80
commit a0d6740
Showing
11 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
skip_list: | ||
- no-handler | ||
- command-instead-of-shell | ||
- no-changed-when | ||
- line-length | ||
- fqcn-builtins |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @francomile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: "Lint Ansible roles" | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
|
||
jobs: | ||
ansible-lint: | ||
name: "Ansible Lint" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Lint Ansible Playbook" | ||
uses: ansible/ansible-lint-action@v6.0.2 | ||
with: | ||
path: ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
# This workflow requires a GALAXY_API_TOKEN secret present in the GitHub repository or organization. The TOKEN can be generated in https://galaxy.ansible.com/ui/token/ | ||
|
||
name: "Release role to Ansible Galaxy" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
|
||
defaults: | ||
run: | ||
working-directory: "francomile.common" | ||
|
||
jobs: | ||
release: | ||
name: "Release to Galaxy" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Check out." | ||
uses: actions/checkout@v4 | ||
with: | ||
path: "francomile.common" | ||
|
||
- name: "Set up Python 3." | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: "Install Ansible." | ||
run: pip3 install ansible-core | ||
|
||
- name: "Import to Galaxy." | ||
run: >- | ||
ansible-galaxy role import --token ${{ secrets.GALAXY_API_TOKEN }} | ||
francomile $(echo ${{ github.repository }} | cut -d/ -f2 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.vscode | ||
.idea | ||
.dccache | ||
######## DON'T REMOVE THE BELOW FILE IGNORE ################# | ||
# ignore secret variables file for Ansible sensitive variables. | ||
**/secret_vars.yaml* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Ansible Prometheus Node Exporter Role | ||
|
||
## Actions of the Role | ||
|
||
* Install Prometheus node_exporter | ||
|
||
## Common Usage | ||
|
||
```yaml | ||
roles: | ||
- { | ||
role: prom_node_exporter, | ||
prom_node_exporter_basedir: "/opt/node_exporter", | ||
prom_node_exporter_version: "v1.8.1", | ||
tags: ["node-exporter"] | ||
} | ||
``` | ||
|
||
## Run the playbook | ||
|
||
```shell | ||
ansible-playbook -i inventory playbook.yaml -t "node-exporter" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
prom_node_exporter_basedir: "/opt/node_exporter" | ||
prom_node_exporter_version: "v1.8.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: "Restart node_exporter" | ||
ansible.builtin.command: | ||
cmd: "docker compose -f {{ prom_node_exporter_basedir }}/docker-compose.yaml up -d --force-recreate" | ||
register: cmd_output | ||
changed_when: cmd_output.rc != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
galaxy_info: | ||
role_name: prom_node_exporter | ||
author: "Rubens Franco" | ||
description: "Install Prometheus node_exporter" | ||
license: "GNU GENERAL PUBLIC LICENSE v2" | ||
min_ansible_version: "2.9" | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- "jammy" | ||
- "focal" | ||
- "bionic" | ||
- name: Debian | ||
versions: | ||
- "bullseye" | ||
- "buster" | ||
- name: EL | ||
versions: | ||
- "9" | ||
- "8" | ||
galaxy_tags: | ||
- monitoring | ||
- observability | ||
- prometheus | ||
- exporter | ||
- node | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: "Prom Node Exporter | Create directories tree for node_exporter" | ||
ansible.builtin.file: | ||
path: "{{ prom_node_exporter_basedir }}" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: "0755" | ||
|
||
- name: "Prom Node Exporter | Copy docker-compose.yaml template" | ||
ansible.builtin.template: | ||
src: "docker-compose.yaml.j2" | ||
dest: "{{ prom_node_exporter_basedir }}/docker-compose.yaml" | ||
owner: root | ||
group: root | ||
mode: "0640" | ||
notify: "Restart node_exporter" | ||
|
||
- name: "Prom Node Exporter | Start node_exporter" | ||
ansible.builtin.command: | ||
cmd: "docker compose -f {{ prom_node_exporter_basedir }}/docker-compose.yaml up -d" | ||
register: cmd_output | ||
changed_when: cmd_output.rc != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: '3.9' | ||
|
||
services: | ||
node_exporter: | ||
image: prom/node-exporter:{{ prom_node_exporter_version }} | ||
container_name: node_exporter | ||
command: | ||
- '--path.rootfs=/host' | ||
- --collector.filesystem.ignored-mount-points | ||
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2)($$|/)" | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
network_mode: host | ||
pid: host | ||
volumes: | ||
- '/:/host:ro,rslave' | ||
logging: | ||
driver: "journald" |