Serve the ceilometer-api using mod_wsgi

With the dependent change merged Ceilometer API will no longer run
without a stand-alone wsgi engine. It is too late in the cycle right
now to bring over changes for nginx and/or uwsgi for this project so
only this deployment option is being supported at this time.

Change-Id: I3cff6b183feae3c346cd56602d7b733a6dd9a01b
Depends-On: I8812ea1a92d6dc7f41a490e971bb7a09dee9b304
This commit is contained in:
Steve Lewis 2016-09-14 10:45:09 -07:00
parent de037c4d3f
commit 31cddcd762
13 changed files with 166 additions and 17 deletions

View File

@ -57,6 +57,13 @@ ceilometer_db_ip: localhost
ceilometer_db_port: 27017
ceilometer_connection_string: "{{ ceilometer_db_type }}://{{ ceilometer_database_user }}:{{ ceilometer_container_db_password }}@{{ ceilometer_db_ip }}:{{ ceilometer_db_port }}/{{ ceilometer_database_name }}"
## Apache setup
ceilometer_apache_log_level: info
ceilometer_apache_servertokens: "Prod"
ceilometer_apache_serversignature: "Off"
ceilometer_wsgi_threads: 10
ceilometer_wsgi_processes: "{{ ansible_processor_vcpus | default (1) * 2 }}"
## RabbitMQ info
## Configuration for RPC communications

View File

@ -13,13 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Restart ceilometer api
service:
name: "{{ ceilometer_api_program_name }}"
state: "restarted"
pattern: "{{ ceilometer_api_program_name }}"
- name: Restart ceilometer collector
service:
name: "{{ ceilometer_collector_program_name }}"
@ -45,3 +38,13 @@
pattern: "{{ item }}"
with_items: "{{ ceilometer_service_names }}"
failed_when: false
- name: Restart Apache
service:
name: "apache2"
state: "restarted"
pattern: "apache2"
register: apache_restart
until: apache_restart|success
retries: 5
delay: 2

View File

@ -0,0 +1,4 @@
---
upgrade:
- The ``ceilometer-api`` init service is removed since ``ceilometer-api`` is
deployed as an apache ``mod_wsgi`` service.

View File

@ -0,0 +1,63 @@
---
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Drop apache2 virtual host and ports file
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "root"
group: "root"
with_items:
- { src: "ceilometer-ports.conf.j2", dest: "/etc/apache2/ports.conf" }
- { src: "ceilometer-httpd.conf.j2", dest: "/etc/apache2/sites-available/ceilometer-httpd.conf" }
notify:
- Restart Apache
- name: Disable default apache site
file:
path: "/etc/apache2/sites-enabled/000-default.conf"
state: "absent"
notify:
- Restart Apache
- name: Enabled ceilometer vhost
file:
src: "/etc/apache2/sites-available/ceilometer-httpd.conf"
dest: "/etc/apache2/sites-enabled/ceilometer-httpd.conf"
state: "link"
notify:
- Restart Apache
- name: Ensure Apache ServerName
lineinfile:
dest: "/etc/apache2/apache2.conf"
line: "ServerName {{ inventory_hostname }}"
notify:
- Restart Apache
- name: Ensure Apache ServerTokens
lineinfile:
dest: "/etc/apache2/conf-available/security.conf"
regexp: '^ServerTokens'
line: "ServerTokens {{ ceilometer_apache_servertokens }}"
notify:
- Restart Apache
- name: Ensure Apache ServerSignature
lineinfile:
dest: "/etc/apache2/conf-available/security.conf"
regexp: '^ServerSignature'
line: "ServerSignature {{ ceilometer_apache_serversignature }}"
notify:
- Restart Apache

View File

@ -13,15 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: ceilometer_init_common.yml
vars:
program_name: "{{ ceilometer_api_program_name }}"
service_name: "{{ ceilometer_service_name }}"
system_user: "{{ ceilometer_system_user_name }}"
system_group: "{{ ceilometer_system_group_name }}"
service_home: "{{ ceilometer_system_user_home }}"
when: inventory_hostname in groups['ceilometer_api']
- include: ceilometer_init_common.yml
vars:
program_name: "{{ ceilometer_agent_notification_program_name }}"

View File

@ -65,7 +65,19 @@
dest: "/etc/ceilometer/policy.json"
config_overrides: "{{ ceilometer_policy_overrides }}"
config_type: "json"
notify: Restart ceilometer services
notify:
- Restart ceilometer services
- Restart Apache
- name: Drop ceilometer API WSGI Configs
template:
src: ceilometer-api-wsgi.py.j2
dest: /var/www/cgi-bin/ceilometer/ceilometer-api
owner: "{{ ceilometer_system_user_name }}"
group: "{{ ceilometer_system_group_name }}"
mode: "0755"
notify:
- Restart Apache
- name: Drop rootwrap filters
copy:

View File

@ -54,6 +54,17 @@
- { path: "{{ ceilometer_system_user_home }}/.ssh", mode: "0700" }
- { path: "/var/cache/ceilometer", mode: "0700" }
- name: Create Apache mod_wsgi dirs
file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner|default(ceilometer_system_user_name) }}"
group: "{{ item.group|default(ceilometer_system_group_name) }}"
mode: "0755"
with_items:
- { path: "/var/www/cgi-bin", owner: root, group: root }
- { path: "/var/www/cgi-bin/ceilometer" }
- name: Test for log directory or link
shell: |
if [ -h "/var/log/ceilometer" ]; then

View File

@ -61,6 +61,13 @@
tags:
- ceilometer-install
- include: ceilometer_apache.yml
when:
- inventory_hostname in groups['ceilometer_api']
tags:
- ceilometer-install
- ceilometer-config
- include: ceilometer_service_setup.yml
when:
- inventory_hostname == groups['ceilometer_api'][0]

View File

@ -0,0 +1,22 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
activate_this = os.path.expanduser("{{ ceilometer_bin }}/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
from ceilometer import service
from ceilometer.api import app
service.prepare_service([])
application = app.load_app()

View File

@ -0,0 +1,16 @@
# {{ ansible_managed }}
<VirtualHost *:{{ ceilometer_service_port }}>
WSGIDaemonProcess ceilometer-api lang='en_US.UTF-8' locale='en_US.UTF-8' user={{ ceilometer_system_user_name }} group={{ ceilometer_system_group_name }} processes={{ ceilometer_wsgi_processes }} threads={{ ceilometer_wsgi_threads }} display-name=%{GROUP}
WSGIProcessGroup ceilometer-api
WSGIScriptAlias / /var/www/cgi-bin/ceilometer/ceilometer-api
WSGIApplicationGroup %{GLOBAL}
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
LogLevel {{ ceilometer_apache_log_level }}
ErrorLog /var/log/ceilometer/ceilometer-apache-error.log
CustomLog /var/log/ceilometer/ceilometer-access.log combined
</VirtualHost>

View File

@ -0,0 +1,3 @@
# {{ ansible_managed }}
Listen {{ ceilometer_service_port }}

View File

@ -21,6 +21,11 @@ ceilometer_distro_packages:
- rpcbind
- rsync
- git
- apache2
- apache2-utils
- libapache2-mod-wsgi
- libffi-dev
- libssl-dev
# Packages required in developer mode, where packages are built locally
ceilometer_developer_mode_distro_packages:

View File

@ -21,6 +21,11 @@ ceilometer_distro_packages:
- rpcbind
- rsync
- git
- apache2
- apache2-utils
- libapache2-mod-wsgi
- libffi-dev
- libssl-dev
# Packages required in developer mode, where packages are built locally
ceilometer_developer_mode_distro_packages: