Skip to content

Commit bf757ab

Browse files
authored
Merge pull request #143 from opentelekomcloud-infra/devel
Add graphite webapp
2 parents 86f9820 + 84a74d3 commit bf757ab

File tree

15 files changed

+223
-18
lines changed

15 files changed

+223
-18
lines changed

inventory/service/groups.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ groups:
8484
- graphite3.apimon.eco.tsi-dev.otc-service.com
8585
- graphite1.eco.tsi-dev.otc-service.com
8686

87+
graphite-web:
88+
- web3.eco.tsi-dev.otc-service.com
89+
8790
memcached:
8891
- graphite1.apimon.eco.tsi-dev.otc-service.com
8992
- graphite2.apimon.eco.tsi-dev.otc-service.com

inventory/service/host_vars/web3.eco.tsi-dev.otc-service.com.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
alerta_instance: production_vc
2-
grafana_instance: production_vc
1+
alerta_instance: "production_vc"
2+
grafana_instance: "production_vc"
33
ssl_certs:
44
web3:
55
- "web3.eco.tsi-dev.otc-service.com"
@@ -13,5 +13,8 @@ ssl_certs:
1313
graphite:
1414
- "graphite.eco.tsi-dev.otc-service.com"
1515

16+
graphite_instance_group: "graphite-apimon"
17+
graphite_cert: "graphite"
18+
1619
firewalld_extra_services_enable: ['http', 'https']
1720
firewalld_extra_ports_enable: ['3000/tcp', '8080/tcp', '8081/tcp']

playbooks/roles/graphite/templates/docker-compose.yaml.j2

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run Graphite
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphite_config_location: "/etc/graphite"
2+
3+
# graphite_cluster_servers: "127.0.0.1:8080"
4+
5+
graphite_image: "quay.io/opentelekomcloud/graphite-statsd:1.1.7-9"
6+
7+
container_command: "podman"
8+
container_runtime: "/usr/bin/{{ container_command }}"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: Restart graphite-web
2+
ansible.builtin.systemd:
3+
name: "graphite-web"
4+
enabled: true
5+
state: "restarted"
6+
daemon_reload: true
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
- name: Include variables
3+
include_vars: "{{ lookup('first_found', params) }}"
4+
vars:
5+
params:
6+
files: "{{ distro_lookup_path }}"
7+
paths:
8+
- "vars"
9+
10+
- name: Install required packages
11+
become: true
12+
ansible.builtin.package:
13+
state: present
14+
name: "{{ item }}"
15+
loop:
16+
- "{{ packages }}"
17+
when: "ansible_facts.pkg_mgr != 'atomic_container'"
18+
register: task_result
19+
until: task_result is success
20+
retries: 5
21+
22+
- name: Ensure directories exist
23+
become: true
24+
ansible.builtin.file:
25+
state: "directory"
26+
path: "{{ item }}"
27+
mode: "0755"
28+
loop:
29+
- "{{ graphite_config_location }}"
30+
- "/var/log/graphite"
31+
32+
- name: Write config files
33+
become: true
34+
ansible.builtin.template:
35+
src: "{{ item }}.j2"
36+
dest: "{{ graphite_config_location }}//{{ item }}"
37+
mode: "0644"
38+
loop:
39+
- "graphite-statsd.conf"
40+
- "env"
41+
notify:
42+
- Restart graphite-web
43+
44+
- name: Write systemd unit file
45+
become: true
46+
ansible.builtin.template:
47+
src: "graphite-web.service.j2"
48+
dest: "/etc/systemd/system/graphite-web.service"
49+
notify:
50+
- Restart graphite-web
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% if graphite_cluster_servers is defined and graphite_cluster_servers|length %}
2+
GRAPHITE_CLUSTER_SERVERS={{ graphite_cluster_servers }}
3+
{% endif %}
4+
{% if graphite_memcached_host is defined %}
5+
MEMCACHE_HOST={{ graphite_memcached_host }}
6+
{% endif %}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
server {
2+
listen 80 default_server;
3+
listen [::]:80 default_server;
4+
server_name _;
5+
6+
return 301 https://$host$request_uri;
7+
}
8+
9+
server {
10+
listen 443 ssl;
11+
listen [::]:443 ssl;
12+
server_name {{ inventory_hostname }};
13+
14+
ssl_certificate /etc/ssl/{{ inventory_hostname }}/{{ graphite_cert }}.crt;
15+
ssl_certificate_key /etc/ssl/{{ inventory_hostname }}/{{ graphite_cert }}.pem;
16+
root /opt/graphite/static;
17+
index index.html;
18+
19+
location /nginx_status {
20+
stub_status on;
21+
access_log off;
22+
allow 127.0.0.1;
23+
deny all;
24+
}
25+
26+
# No remote login
27+
location /admin {
28+
allow 127.0.0.1;
29+
deny all;
30+
}
31+
32+
location /account {
33+
allow 127.0.0.1;
34+
deny all;
35+
}
36+
37+
location /media {
38+
# django admin static files
39+
alias /usr/local/lib/python3.6/dist-packages/django/contrib/admin/media/;
40+
}
41+
42+
location /admin/auth/admin {
43+
alias /usr/local/lib/python3.6/dist-packages/django/contrib/admin/static/admin;
44+
}
45+
46+
location /admin/auth/user/admin {
47+
alias /usr/local/lib/python3.6/dist-packages/django/contrib/admin/static/admin;
48+
}
49+
50+
location / {
51+
proxy_pass http://127.0.0.1:8080;
52+
proxy_set_header Host $http_host;
53+
proxy_set_header X-Real-IP $remote_addr;
54+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55+
56+
add_header 'Access-Control-Allow-Origin' '*';
57+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
58+
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type';
59+
add_header 'Access-Control-Allow-Credentials' 'true';
60+
}
61+
62+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[Unit]
2+
Description=Graphite Web Service
3+
After=syslog.target network.target
4+
5+
[Service]
6+
Restart=always
7+
ExecStartPre=-{{ container_runtime }} kill graphite_web
8+
ExecStartPre=-{{ container_runtime }} rm graphite_web
9+
10+
ExecStart={{ container_runtime }} run \
11+
--name graphite_web \
12+
--port 8081:80 \
13+
--env-file /etc/graphite/env \
14+
{% if container_command == 'podman' %}
15+
--log-opt=path=/dev/null \
16+
{% endif %}
17+
-v /etc/ssl/{{ inventory_hostname }}/{{ graphite_cert }}.pem:/etc/ssl/{{
18+
inventory_hostname }}/{{ graphite_cert }}.pem:ro,z \
19+
-v /etc/ssl/{{ inventory_hostname }}/{{ graphite_cert }}.crt:/etc/ssl/{{
20+
inventory_hostname }}/{{ graphite_cert }}.crt:ro,z \
21+
-v /etc/graphite/graphite-statsd.conf:/etc/nginx/sites-enabled/graphite-statsd.conf:ro \
22+
-v /var/log/graphite:/var/log:rw,z \
23+
--tmpfs /tmp:rw,size=2g \
24+
{{ graphite_image }}
25+
26+
[Install]
27+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)