mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
Merge pull request #130 from dj-wasabi/add-to-github-actions
Going to Github Actions
This commit is contained in:
68
.github/workflows/telegraf.yml
vendored
Normal file
68
.github/workflows/telegraf.yml
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
name: "ansible-telegraf"
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'defaults/**'
|
||||||
|
- 'files/**'
|
||||||
|
- 'handlers/**'
|
||||||
|
- 'meta/**'
|
||||||
|
- 'molecule/**'
|
||||||
|
- 'tasks/**'
|
||||||
|
- 'templates/**'
|
||||||
|
- '.github/workflows/telegraf.yml'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'defaults/**'
|
||||||
|
- 'files/**'
|
||||||
|
- 'handlers/**'
|
||||||
|
- 'meta/**'
|
||||||
|
- 'molecule/**'
|
||||||
|
- 'tasks/**'
|
||||||
|
- 'templates/**'
|
||||||
|
- '.github/workflows/telegraf.yml'
|
||||||
|
jobs:
|
||||||
|
molecule:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
molecule_distro:
|
||||||
|
- container: centos8
|
||||||
|
image: geerlingguy/docker-centos8-ansible:latest
|
||||||
|
- container: centos7
|
||||||
|
image: geerlingguy/docker-centos7-ansible:latest
|
||||||
|
- container: ubuntu2004
|
||||||
|
image: geerlingguy/docker-ubuntu2004-ansible:latest
|
||||||
|
- container: ubuntu1804
|
||||||
|
image: geerlingguy/docker-ubuntu1804-ansible:latest
|
||||||
|
- container: ubuntu1604
|
||||||
|
image: geerlingguy/docker-ubuntu1604-ansible:latest
|
||||||
|
- container: debian9
|
||||||
|
image: geerlingguy/docker-debian9-ansible:latest
|
||||||
|
- container: debian8
|
||||||
|
image: geerlingguy/docker-debian8-ansible:latest
|
||||||
|
- container: opensuse-leap
|
||||||
|
image: wdijkerman/molecule-systemd-leap:new
|
||||||
|
command: /sbin/init
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Set up Python 3.7
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.7
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r molecule/requirements.txt
|
||||||
|
|
||||||
|
- name: Run role tests
|
||||||
|
run: >-
|
||||||
|
MY_MOLECULE_CONTAINER=${{ matrix.molecule_distro.container }}
|
||||||
|
MY_MOLECULE_IMAGE=${{ matrix.molecule_distro.image }}
|
||||||
|
MY_MOLECULE_GROUP=${{ matrix.molecule_distro.group }}
|
||||||
|
MY_MOLECULE_DOCKER_COMMAND=${{ matrix.molecule_distro.command }}
|
||||||
|
molecule test
|
16
.travis.yml
16
.travis.yml
@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
sudo: required
|
|
||||||
language: python
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
install:
|
|
||||||
- curl -sSlo requirements.txt https://raw.githubusercontent.com/dj-wasabi/ansible-ci-base/master/requirements.txt
|
|
||||||
- pip install -r requirements.txt
|
|
||||||
|
|
||||||
script:
|
|
||||||
- molecule --version
|
|
||||||
- ansible --version
|
|
||||||
- molecule test
|
|
||||||
notifications:
|
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
|
@ -1,14 +0,0 @@
|
|||||||
# Molecule managed
|
|
||||||
|
|
||||||
{% if item.registry is defined %}
|
|
||||||
FROM {{ item.registry.url }}/{{ item.image }}
|
|
||||||
{% else %}
|
|
||||||
FROM {{ item.image }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
|
||||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
|
|
||||||
elif [ $(command -v yum) ]; then yum makecache fast && 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 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; \
|
|
||||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
|
|
@ -1,46 +0,0 @@
|
|||||||
*******
|
|
||||||
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
|
|
@ -1,84 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Create
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
gather_facts: false
|
|
||||||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
|
|
||||||
tasks:
|
|
||||||
- name: Log into a Docker registry
|
|
||||||
docker_login:
|
|
||||||
username: "{{ item.registry.credentials.username }}"
|
|
||||||
password: "{{ item.registry.credentials.password }}"
|
|
||||||
email: "{{ item.registry.credentials.email | default(omit) }}"
|
|
||||||
registry: "{{ item.registry.url }}"
|
|
||||||
docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
with_items: "{{ molecule_yml.platforms }}"
|
|
||||||
when:
|
|
||||||
- item.registry is defined
|
|
||||||
- item.registry.credentials is defined
|
|
||||||
- item.registry.credentials.username is defined
|
|
||||||
|
|
||||||
- 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 }}"
|
|
||||||
docker_host: "{{ item.item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
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 }}"
|
|
||||||
docker_host: "{{ item.item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
|
|
||||||
force: "{{ item.item.force | default(true) }}"
|
|
||||||
pull: "{{ item.item.pull | default(omit) }}"
|
|
||||||
with_items: "{{ platforms.results }}"
|
|
||||||
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
|
|
||||||
|
|
||||||
- name: Create docker network(s)
|
|
||||||
docker_network:
|
|
||||||
name: "{{ item }}"
|
|
||||||
docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
state: present
|
|
||||||
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"
|
|
||||||
|
|
||||||
- name: Create molecule instance(s)
|
|
||||||
docker_container:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
hostname: "{{ item.hostname | default(item.name) }}"
|
|
||||||
image: "molecule_local/{{ item.image }}"
|
|
||||||
state: started
|
|
||||||
recreate: false
|
|
||||||
log_driver: json-file
|
|
||||||
command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}"
|
|
||||||
privileged: "{{ item.privileged | default(omit) }}"
|
|
||||||
security_opts: "{{ item.security_opts | default(omit) }}"
|
|
||||||
volumes: "{{ item.volumes | default(omit) }}"
|
|
||||||
tmpfs: "{{ item.tmpfs | default(omit) }}"
|
|
||||||
capabilities: "{{ item.capabilities | default(omit) }}"
|
|
||||||
exposed_ports: "{{ item.exposed_ports | default(omit) }}"
|
|
||||||
published_ports: "{{ item.published_ports | default(omit) }}"
|
|
||||||
ulimits: "{{ item.ulimits | default(omit) }}"
|
|
||||||
networks: "{{ item.networks | default(omit) }}"
|
|
||||||
dns_servers: "{{ item.dns_servers | default(omit) }}"
|
|
||||||
register: server
|
|
||||||
with_items: "{{ molecule_yml.platforms }}"
|
|
||||||
async: 7200
|
|
||||||
poll: 0
|
|
||||||
|
|
||||||
- name: Wait for instance(s) creation to complete
|
|
||||||
async_status:
|
|
||||||
jid: "{{ item.ansible_job_id }}"
|
|
||||||
register: docker_jobs
|
|
||||||
until: docker_jobs.finished
|
|
||||||
retries: 300
|
|
||||||
with_items: "{{ server.results }}"
|
|
@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Destroy
|
|
||||||
hosts: localhost
|
|
||||||
connection: local
|
|
||||||
gather_facts: false
|
|
||||||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
|
|
||||||
tasks:
|
|
||||||
- name: Destroy molecule instance(s)
|
|
||||||
docker_container:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
state: absent
|
|
||||||
force_kill: "{{ item.force_kill | default(true) }}"
|
|
||||||
register: server
|
|
||||||
with_items: "{{ molecule_yml.platforms }}"
|
|
||||||
async: 7200
|
|
||||||
poll: 0
|
|
||||||
|
|
||||||
- name: Wait for instance(s) deletion to complete
|
|
||||||
async_status:
|
|
||||||
jid: "{{ item.ansible_job_id }}"
|
|
||||||
register: docker_jobs
|
|
||||||
until: docker_jobs.finished
|
|
||||||
retries: 300
|
|
||||||
with_items: "{{ server.results }}"
|
|
||||||
|
|
||||||
- name: Delete docker network(s)
|
|
||||||
docker_network:
|
|
||||||
name: "{{ item }}"
|
|
||||||
docker_host: "{{ item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
|
|
||||||
state: absent
|
|
||||||
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"
|
|
@ -3,10 +3,6 @@ dependency:
|
|||||||
name: galaxy
|
name: galaxy
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
lint:
|
|
||||||
name: yamllint
|
|
||||||
options:
|
|
||||||
config-file: molecule/default/yaml-lint.yml
|
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: influxdb
|
- name: influxdb
|
||||||
@ -18,41 +14,17 @@ platforms:
|
|||||||
- name: telegraf
|
- name: telegraf
|
||||||
environment:
|
environment:
|
||||||
INFLUXDB_DB: telegraf
|
INFLUXDB_DB: telegraf
|
||||||
- name: telegraf-centos
|
- name: telegraf-${MY_MOLECULE_CONTAINER:-centos8}
|
||||||
image: milcom/centos7-systemd
|
image: ${MY_MOLECULE_IMAGE:-"geerlingguy/docker-centos8-ansible"}
|
||||||
|
command: ${MY_MOLECULE_DOCKER_COMMAND:-""}
|
||||||
privileged: True
|
privileged: True
|
||||||
groups:
|
pre_build_image: True
|
||||||
- telegraf
|
|
||||||
networks:
|
networks:
|
||||||
- name: telegraf
|
- name: telegraf
|
||||||
- name: telegraf-debian
|
|
||||||
image: minimum2scp/systemd-stretch
|
|
||||||
privileged: True
|
|
||||||
command: /sbin/init
|
|
||||||
groups:
|
|
||||||
- telegraf
|
|
||||||
- debian
|
|
||||||
networks:
|
|
||||||
- name: telegraf
|
|
||||||
- name: telegraf-ubuntu
|
|
||||||
image: solita/ubuntu-systemd:bionic
|
|
||||||
privileged: True
|
|
||||||
command: /sbin/init
|
|
||||||
groups:
|
|
||||||
- telegraf
|
|
||||||
- debian
|
|
||||||
networks:
|
|
||||||
- name: telegraf
|
|
||||||
- name: telegraf-opensuse
|
|
||||||
image: wdijkerman/molecule-systemd-leap
|
|
||||||
privileged: True
|
|
||||||
command: /sbin/init
|
|
||||||
volumes:
|
volumes:
|
||||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
groups:
|
groups:
|
||||||
- telegraf
|
- telegraf
|
||||||
networks:
|
|
||||||
- name: telegraf
|
|
||||||
|
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
|
@ -9,11 +9,22 @@
|
|||||||
when:
|
when:
|
||||||
- ansible_os_family == 'RedHat'
|
- ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
|
- name: "Apt get update"
|
||||||
|
shell: apt-get update && apt-get install -y python-apt
|
||||||
|
when:
|
||||||
|
- ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
- name: debug
|
||||||
|
debug:
|
||||||
|
var: ansible_distribution_major_version
|
||||||
|
|
||||||
- name: "Installing packages on Debian"
|
- name: "Installing packages on Debian"
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
- wget
|
- wget
|
||||||
# - gpg
|
- python-apt
|
||||||
|
- "{{ 'gnupg-agent' if ansible_distribution_major_version in ['8', '18', '16'] else 'gpg-agent' }}"
|
||||||
|
update_cache: True
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == 'Debian'
|
- ansible_os_family == 'Debian'
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
extends: default
|
|
||||||
|
|
||||||
rules:
|
|
||||||
line-length:
|
|
||||||
max: 180
|
|
||||||
level: warning
|
|
||||||
truthy: disable
|
|
10
molecule/requirements.txt
Normal file
10
molecule/requirements.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Install CI dependencies for the Zabbix Roles
|
||||||
|
ansible==2.9.11
|
||||||
|
ansible-lint==4.2.0
|
||||||
|
docker==4.2.1
|
||||||
|
molecule==3.0.4
|
||||||
|
netaddr==0.7.19
|
||||||
|
testinfra==5.2.1
|
||||||
|
zabbix-api==0.5.4
|
||||||
|
ipaddr==2.2.0
|
||||||
|
ipaddress==1.0.23
|
Reference in New Issue
Block a user