feat(cadvisor): add ansible role for deployment using docker containers
This commit is contained in:
parent
fc65595bce
commit
d836d33d82
53
roles/cadvisor/defaults/main.yml
Normal file
53
roles/cadvisor/defaults/main.yml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
|
||||
cadvisor_version: 0.39.3
|
||||
|
||||
cadvisor_container_name: cadvisor
|
||||
cadvisor_container_image_name: gcr.io/cadvisor/cadvisor
|
||||
cadvisor_container_image_tag: ~
|
||||
cadvisor_container_image_ref: >-
|
||||
{{ cadvisor_container_image_name }}:{{ cadvisor_container_image_tag | default('v' + cadvisor_version, True) }}
|
||||
cadvisor_container_volumes: >-
|
||||
{{ cadvisor_container_base_volumes + cadvisor_container_extra_volumes | default([], True) }}
|
||||
cadvisor_container_extra_volumes: ~
|
||||
cadvisor_container_env: ~
|
||||
cadvisor_container_labels: "{{ cadvisor_container_base_labels | combine(cadvisor_container_extra_labels) }}"
|
||||
cadvisor_container_extra_labels: {}
|
||||
cadvisor_container_ports: ~
|
||||
cadvisor_container_networks: ~
|
||||
cadvisor_container_etc_hosts: ~
|
||||
cadvisor_container_devices: [ "/dev/kmsg:/dev/kmsg:rwm" ]
|
||||
cadvisor_container_privileged: yes
|
||||
cadvisor_container_pid_mode: "host"
|
||||
cadvisor_container_userns_mode: "host"
|
||||
cadvisor_container_capabilities: ~
|
||||
cadvisor_container_restart_policy: unless-stopped
|
||||
cadvisor_container_command: >-2
|
||||
{{ ["--docker_only=false"]
|
||||
+ (["--disable_metrics=" + cadvisor_disabled_metrics | join( ',' )]
|
||||
if cadvisor_disabled_metrics | default(false, True) else [])
|
||||
+ (["--enable_metrics=" + cadvisor_force_enable_metrics | join( ',' )]
|
||||
if cadvisor_force_enable_metrics | default(false, True) else [])
|
||||
}}
|
||||
cadvisor_container_base_labels:
|
||||
version: "{{ cadvisor_version }}"
|
||||
cadvisor_container_base_volumes:
|
||||
- "/:/rootfs:ro"
|
||||
- "/var/run:/var/run:ro"
|
||||
- "/sys:/sys:ro"
|
||||
- "/var/lib/docker/:/var/lib/docker:ro"
|
||||
- "/dev/disk/:/dev/disk:ro"
|
||||
|
||||
cadvisor_disabled_metrics:
|
||||
- advtcp
|
||||
- cpu_topology
|
||||
- cpuset
|
||||
- hugetlb
|
||||
- memory_numa
|
||||
- process
|
||||
- referenced_memory
|
||||
- resctrl
|
||||
- sched
|
||||
- tcp
|
||||
- udp
|
||||
cadvisor_force_enable_metrics: []
|
26
roles/cadvisor/tasks/main.yml
Normal file
26
roles/cadvisor/tasks/main.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
|
||||
- name: Ensure container image is present
|
||||
docker_image:
|
||||
name: "{{ cadvisor_container_image_ref }}"
|
||||
state: present
|
||||
source: pull
|
||||
force_source: "{{ cadvisor_container_image_tag|default(False, True) | bool }}"
|
||||
|
||||
- name: Ensure cadvisor container is running
|
||||
docker_container:
|
||||
name: "{{ cadvisor_container_name }}"
|
||||
image: "{{ cadvisor_container_image_ref }}"
|
||||
env: "{{ cadvisor_container_env | default(omit, True) }}"
|
||||
ports: "{{ cadvisor_container_ports | default(omit, True) }}"
|
||||
labels: "{{ cadvisor_container_labels }}"
|
||||
devices: "{{ cadvisor_container_devices }}"
|
||||
volumes: "{{ cadvisor_container_volumes }}"
|
||||
networks: "{{ cadvisor_container_networks | default(omit, True) }}"
|
||||
etc_hosts: "{{ cadvisor_container_etc_hosts | default(omit, True) }}"
|
||||
privileged: "{{ cadvisor_container_privileged }}"
|
||||
command: "{{ cadvisor_container_command }}"
|
||||
pid_mode: "{{ cadvisor_container_pid_mode | default(omit, True) }}"
|
||||
userns_mode: "{{ cadvisor_container_userns_mode | default(omit, True) }}"
|
||||
restart_policy: "{{ cadvisor_container_restart_policy }}"
|
||||
state: started
|
0
roles/cadvisor/vars/main.yml
Normal file
0
roles/cadvisor/vars/main.yml
Normal file
Loading…
Reference in New Issue
Block a user