Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrothstein committed Dec 27, 2020
0 parents commit 6c45883
Show file tree
Hide file tree
Showing 15 changed files with 282 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**~
*.retry
.ansible-roles/
Dockerfile.*
requirements.yml
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
before_install: "if [[ \"$TRAVIS_OS_NAME\" == \"osx\" ]]\nthen\n brew upgrade openssl\
\ || brew install openssl || true\n brew upgrade python@3 || brew install python@3\
\ || true\n brew upgrade md5sha1sum || brew install md5sha1sum || true\n virtualenv\
\ venv -p python\n source venv/bin/activate\n pip install ansible\nfi"
branches:
except:
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
dist: xenial
env:
- OS=alpine_3.11
- OS=alpine_3.12
- OS=alpine_edge
- OS=archlinux_latest
- OS=centos_7
- OS=centos_8
- OS=debian_buster
- OS=debian_stretch
- OS=fedora_31
- OS=fedora_32
- OS=ubi8_8.1
- OS=ubi8_8.2
- OS=ubuntu_bionic
- OS=ubuntu_focal
- OS=ubuntu_xenial
language: python
python: 3.9
script:
- ansible-galaxy-local-deps-write
- dcb --upstreamgroup andrewrothstein --upstreamapp docker-ansible-role --pull ${OS}
--write ${OS} --build ${OS} --push ${OS}
services:
- docker
sudo: required
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Andrew Rothstein

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
andrewrothstein.influxdb2
=========
[![Build Status](https://travis-ci.org/andrewrothstein/ansible-influxdb2.svg?branch=master)](https://travis-ci.org/andrewrothstein/ansible-influxdb2)

Installs InfluxDB2

Requirements
------------

See [meta/main.yml](meta/main.yml)

Role Variables
--------------

See [defaults/main.yml](defaults/main.yml)

Dependencies
------------

See [meta/main.yml](meta/main.yml)

Example Playbook
----------------

```yml
- hosts: servers
roles:
- andrewrothstein.influxdb2
```
License
-------
MIT
Author Information
------------------
Andrew Rothstein <[email protected]>
15 changes: 15 additions & 0 deletions dcb-os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- alpine_3.11
- alpine_3.12
- alpine_edge
- archlinux_latest
- centos_7
- centos_8
- debian_buster
- debian_stretch
- fedora_31
- fedora_32
- ubi8_8.1
- ubi8_8.2
- ubuntu_bionic
- ubuntu_focal
- ubuntu_xenial
15 changes: 15 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
influxdb2_ver: 2.0.3
influxdb2_os: linux
influxdb2_arch: amd64
influxdb2_mirror: https://dl.influxdata.com/influxdb/releases
influxdb2_parent_install_dir: /usr/local
# defaults file for influxdb2
influxdb2_checksums:
'2.0.3':
# https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.3_darwin_amd64.tar.gz
darwin_amd64: sha256:bfb3f62206daf05b72994b1e5b8897022c10a90aa405fb5993b58119de71e92e
# https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.3_linux_amd64.tar.gz
linux_amd64: sha256:d01f0b6d634406e0be1829f884ebf93423cc0c920743fa293a03b1533ffac4af
# https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.3_linux_arm64.tar.gz
linux_arm64: sha256:0c67b0282cefc9b1052633008f5713d24f6d18f669d8f92abb2004e2541947b4
33 changes: 33 additions & 0 deletions dl-checksum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env sh
set -e
DIR=~/Downloads
MIRROR=https://dl.influxdata.com/influxdb/releases

dl() {
local ver=$1
local os=$2
local arch=$3
local archive_type=${4:-tar.gz}
local platform="${os}_${arch}"
local file="influxdb2-${ver}_${platform}.${archive_type}"
# https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.3_linux_amd64.tar.gz
local url=$MIRROR/$file
local lfile=$DIR/$file

if [ ! -e $lfile ];
then
wget -q -O $lfile $url
fi
printf " # %s\n" $url
printf " %s: sha256:%s\n" $platform $(sha256sum $lfile | awk '{print $1}')
}

dl_ver() {
local ver=$1
printf " '%s':\n" $ver
dl $ver darwin amd64
dl $ver linux amd64
dl $ver linux arm64
}

dl_ver ${1:-2.0.3}
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for influxdb2
39 changes: 39 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
galaxy_info:
author: Andrew Rothstein
description: installs influxdb2
company: BlackRock Financial Management
license:
- MIT
min_ansible_version: 2.0
platforms:
- name: Alpine
versions:
- all
- name: Archlinux
versions:
- all
- name: Debian
versions:
- buster
- stretch
- name: EL
versions:
- 7
- 8
- name: Fedora
versions:
- 31
- 32
- name: Ubuntu
versions:
- bionic
- focal
- xenial
galaxy_tags:
- development
role_name: influxdb2

dependencies:
- role: andrewrothstein.unarchive-deps
version: v1.1.5
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ansible-galaxy-local-deps == 0.0.14
dcb == 0.0.17
52 changes: 52 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
- name: resolve platform specific vars
include_vars: '{{ item }}'
with_first_found:
- files:
- '{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
skip: true
paths:
- '{{ role_path }}/vars'
- name: check for install at {{ influxdb2_install_dir }}
become: yes
become_user: root
stat:
path: '{{ influxdb2_install_dir }}'
changed_when: False
register: influxdb2_binary
- when: not influxdb2_binary.stat.exists
block:
- name: downloading {{ influxdb2_url }} to {{ influxdb2_tmp_tgz }}
become: yes
become_user: root
get_url:
url: '{{ influxdb2_url }}'
dest: '{{ influxdb2_tmp_tgz }}'
checksum: '{{ influxdb2_checksum }}'
- name: unarchive {{ influxdb2_tmp_tgz }} to {{ influxdb2_parent_install_dir }}
become: yes
become_user: root
unarchive:
remote_src: yes
src: '{{ influxdb2_tmp_tgz }}'
dest: '{{ influxdb2_parent_install_dir }}'
creates: '{{ influxdb2_install_dir }}'
always:
- name: rm {{ influxdb2_tmp_tgz }}
become: yes
become_user: root
file:
path: '{{ influxdb2_tmp_tgz }}'
state: absent
- name: link applications in {{ influxdb2_install_dir }} to {{ influxdb2_parent_install_dir }}/bin
become: yes
become_user: root
with_items:
- influx
- influxd
file:
src: '{{ influxdb2_install_dir }}/{{ item }}'
dest: '{{ influxdb2_parent_install_dir }}/bin/{{ item }}'
state: link
10 changes: 10 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- hosts: all
roles:
- role: '{{ playbook_dir }}'
tasks:
- command: /usr/local/bin/influx version
register: influxdb2_test_output
- name: influx version
debug:
msg: '{{ influxdb2_test_output.stdout }}'
2 changes: 2 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
localhost

5 changes: 5 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- influxdb2
9 changes: 9 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# vars file for influxdb2
influxdb2_platform: '{{ influxdb2_os }}_{{ influxdb2_arch }}'
influxdb2_name: influxdb2-{{ influxdb2_ver }}_{{ influxdb2_platform }}
influxdb2_tgz: '{{ influxdb2_name }}.tar.gz'
influxdb2_tmp_tgz: /tmp/{{ influxdb2_tgz }}
influxdb2_url: '{{ influxdb2_mirror }}/{{ influxdb2_tgz }}'
influxdb2_checksum: '{{ influxdb2_checksums[influxdb2_ver][influxdb2_platform] }}'
influxdb2_install_dir: '{{ influxdb2_parent_install_dir }}/{{ influxdb2_name }}'

0 comments on commit 6c45883

Please sign in to comment.