Netdata as playbook
This commit is contained in:
parent
c5c15341b8
commit
e68920c0e2
@ -6,12 +6,44 @@
|
|||||||
- vars/ports.yml
|
- vars/ports.yml
|
||||||
- vars/vars.yml
|
- vars/vars.yml
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: "Install Netdata from role"
|
|
||||||
ansible.builtin.import_role:
|
|
||||||
name: netdata
|
|
||||||
vars:
|
vars:
|
||||||
netdata_version: "v2.4.0"
|
netdata_version: 'v2.4.0'
|
||||||
netdata_exposed_port: "{{ netdata_port }}"
|
netdata_image: 'netdata/netdata:{{ netdata_version }}'
|
||||||
tags:
|
netdata_exposed_port: '{{ netdata_port }}'
|
||||||
- monitoring
|
|
||||||
|
tasks:
|
||||||
|
- name: 'Grab docker group id.'
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: |
|
||||||
|
set -o pipefail
|
||||||
|
grep docker /etc/group | cut -d ':' -f 3
|
||||||
|
executable: /bin/bash
|
||||||
|
register: netdata_docker_group_output
|
||||||
|
changed_when: netdata_docker_group_output.rc != 0
|
||||||
|
|
||||||
|
- name: 'Create NetData container from {{ netdata_image }}'
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: netdata
|
||||||
|
image: '{{ netdata_image }}'
|
||||||
|
image_name_mismatch: 'recreate'
|
||||||
|
restart_policy: 'unless-stopped'
|
||||||
|
published_ports:
|
||||||
|
- '127.0.0.1:{{ netdata_exposed_port }}:19999'
|
||||||
|
volumes:
|
||||||
|
- '/:/host/root:ro,rslave'
|
||||||
|
- '/etc/group:/host/etc/group:ro'
|
||||||
|
- '/etc/localtime:/etc/localtime:ro'
|
||||||
|
- '/etc/os-release:/host/etc/os-release:ro'
|
||||||
|
- '/etc/passwd:/host/etc/passwd:ro'
|
||||||
|
- '/proc:/host/proc:ro'
|
||||||
|
- '/run/dbus:/run/dbus:ro'
|
||||||
|
- '/sys:/host/sys:ro'
|
||||||
|
- '/var/log:/host/var/log:ro'
|
||||||
|
- '/var/run/docker.sock:/var/run/docker.sock:ro'
|
||||||
|
capabilities:
|
||||||
|
- 'SYS_PTRACE'
|
||||||
|
- 'SYS_ADMIN'
|
||||||
|
security_opts:
|
||||||
|
- 'apparmor:unconfined'
|
||||||
|
env:
|
||||||
|
PGID: '{{ netdata_docker_group_output.stdout | default(999) }}'
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
netdata_version: 'v2.0.0'
|
|
||||||
netdata_image: 'netdata/netdata:{{ netdata_version }}'
|
|
||||||
netdata_exposed_port: '19999'
|
|
@ -1,36 +0,0 @@
|
|||||||
---
|
|
||||||
- name: 'Grab docker group id.'
|
|
||||||
ansible.builtin.shell:
|
|
||||||
cmd: |
|
|
||||||
set -o pipefail
|
|
||||||
grep docker /etc/group | cut -d ':' -f 3
|
|
||||||
executable: /bin/bash
|
|
||||||
register: netdata_docker_group_output
|
|
||||||
changed_when: netdata_docker_group_output.rc != 0
|
|
||||||
|
|
||||||
- name: 'Create NetData container from {{ netdata_image }}'
|
|
||||||
community.docker.docker_container:
|
|
||||||
name: netdata
|
|
||||||
image: '{{ netdata_image }}'
|
|
||||||
image_name_mismatch: 'recreate'
|
|
||||||
restart_policy: 'always'
|
|
||||||
published_ports:
|
|
||||||
- '127.0.0.1:{{ netdata_exposed_port }}:19999'
|
|
||||||
volumes:
|
|
||||||
- '/:/host/root:ro,rslave'
|
|
||||||
- '/etc/group:/host/etc/group:ro'
|
|
||||||
- '/etc/localtime:/etc/localtime:ro'
|
|
||||||
- '/etc/os-release:/host/etc/os-release:ro'
|
|
||||||
- '/etc/passwd:/host/etc/passwd:ro'
|
|
||||||
- '/proc:/host/proc:ro'
|
|
||||||
- '/run/dbus:/run/dbus:ro'
|
|
||||||
- '/sys:/host/sys:ro'
|
|
||||||
- '/var/log:/host/var/log:ro'
|
|
||||||
- '/var/run/docker.sock:/var/run/docker.sock:ro'
|
|
||||||
capabilities:
|
|
||||||
- 'SYS_PTRACE'
|
|
||||||
- 'SYS_ADMIN'
|
|
||||||
security_opts:
|
|
||||||
- 'apparmor:unconfined'
|
|
||||||
env:
|
|
||||||
PGID: '{{ netdata_docker_group_output.stdout | default(999) }}'
|
|
@ -27,8 +27,7 @@
|
|||||||
|
|
||||||
- name: "Prepare env variables."
|
- name: "Prepare env variables."
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
env_dict: '{{ owner_env | combine({ "CURRENT_UID": user_create_result.uid | default(owner_name), "CURRENT_GID": user_create_result.group | default(owner_group)
|
env_dict: '{{ owner_env | combine({"CURRENT_UID": user_create_result.uid | default(owner_name), "CURRENT_GID": user_create_result.group | default(owner_group)}) }}'
|
||||||
}) }}'
|
|
||||||
|
|
||||||
- name: 'Set up environment variables for user "{{ owner_name }}".'
|
- name: 'Set up environment variables for user "{{ owner_name }}".'
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user