From f27e381a6cc01a34efecb89d314d1758c8476679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 10 May 2019 16:36:17 +0200 Subject: [PATCH] add initial tasks and defaults MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 18 ++++++++++++++++++ tasks/consul.yml | 17 +++++++++++++++++ tasks/container.yml | 18 ++++++++++++++++++ tasks/main.yml | 3 +++ 4 files changed, 56 insertions(+) create mode 100644 defaults/main.yml create mode 100644 tasks/consul.yml create mode 100644 tasks/container.yml create mode 100644 tasks/main.yml diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..56ee874 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,18 @@ +--- +geth_expo_cont_image: statusteam/geth_exporter:latest +geth_expo_cont_name: geth-exporter +geth_expo_cont_addr: '0.0.0.0' +geth_expo_cont_port: 9200 + +# consul catalog data +geth_expo_consul_name: 'geth-exporter' +geth_expo_consul_addr: '{{ ansible_local.tinc.vpn_ip }}' +geth_expo_consul_extra_tag: '{{ geth_expo_cont_name }}' +geth_expo_consul_tags: + - '{{ geth_expo_consul_extra_tag }}' + - metrics + - geth + +cont_state: started +cont_recreate: false +cont_restart: false diff --git a/tasks/consul.yml b/tasks/consul.yml new file mode 100644 index 0000000..7ac7d6f --- /dev/null +++ b/tasks/consul.yml @@ -0,0 +1,17 @@ +--- +- name: Create Consul service definition + include_role: name=consul-service + vars: + consul_config_name: '{{ geth_expo_cont_name | replace("-", "_") }}' + consul_services: + - name: '{{ geth_expo_consul_name }}' + port: '{{ geth_expo_cont_port }}' + address: '{{ geth_expo_consul_addr }}' + tags: '{{ geth_expo_consul_tags }}' + meta: + container: '{{ geth_expo_cont_name }}' + checks: + - id: '{{ geth_expo_consul_name }}'-health + name: 'geth-exporter healthcheck' + type: http + http: 'http://localhost:{{ geth_expo_cont_port }}/health' diff --git a/tasks/container.yml b/tasks/container.yml new file mode 100644 index 0000000..d741b7f --- /dev/null +++ b/tasks/container.yml @@ -0,0 +1,18 @@ +--- +- name: 'Start container: {{ geth_expo_cont_name }}' + docker_container: + name: '{{ geth_expo_cont_name }}' + image: '{{ geth_expo_cont_image }}' + user: root + pull: true + restart_policy: always + state: '{{ cont_state }}' + recreate: '{{ cont_recreate }}' + restart: '{{ cont_restart }}' + entrypoint: geth_exporter + volumes_from: '{{ cont_name }}' + command: | + -ipc /data/geth.ipc + -port 9200 + ports: + - '{{ geth_expo_cont_port }}:9200/tcp' diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..272da75 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: container.yml +- import_tasks: consul.yml