Skip to content

Commit a21bb9b

Browse files
committed
Merge pull request #10 from nsg/centos7
Support for RedHat/CentOS 7
2 parents 4afe7b0 + 13aab38 commit a21bb9b

File tree

10 files changed

+125
-22
lines changed

10 files changed

+125
-22
lines changed

.travis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22

33
sudo: required
4+
dist: trusty
45
language: python
56
services:
67
- docker
@@ -13,10 +14,7 @@ env:
1314
- TEST_OSVER="debian:8"
1415
- TEST_OSVER="ubuntu:1404"
1516
- TEST_OSVER="centos:6"
16-
17-
before_install:
18-
# hack! https://github.com/travis-ci/travis-ci/issues/4778
19-
- sudo service docker restart ; sleep 10
17+
- TEST_OSVER="centos:7"
2018

2119
install:
2220
# Download ansible-role-tester and setup the enviroment

defaults/main.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
2+
graphite_install_version: 0.9.15
3+
24
graphite_user: graphite
35
graphite_secret_key: UNSAFE_DEFAULT
46
graphite_time_zone: "UTC"
57

68
graphite_admin_date_joined: "2014-07-21T10:11:17.464"
7-
graphite_admin_email: "root@localhost.localhdomain"
9+
graphite_admin_email: "root@example.com"
810
graphite_admin_first_name: ""
911
graphite_admin_last_name: ""
1012
graphite_admin_last_login: "2014-07-21T10:11:17.464"

meta/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ galaxy_info:
2323
# - all
2424
# - 5
2525
- 6
26-
# - 7
26+
- 7
2727
#- name: GenericUNIX
2828
# versions:
2929
# - all

tasks/Debian.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
- python-pip
77
- python-dev
88
- libcairo2-dev
9-
- python-twisted
109
- python-cairo
1110
- fontconfig
1211
- uwsgi
1312
- uwsgi-plugin-python
1413
- sudo
15-
16-
- name: Use the pip package, version 13
17-
pip: name="Twisted==13.0" state=present
14+
- libffi-dev
1815

1916
- name: Install init.d script for carbon-cache
2017
template: src=debian_carbon_service.j2 dest=/etc/init.d/carbon-cache

tasks/RedHat.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
---
22

3-
- name: Install EPEL repository
3+
- name: Install EPEL repository from fedoraproject.org
44
yum: name=http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
5+
when: ansible_distribution_version.split(".")[0]|int < 7
6+
7+
- name: Install EPEL repository from repo
8+
yum: name=epel-release
9+
when: ansible_distribution_version.split(".")[0]|int >= 7
510

611
- name: Install packages with yum
712
yum: name={{ item }} state=present
@@ -10,15 +15,16 @@
1015
- python-devel
1116
- gcc
1217
- cairo-devel
13-
- python-twisted
1418
- pycairo
1519
- bitmap-fonts-compat
1620
- libselinux-python
1721
- fontconfig
1822
- sudo
23+
- libffi-devel
1924

20-
- name: Use the pip package, version 13
21-
pip: name="Twisted==13.0" state=present
25+
- name: "Install Twisted 15.3.0 on 6.x (never versions req python 2.7)"
26+
pip: name=Twisted==15.3.0
27+
when: ansible_distribution_version.split(".")[0]|int < 7
2228

2329
- name: Install uwsgi with pip
2430
pip: name=uwsgi state=present

tasks/main.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@
1313

1414
- name: Setup graphite with pip
1515
pip: name={{ item }} state=present
16-
with_items:
17-
- "https://github.com/graphite-project/ceres/tarball/master"
18-
- whisper
19-
- carbon
20-
- graphite-web
21-
- "django==1.5" # Current version of graphite do not support 1.6
22-
- "django-tagging==0.3.6" # Never versions require Django 1.7+
16+
with_items: graphite_install_requirements[graphite_install_version]
2317
environment:
2418
PYTHONPATH: "{{ graphite_install_path }}/lib:{{ graphite_install_path }}/webapp"
2519
notify: restart carbon-cache
@@ -39,7 +33,7 @@
3933
template: src=storage-schemas.conf.j2 dest={{ graphite_install_path }}/conf/storage-schemas.conf
4034
notify: restart carbon-cache
4135

42-
- name: Install uwsgi
36+
- name: Install uwsgi configuration
4337
template: src=wsgi.py.j2 dest={{ graphite_install_path }}/conf/wsgi.py
4438
notify: restart carbon-cache
4539

tests/post.yml

