14 Commits
0.7.0 ... 0.8.0

Author SHA1 Message Date
bd62e6316e Updating to 0.8.0 2017-10-30 19:54:29 +01:00
b86a9f29a3 Merge pull request #38 from tszym/rename_tags_parameter
Use telegra_global_tags for oldest telegraf versions
2017-10-24 18:48:31 +02:00
b2a1652c47 Use telegra_global_tags for oldest telegraf versions
Users will use the same config key for global tags regardless of the
telegraf version.
Also fix the documentation about this parameter to be consistent with
changes from #37
2017-10-24 15:06:47 +02:00
2bee19f8a1 Merge pull request #37 from aarnaud/master
Fix extra plugins by file  /  Change apt source filename / Change tags by global_tags
2017-10-24 11:55:57 +02:00
87e6e95c72 Fix extra plugins by file 2017-10-23 23:10:25 -04:00
4fb8da24af Change apt source filename 2017-10-23 23:10:24 -04:00
b4317d8e5d Change tags by global_tags 2017-10-23 23:10:09 -04:00
7766329cb8 Merge pull request #36 from tszym/remove-redhat-useless-packages
Remove useless packages on RedHat. fix #28
2017-10-18 14:54:16 +02:00
1e57d51575 Remove useless packages on RedHat. fix #28
Once used for testing, these packages are no longer useful and can even
lead to certain issues, as installation can fail.
2017-10-18 14:41:35 +02:00
163284ab36 Merge pull request #35 from tszym/fix-lsb-usage
Test if LSB codename exists before using it
2017-10-17 17:16:25 +02:00
a08dee2562 Test if LSB codename exists before using it
Testing Debian with Molecule, Ansible will see the ansible_lsb defined
but the codename attribute is not. Testing its definition will prevent
access to an undifined attribute.
2017-10-17 14:24:19 +02:00
9e0be2c3d2 Setting to 1.4 2017-09-11 10:14:27 +02:00
82ca1ef61d Merge pull request #31 from dj-wasabi/port_molecule_v2
Updating to Molecule V2
2017-09-10 18:18:08 +02:00
4f8fa12fad Updating to Molecule V2 2017-09-10 18:11:07 +02:00
23 changed files with 202 additions and 107 deletions

View File

@ -4,17 +4,12 @@ language: python
services:
- docker
before_install:
- sudo apt-get -qq update
- sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-engine
install:
- pip install molecule ansible docker-py
- pip install molecule ansible docker
script:
- molecule --version
- ansible --version
- molecule test
- molecule --version
- ansible --version
- molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -5,6 +5,14 @@ Below an overview of all changes in the releases.
Version (Release date)
0.8.0 (2017-10-30)
* Updating to Molecule V2
* Test if LSB codename exists before using it #35 (By pull request: tszym (Thanks!))
* Remove useless packages on RedHat. fix #28 #36 (By pull request: tszym (Thanks!))
* Fix extra plugins by file / Change apt source filename / Change tags by global_tags #37 (By pull request: aarnaud (Thanks!))
* Use telegra_global_tags for oldest telegraf versions #38 (By pull request: tszym (Thanks!))
0.7.0 (2017-02-23)
* Replace action by modules #26 (By pull request: tszym (Thanks!))

View File

@ -47,7 +47,7 @@ Full agent settings reference: https://github.com/influxdata/telegraf/blob/maste
You can set tags for the host running telegraf:
telegraf_agent_tags:
telegraf_global_tags:
- tag_name: some_name
tag_value: some_value

View File

@ -1,8 +1,7 @@
---
# defaults file for ansible-telegraf
#telegraf_agent_version: 0.10.1
telegraf_agent_version: 1.0.0
telegraf_agent_version: 1.4.0
telegraf_agent_hostname: "{{ ansible_fqdn }}"
telegraf_agent_interval: 10
telegraf_agent_debug: False
@ -10,17 +9,17 @@ telegraf_agent_round_interval: True
telegraf_agent_flush_interval: 10
telegraf_agent_flush_jitter: 0
#v0.13 settings (not sure if supported in older version):
# v0.13 settings (not sure if supported in older version):
telegraf_agent_collection_jitter: 0
telegraf_agent_metric_batch_size: 1000
telegraf_agent_metric_buffer_limit: 10000
telegraf_agent_quiet: False
#v1.1 settings:
# v1.1 settings:
telegraf_agent_logfile: ""
telegraf_agent_omit_hostname: False
telegraf_agent_tags:
telegraf_global_tags: []
telegraf_agent_output:
- type: influxdb

View File

@ -1,24 +0,0 @@
---
ansible:
playbook: playbook.yml
driver:
name: docker
verifier:
name: testinfra
docker:
containers:
- name: telegraf-centos
ansible_groups:
- group1
image: milcom/centos7-systemd
image_version: latest
privileged: True
- name: telegraf-debian
ansible_groups:
- group2
image: maint/debian-systemd
image_version: latest
privileged: True

View File

@ -0,0 +1,7 @@
FROM {{ item.image }}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi

View File

@ -0,0 +1,46 @@
*******
Install
*******
This set of playbooks have specific dependencies on Ansible due to the modules
being used.
Requirements
============
* Ansible 2.2
* Docker Engine
* docker-py
Install OS dependencies on CentOS 7
.. code-block:: bash
$ sudo yum install -y epel-release
$ sudo yum install -y gcc python-pip python-devel openssl-devel
# If installing Molecule from source.
$ sudo yum install libffi-devel git
Install OS dependencies on Ubuntu 16.x
.. code-block:: bash
$ sudo apt-get update
$ sudo apt-get install -y python-pip libssl-dev docker-engine
# If installing Molecule from source.
$ sudo apt-get install -y libffi-dev git
Install OS dependencies on Mac OS
.. code-block:: bash
$ brew install python
$ brew install git
Install using pip:
.. code-block:: bash
$ sudo pip install ansible
$ sudo pip install docker-py
$ sudo pip install molecule --pre

