-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:dj-wasabi/ansible-telegraf
- Loading branch information
Showing
11 changed files
with
256 additions
and
40 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
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
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,4 @@ | ||
--- | ||
- hosts: telegraf | ||
roles: | ||
- role: ansible-telegraf |
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,70 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
|
||
platforms: | ||
- name: telegraf-${MY_MOLECULE_CONTAINER:-centos8} | ||
image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"} | ||
command: ${MY_MOLECULE_DOCKER_COMMAND:-""} | ||
privileged: True | ||
pre_build_image: True | ||
networks: | ||
- name: telegraf | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
groups: | ||
- telegraf | ||
|
||
provisioner: | ||
name: ansible | ||
lint: | ||
name: ansible-lint | ||
inventory: | ||
group_vars: | ||
debian: | ||
telegraf_agent_package_method: online | ||
all: | ||
telegraf_agent_package_state: latest | ||
telegraf_agent_output: | ||
- type: influxdb | ||
config: | ||
- urls = ["http://influxdb:8086"] | ||
- database = "telegraf" | ||
- precision = "s" | ||
telegraf_plugins_extra: | ||
logparser: | ||
plugin: logparser | ||
config: | ||
- files = ["/var/log/messages"] | ||
- from_beginning = false | ||
filter: | ||
name: grok | ||
config: | ||
- patterns = ["invoked oom-killer"] | ||
telegraf_aggregators: | ||
- aggregator: basicstats | ||
config: | ||
- drop_original = false | ||
- stats = ['mean'] | ||
tagpass: | ||
- cpu = ["cpu-total"] | ||
|
||
scenario: | ||
name: empty-checkmode | ||
test_sequence: | ||
- dependency | ||
- cleanup | ||
- destroy | ||
- syntax | ||
- create | ||
- prepare | ||
- check | ||
- verify | ||
- cleanup | ||
- destroy | ||
verifier: | ||
name: testinfra | ||
lint: | ||
name: flake8 |
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,46 @@ | ||
--- | ||
|
||
- hosts: telegraf | ||
tasks: | ||
- name: "Installing packages on CentOS" | ||
yum: | ||
name: which | ||
state: present | ||
when: | ||
- ansible_os_family == 'RedHat' | ||
|
||
- name: "Apt get update" | ||
shell: apt-get update | ||
when: | ||
- ansible_os_family == 'Debian' | ||
|
||
- name: "Installing packages on Debian" | ||
apt: | ||
name: | ||
- wget | ||
- "{{ 'gnupg-agent' if ansible_distribution_major_version in ['8', '18', '16'] else 'gpg-agent' }}" | ||
update_cache: True | ||
state: present | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution_major_version not in [9, 10] | ||
|
||
- name: "Installing packages on Debian" | ||
apt: | ||
name: | ||
- wget | ||
- python-apt | ||
- "{{ 'gnupg-agent' if ansible_distribution_major_version in ['8', '18', '16'] else 'gpg-agent' }}" | ||
update_cache: True | ||
state: present | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution_major_version in [9, 10] | ||
|
||
- name: "Installing packages on Suse" | ||
zypper: | ||
name: | ||
- aaa_base | ||
state: present | ||
when: | ||
- ansible_os_family == 'Suse' |
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,32 @@ | ||
import os | ||
|
||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | ||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('telegraf') | ||
|
||
|
||
def test_telegraf_running_and_enabled(host): | ||
telegraf = host.service("telegraf") | ||
if host.system_info.distribution not in ['opensuse-leap']: | ||
assert not telegraf.is_enabled | ||
assert not telegraf.is_running | ||
|
||
|
||
def test_telegraf_dot_conf(host): | ||
telegraf = host.file("/etc/telegraf/telegraf.conf") | ||
assert not telegraf.exists | ||
|
||
def test_telegraf_dot_d_dir(host): | ||
telegraf = host.file("/etc/telegraf/telegraf.d") | ||
assert not telegraf.exists | ||
|
||
|
||
def test_telegraf_dot_d(host): | ||
telegraf = host.file("/etc/telegraf/telegraf.d/logparser.conf") | ||
assert not telegraf.exists | ||
|
||
|
||
def test_telegraf_package(host): | ||
telegraf = host.package('telegraf') | ||
assert not telegraf.is_installed |
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
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
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
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
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