+65
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,68 @@
1010
- name: Install nginx (RedHat)
1111
yum: name=nginx
1212
when: ansible_os_family == "RedHat"
13+
14+
- name: Install nginx config
15+
template:
16+
src: templates/graphite.conf.j2
17+
dest: /etc/nginx/conf.d/graphite.conf
18+
19+
- name: Start nginx
20+
service: name=nginx state=started
21+
22+
# Ready to check the installation
23+
24+
- name: Make sure processes are running
25+
shell: "pgrep {{ item }}"
26+
with_items:
27+
- carbon-cache
28+
- uwsgi
29+
- nginx
30+
31+
- name: "Make sure we have a Graphite install at localhost:8080"
32+
shell: "curl -s http://localhost:8080 | grep 'Graphite Browser'"
33+
34+
- name: Download a sample graph
35+
shell: "curl -so out 'http://localhost:8080/render/?width=586&height=308&_salt=1448804805.156&target=carbon.agents.*-a.cache.size'"
36+
37+
- name: Make sure that we got a image
38+
shell: file out | grep -i image
39+
40+
- name: "Insert a metric to carbon"
41+
shell: echo "local.random.diceroll 4711 $(date +%s)" | nc -w 2 0.0.0.0 2003
42+
43+
- name: Wait 5 sec
44+
pause: seconds=5
45+
46+
- name: Search for the value from graphite-web
47+
shell: "curl -s 'http://localhost:8080/render/?_salt=1448817576.96&target=local.random.diceroll&format=csv' | grep ',4711.0'"
48+
49+
- name: Remove false positives from carbon creates.log
50+
lineinfile:
51+
dest: /opt/graphite/storage/log/carbon-cache/carbon-cache-a/creates.log
52+
line: "- REMOVED -"
53+
regexp: "{{ item }}"
54+
with_items:
55+
- "creating database file.*errors.wsp"
56+
- "new metric carbon.agents.*a.errors matched schema carbon"
57+
- "new metric carbon.agents.*a.errors matched aggregation schema default"
58+
failed_when: False
59+
60+
- name: Search for errors in logs
61+
shell: test -f {{ item }} && cat {{ item }}
62+
register: logout
63+
failed_when: >
64+
'error' in logout.stdout or
65+
'Error' in logout.stdout or
66+
'ERROR' in logout.stdout
67+
with_items:
68+
- /var/log/uwsgi_graphite.log
69+
- /var/log/uwsgi/app/graphite.log
70+
- /var/log/nginx/graphite.error.log
71+
- /var/log/nginx/error.log
72+
- /opt/graphite/storage/log/webapp/info.log
73+
- /opt/graphite/storage/log/webapp/exception.log
74+
- /opt/graphite/storage/log/carbon-cache/carbon-cache-a/query.log
75+
- /opt/graphite/storage/log/carbon-cache/carbon-cache-a/listener.log
76+
- /opt/graphite/storage/log/carbon-cache/carbon-cache-a/creates.log
77+
- /opt/graphite/storage/log/carbon-cache/carbon-cache-a/console.log

tests/pre.yml

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
- hosts: all
44
pre_tasks:
55

6+
- name: Install a few packages for the tests
7+
yum: name={{ item }}
8+
with_items:
9+
- file
10+
- nc
11+
when: ansible_os_family == "RedHat"
12+
13+
- name: Install a few packages for the tests
14+
apt: name={{ item }}
15+
with_items:
16+
- netcat
17+
when: ansible_os_family == "Debian"
18+
619
# This is a hack because start-stop-daemon get a little confused
720
# when we run this inside a container and "start-stop-daemon --start
821
# --pidfile mypid --exec myexec --test" fails to correctly identify

tests/templates/graphite.conf.j2

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server {
2+
listen 8080;
3+
charset utf-8;
4+
access_log /var/log/nginx/graphite.access.log;
5+
error_log /var/log/nginx/graphite.error.log;
6+
7+
location / {
8+
include uwsgi_params;
9+
uwsgi_pass 127.0.0.1:3031;
10+
}
11+
}

vars/main.yml

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
---
22

33
graphite_install_path: "/opt/graphite"
4+
graphite_install_requirements:
5+
# List from requirements.txt at https://github.com/graphite-project/graphite-web
6+
0.9.15:
7+
- Django==1.4
8+
- python-memcached==1.47
9+
- txAMQP==0.4
10+
- simplejson==2.1.6
11+
- django-tagging==0.3.1
12+
- gunicorn
13+
- pytz
14+
- sphinx
15+
- sphinx_rtd_theme
16+
- cairocffi
17+
- whisper==0.9.13
18+
- whitenoise
19+
- graphite-web==0.9.15
20+
- carbon==0.9.15

0 commit comments

Comments
 (0)