Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RedHat. #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gitreview
38 changes: 34 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
---
horizon_path: /opt/stack/horizon/
panel_src_path_os:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are enough platform specific variables that I think it would be cleaner to setup individual files for them and then at the top of the main task do an include_vars with_first_found statement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but vars are hard to overwrite. You could do it in include role but not in host_vars and group_vars. So if we think that some variable could be overwritten we think that better place is defaults/main.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point using include_vars does make them harder to overwrite.

RedHat: /usr/lib/python2.7/site-packages/monitoring/
Debian: /usr/local/lib/python2.7/dist-packages/monitoring/

grafana_tarball_url_os:
RedHat: https://api.github.com/repos/FujitsuEnablingSoftwareTechnologyGmbH/grafana/tarball
Debian: https://api.github.com/repos/hpcloud-mon/grafana/tarball

apache_conf_dir_os:
RedHat: /etc/httpd/conf.d/
Debian: /etc/apache2/sites-enabled/

apache_service_name_os:
RedHat: httpd
Debian: apache2

horizon_path_os:
RedHat: /usr/share/openstack-dashboard/
Debian: /opt/stack/horizon/

download_tmp_dir: /opt/monasca_download

apache_conf_dir: "{{ apache_conf_dir_os[ansible_os_family] }}"
apache_service_name: "{{ apache_service_name_os[ansible_os_family] }}"
horizon_path: "{{ horizon_path_os[ansible_os_family] }}"
grafana_tarball_url: "{{ grafana_tarball_url_os[ansible_os_family] }}"
panel_src_path: "{{ panel_src_path_os[ansible_os_family] }}"

monasca_ui_name: monasca-ui

kibana_support_enabled: False

dashboard_path: "{{ horizon_path }}openstack_dashboard/"
dashboard_settings_file: "{{ dashboard_path }}settings.py"

Expand All @@ -8,12 +39,11 @@ grafana_dest: "{{ horizon_path }}static/grafana"
grafana_config: "{{ grafana_dest }}/config.js"
grafana_version: master

panel_src_path: /usr/local/lib/python2.7/dist-packages/monitoring/
panel_dest_path: "{{ horizon_path }}monitoring"
panel_static_dest_path: "{{ horizon_path }}static/monitoring"

ui_dest_path: "{{ dashboard_path }}local/enabled/"
ui_src_path: "{{panel_src_path}}enabled/"
ui_py_file: _50_admin_add_monitoring_panel.py



grafana_tarball_file: ""
3 changes: 1 addition & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
- name: restart apache
service: name=apache2 state=restarted enabled=yes

service: name={{ apache_service_name }} state=restarted enabled=yes
26 changes: 19 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
- name: Change ownership on monasca download directory.
file: path="{{download_tmp_dir}}" state=directory owner=root group=root recurse=yes

- name: UI - Install monasca-ui package
pip: name=monasca-ui state=latest
pip: name="{{monasca_ui_name}}" state=present extra_args='--pre'
notify:
- restart apache

Expand All @@ -10,12 +13,16 @@
- name: UI - Link monitoring directory
file: src={{ panel_src_path }} dest={{ panel_dest_path }} state=link force=no

- name: Copy configuration file
template: dest={{ panel_src_path }}/config/local_settings.py owner=root group=root mode=644 src=local_settings.py.j2
notify: restart apache

- name: UI - Fetch grafana tar.gz file
get_url: dest=/root/hpcloud-mon-grafana-{{grafana_version}}.tar.gz url={{github_tarball_url}}/{{grafana_version}}
get_url: dest={{ download_tmp_dir }}/hpcloud-mon-grafana-{{grafana_version}}.tar.gz url={{grafana_tarball_url}}/{{grafana_version}}{{grafana_tarball_file}}
register: download

- name: UI - Uncompress the grafana tar
unarchive: copy=no dest={{ grafana_base_dir }} src=/root/hpcloud-mon-grafana-{{grafana_version}}.tar.gz
unarchive: copy=no dest={{ grafana_base_dir }} src={{ download_tmp_dir }}/hpcloud-mon-grafana-{{grafana_version}}.tar.gz
register: untar
when: download | changed
notify:
Expand All @@ -25,7 +32,7 @@
# In Ansible 1.8 this was in the untar variable, in 2.0 there is list_files option you can add to unarchive but in 1.9 we must use this
# command to discover the tar dir. This method will work for the other versions also.
- name: Discover the tar path
command: tar -tzf /root/hpcloud-mon-grafana-{{grafana_version}}.tar.gz
command: tar -tzf {{ download_tmp_dir }}/hpcloud-mon-grafana-{{grafana_version}}.tar.gz
register: tarpath
when: untar | changed

Expand All @@ -39,8 +46,6 @@
file: src={{ grafana_dest }}/config.monasca.js dest={{ grafana_config }} state=link force=no
when: untar | changed

- meta: flush_handlers

- stat: path={{horizon_path}}manage.py
register: horizon_manage

Expand All @@ -49,4 +54,11 @@
when: horizon_manage.stat.exists

- name: Enable apache
service: name=apache2 state=started enabled=yes
service: name="{{ apache_service_name }}" state=started enabled=yes

- stat: path={{horizon_path}}static/monitoring
register: static_monitoring

- name: UI - Link static monitoring directory
file: src={{ panel_dest_path }}/static/monitoring dest={{ panel_static_dest_path }} state=link force=no
when: not static_monitoring.stat.exists
24 changes: 24 additions & 0 deletions templates/local_settings.py.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.utils.translation import ugettext_lazy as _

# Services being monitored
MONITORING_SERVICES = [
{'name': _('OpenStack Services'),
'groupBy': 'service'},
{'name': _('Servers'),
'groupBy': 'hostname'}
]

# Grafana button titles/file names
GRAFANA_LINKS = [
{'title': 'Dashboard', 'fileName': 'openstack.json'},
{'title': 'Monasca Health', 'fileName': 'monasca.json'}
]

{% if kibana_support_enabled is defined and kibana_support_enabled %}
KIBANA_HOST = '{{ kibana_url }}'
{% endif %}

MONITORING_SERVICE_TYPE='monitoring'

OPENSTACK_SSL_NO_VERIFY=False
OPENSTACK_SSL_CACERT=None
3 changes: 0 additions & 3 deletions vars/main.yml

This file was deleted.