Skip to content

Commit 1aaa832

Browse files
committed
Initial version
0 parents  commit 1aaa832

File tree

12 files changed

+299
-0
lines changed

12 files changed

+299
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Graphite
2+
=================
3+
4+
graphite automation
5+
6+
7+
generating graphite-web rpm:
8+
9+
```
10+
# yum install ruby-devel gcc make rpm-build rubygems
11+
# gem install --no-ri --no-rdoc fpm
12+
13+
# yum install gcc python-dev libffi-devel
14+
# virtualenv /opt/graphite
15+
# . /opt/graphite/bin/activate
16+
# pip install Django cairocffi cffi django-tagging pycparser pyparsing pytz scandir six urllib3
17+
# pip install --install-option="--prefix=/opt/graphite" --install-option="--install-lib=/opt/graphite/webapp" graphite-web
18+
19+
# /usr/local/bin/fpm -s dir -s dir -t rpm -n graphite-web -v 1.1.4 /opt/graphite
20+
21+
```
22+
23+
24+
Role Variables
25+
--------------
26+
27+
28+
29+
Example Playbook
30+
----------------
31+
32+
33+
License
34+
-------
35+
36+
MIT
37+
38+
Author Information
39+
------------------
40+
41+
Alexandre Biancalana (@biancalana)

defaults/main.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
#
3+
#graphite_debug: false
4+
graphite_user: "graphite"
5+
graphite_path: "/opt/graphite"
6+
graphite_log_dir: "{{ graphite_path }}/log"
7+
graphite_storage_dir: "{{ graphite_path }}/storage"
8+
graphite_use_nginx: False
9+
10+
graphite_disable_access_log: True
11+
graphite_error_logfile: "{{ graphite_log_dir }}/error.log"
12+
graphite_log_rotation: True
13+
graphite_log_rotation_count: 5
14+
graphite_log_rendering_performance: False
15+
graphite_log_cahe_performance: False
16+
17+
graphite_time_zone: "GMT"
18+
19+
graphite_storage_finders: "()"
20+
21+
graphite_use_fetch_worker_pool: True
22+
graphite_max_fetch_workers: 10
23+
24+
graphite_listen_tcp: http://127.0.0.1:8080
25+
graphite_listen_unix: False
26+
graphite_max_connections: 128
27+
graphite_max_connections_per_child: 512
28+
graphite_web_workers: 2
29+
30+
graphite_intracluster_https: False
31+
graphite_remote_exclude_local: False
32+
graphite_remote_find_timeout: "30.0"
33+
graphite_remote_fetch_timeout: "60.0"
34+
graphite_remote_prefetch_data: True
35+
graphite_remote_retry_delay: "60.0"
36+
graphite_max_fetch_retry: 2
37+
38+
graphite_find_cache_duration: 120
39+
graphite_remote_store_use_post: True
40+
graphite_remote_store_forward_headers: '["x-org-id"]'
41+
42+
43+
graphite_cluster_servers: '["10.0.2.2:80", "10.0.2.3:80"]'
44+
graphite_memcache_hosts: "['10.10.10.10:11211', '10.10.10.11:11211', '10.10.10.12:11211']"
45+
46+
graphite_cache_duration: 30
47+
graphite_url_prefix: "/graphite"

handlers/handlers.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- name: restart graphite-web
3+
service: name=diamond state=restarted
4+
when: graphite_web_service

meta/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
dependencies:
3+
- src: https://gitlab.home/ansible-roles/nginx.git
4+
version: 1.0.2
5+
name: nginx
6+
scm: git
7+
when: graphite_use_nginx