View File

@ -0,0 +1,47 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: False
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
tasks:
- name: Create Dockerfiles from image names
template:
src: "{{ molecule_scenario_directory }}/Dockerfile.j2"
dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}"
with_items: "{{ molecule_yml.platforms }}"
register: platforms
- name: Discover local Docker images
docker_image_facts:
name: "molecule_local/{{ item.item.name }}"
with_items: "{{ platforms.results }}"
register: docker_images
- name: Build an Ansible compatible image
docker_image:
path: "{{ molecule_ephemeral_directory }}"
name: "molecule_local/{{ item.item.image }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force: "{{ item.item.force | default(True) }}"
with_items: "{{ platforms.results }}"
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
- name: Create molecule instance(s)
docker_container:
name: "{{ item.name }}"
hostname: "{{ item.name }}"
image: "molecule_local/{{ item.image }}"
state: started
recreate: False
log_driver: syslog
command: "{{ item.command | default('sleep infinity') }}"
privileged: "{{ item.privileged | default(omit) }}"
volumes: "{{ item.volumes | default(omit) }}"
capabilities: "{{ item.capabilities | default(omit) }}"
with_items: "{{ molecule_yml.platforms }}"

View File

@ -0,0 +1,16 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: False
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
tasks:
- name: Destroy molecule instance(s)
docker_container:
name: "{{ item.name }}"
state: absent
force_kill: "{{ item.force_kill | default(True) }}"
with_items: "{{ molecule_yml.platforms }}"

View File

@ -0,0 +1,28 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: telegraf-centos
image: milcom/centos7-systemd
privileged: True
- name: telegraf-debian
image: maint/debian-systemd
privileged: True
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8

View File

@ -1,6 +1,9 @@
from testinfra.utils.ansible_runner import AnsibleRunner
import os
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_telegraf_running_and_enabled(Service, SystemInfo):

Binary file not shown.

View File

@ -0,0 +1,9 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
truthy: disable

View File

@ -18,7 +18,7 @@
- telegraf
- packages
- name: Download Influxdb apt key.
- name: Download Telegraf apt key.
apt_key:
url: "https://repos.influxdata.com/influxdb.key"
state: present
@ -27,27 +27,27 @@
- telegraf
- packages
- name: Add Influxdb repository (using LSB).
- name: Add Telegraf repository (using LSB).
apt_repository:
repo: "deb https://repos.influxdata.com/{{ ansible_distribution|lower }} {{ ansible_lsb.codename }} stable"
filename: "influxdb"
filename: "telegraf"
state: present
become: yes
tags:
- telegraf
- packages
when: ansible_lsb is defined
when: ansible_lsb is defined and ansible_lsb.codename is defined
- name: Add Influxdb repository.
- name: Add Telegraf repository.
apt_repository:
repo: "deb https://repos.influxdata.com/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable"
filename: "influxdb"
filename: "telegraf"
state: present
become: yes
tags:
- telegraf
- packages
when: ansible_lsb is not defined
when: ansible_lsb is not defined or ansible_lsb.codename is not defined
- name: "Install telegraf package | Debian"
apt:

View File

@ -1,30 +1,5 @@
---
- name: "Enable EPEL"
yum:
name: epel-release
state: installed
- name: "Installing some dependencies"
yum:
name: "{{ item }}"
state: installed
with_items:
- python-pip
- python-devel
- gcc
- libffi-devel
- openssl-devel
- name: "Installing PIP dependensies"
pip:
name: "{{ item }}"
state: present
with_items:
- urllib3
- pyopenssl
- ndg-httpsclient
- name: "Add yum repository | RedHat"
yum_repository:
name: influxdb

View File

@ -34,10 +34,11 @@
- name: "Copy telegraf extra plugins"
template:
src: "telegraf-extra-plugin.conf.j2"
dest: "/etc/telegraf/telegraf.d/extra-plugins.conf"
dest: "/etc/telegraf/telegraf.d/{{ item.plugin }}.conf"
owner: telegraf
group: telegraf
mode: 0640
with_items: "{{ telegraf_plugins_extra }}"
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable"
become: yes
notify: "Restart Telegraf"

View File

@ -1,8 +1,8 @@
# Telegraf configuration
[tags]
{% if telegraf_agent_tags is defined and telegraf_agent_tags is iterable %}
{% for item in telegraf_agent_tags %}
{% if telegraf_global_tags is defined and telegraf_global_tags is iterable %}
{% for item in telegraf_global_tags %}
{{ item.tag_name }} = "{{ item.tag_value }}"
{% endfor %}
{% endif %}

View File

@ -1,5 +1,3 @@
{% if telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable %}
{% for item in telegraf_plugins_extra %}
[[inputs.{{ item.plugin }}]]
{% if item.interval is defined %}
interval = "{{ item.interval }}s"
@ -45,5 +43,3 @@
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

View File

@ -1,8 +1,8 @@
# Telegraf configuration
[tags]
{% if telegraf_agent_tags is defined and telegraf_agent_tags is iterable %}
{% for item in telegraf_agent_tags %}
[global_tags]
{% if telegraf_global_tags is defined and telegraf_global_tags is iterable %}
{% for item in telegraf_global_tags %}
{{ item.tag_name }} = "{{ item.tag_value }}"
{% endfor %}
{% endif %}

View File

@ -1,6 +0,0 @@
localhost
[group1]
telegraf-centos
[group2]
telegraf-debian

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- ansible-zabbix-agent