diff options
Diffstat (limited to 'roles/services/containers/cadvisor/tasks')
-rw-r--r-- | roles/services/containers/cadvisor/tasks/main.yml | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/roles/services/containers/cadvisor/tasks/main.yml b/roles/services/containers/cadvisor/tasks/main.yml new file mode 100644 index 0000000..cc30cdb --- /dev/null +++ b/roles/services/containers/cadvisor/tasks/main.yml | |||
@@ -0,0 +1,90 @@ | |||
1 | - name: create cadvisor directory | ||
2 | file: | ||
3 | path: "{{ docker_home }}/cadvisor" | ||
4 | state: directory | ||
5 | owner: "{{ docker_username }}" | ||
6 | group: "{{ docker_username }}" | ||
7 | mode: '0755' | ||
8 | |||
9 | - name: login to docker registry | ||
10 | become: yes | ||
11 | become_user: "{{ docker_username }}" | ||
12 | environment: | ||
13 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
14 | docker_login: | ||
15 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
16 | registry_url: "{{ docker_registry_url }}" | ||
17 | username: "{{ docker_registry_username }}" | ||
18 | password: "{{ docker_registry_password }}" | ||
19 | |||
20 | - name: build cadvisor image | ||
21 | become: yes | ||
22 | become_user: "{{ docker_username }}" | ||
23 | environment: | ||
24 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
25 | docker_image: | ||
26 | name: "{{ docker_registry_url }}/{{ docker_registry_username }}/cadvisor:latest" | ||
27 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
28 | build: | ||
29 | path: /srv/docker/cadvisor/src | ||
30 | dockerfile: deploy/Dockerfile | ||
31 | source: build | ||
32 | push: yes | ||
33 | |||
34 | - name: create cadvisor docker network | ||
35 | become: yes | ||
36 | become_user: "{{ docker_username }}" | ||
37 | environment: | ||
38 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
39 | docker_network: | ||
40 | name: "{{ cadvisor_network_name }}" | ||
41 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
42 | driver: bridge | ||
43 | ipam_config: | ||
44 | - subnet: "{{ cadvisor_subnet }}" | ||
45 | gateway: "{{ cadvisor_gateway }}" | ||
46 | |||
47 | - name: create and deploy cadvisor container | ||
48 | become: yes | ||
49 | become_user: "{{ docker_username }}" | ||
50 | environment: | ||
51 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
52 | docker_container: | ||
53 | name: "cadvisor" | ||
54 | hostname: "cadvisor" | ||
55 | image: "{{ docker_registry_url }}/{{ docker_registry_username }}/cadvisor:latest" | ||
56 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
57 | purge_networks: yes | ||
58 | networks: | ||
59 | - name: "{{ cadvisor_network_name }}" | ||
60 | ipv4_address: "{{ cadvisor_ipv4 }}" | ||
61 | ports: | ||
62 | - "127.0.0.1:{{ cadvisor_external_port }}:8080" | ||
63 | state: 'started' | ||
64 | comparisons: | ||
65 | '*': strict | ||
66 | restart_policy: unless-stopped | ||
67 | volumes: | ||
68 | - "/:/rootfs:ro" | ||
69 | - "/run/user/{{ docker_uid }}:/var/run:ro" | ||
70 | - "/sys:/sys:ro" | ||
71 | - "/{{ docker_home }}/.local/share/docker:/var/lib/docker:ro" | ||
72 | - "/dev/disk:/dev/disk:ro" | ||
73 | |||
74 | - name: deploy nginx configuration | ||
75 | notify: restart nginx | ||
76 | register: nginx_config | ||
77 | copy: | ||
78 | src: "{{ cadvisor_nginx_config }}" | ||
79 | dest: /etc/nginx/sites-available/cadvisor.conf | ||
80 | owner: root | ||
81 | group: root | ||
82 | mode: '0644' | ||
83 | |||
84 | - name: symlink site | ||
85 | file: | ||
86 | src: /etc/nginx/sites-available/cadvisor.conf | ||
87 | dest: /etc/nginx/sites-enabled/cadvisor.conf | ||
88 | owner: root | ||
89 | group: root | ||
90 | state: link | ||