tasks/configure/common.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- name: Deploy config file local_settings.py
2+
template:
3+
src: "local_settings.py.j2"
4+
dest: "{{ graphite_path }}/webapp/graphite/local_settings.py"
5+
owner: "root"
6+
mode: 0644
7+
register: mysql_conf
8+
notify: restart mysql
9+
tags:
10+
- graphite
11+
- graphite-config
12+
13+
- name: Create sqlite db
14+
command: django-admin.py migrate --settings=graphite.settings --run-syncdb chdir={{ graphite_path }} creates={{ graphite_storage_dir }}/graphite.db
15+
environment:
16+
PATH: "{{ graphite_path}}/bin:{{ ansible_env.PATH }}"
17+
PYTHONPATH: "{{ graphite_path }}"
18+
tags:
19+
- graphite
20+
- graphite-config

tasks/configure/linux.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- name: systemd socket file
2+
template:
3+
src: "graphite-web.socket.j2"
4+
dest: "/etc/systemd/system/graphite-web.socket.j2"
5+
owner: "root"
6+
mode: "0644"
7+
register: socket_file
8+
tags:
9+
- graphite
10+
- graphite-config
11+
12+
- name: systemd service file
13+
template: src=graphite-web.service.j2 dest=/etc/systemd/system/graphite-web.service.j2 owner=root mode=0644
14+
register: service_file
15+
tags:
16+
- graphite
17+
- graphite-config
18+
19+
- name: reload systemd
20+
systemd: daemon_reload=yes
21+
when: socket_file.changed or service_file.changed
22+
tags:
23+
- graphite
24+
- graphite-config

tasks/install/common.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- name: Creates log_dir
2+
file:
3+
path: "{{ graphite_log_dir }}"
4+
state: directory
5+
tags:
6+
- graphite
7+
- graphite-install
8+
9+
- name: Creates storage_dir
10+
file:
11+
path: "{{ graphite_storage_dir }}"
12+
state: directory
13+
tags:
14+
- graphite
15+
- graphite-install

tasks/install/redhat.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: install graphite-web
2+
yum: name=graphite-web
3+
tags:
4+
- graphite
5+
- graphite-install

tasks/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- name: OS Specific install
2+
include: "{{ item }}"
3+
with_first_found:
4+
- "install/{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
5+
- "install/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
6+
- "install/{{ ansible_distribution | lower }}.yml"
7+
- "install/{{ ansible_os_family | lower }}.yml"
8+
- "install/{{ ansible_system | lower }}.yml"
9+
tags:
10+
- graphite_install
11+
12+
- name: OS Common install
13+
include: "install/common.yml"
14+
tags:
15+
- graphite_install
16+
17+
- name: OS Specific config
18+
include: "{{ item }}"
19+
with_first_found:
20+
- "configure/{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
21+
- "configure/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
22+
- "configure/{{ ansible_distribution | lower }}.yml"
23+
- "configure/{{ ansible_os_family | lower }}.yml"
24+
- "configure/{{ ansible_system | lower }}.yml"
25+
tags:
26+
- graphite_config
27+
28+
- name: Restart graphite-web
29+
service: name=graphite-web state=restarted
30+
when: config.changed
31+
32+
- name: Start graphite-web
33+
service: name=graphite-web state=started

templates/graphite-web.service.j2

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This is /etc/systemd/system/graphite-web.service
2+
[Unit]
3+
Description=graphite-web service
4+
Requires=graphite-web.socket
5+
6+
[Service]
7+
ExecStart={{ graphite_path }}/bin/gunicorn -n graphite-web --chdir {{ graphite_path }} -w {{ graphite_web_workers }} {% if graphite_disable_access_log is defined %}--disable-redirect-access-to-syslog{% endif %} {% if graphite_error_logfile is defined %}--error-logfile {{graphite_error_logfile}}{% endif%} --worker-connections {{ graphite_max_connections }} --max-requests {{ graphite_max_connections_per_child }} wsgi:application
8+
Restart=on-failure
9+
ExecReload=/bin/kill -s HUP $MAINPID
10+
ExecStop=/bin/kill -s TERM $MAINPID
11+
PrivateTmp=true
12+
13+
[Install]
14+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)