Add aodh role

Partially-Implements: blueprint ansible-aodh

Change-Id: I9e20f4bf5e7d8f37f243ae15746e2b7bb49eb20c
This commit is contained in:
zhubingbing 2016-08-04 06:51:11 +00:00
parent 306bc101d1
commit 7ce05f9782
28 changed files with 575 additions and 1 deletions

View File

@ -110,6 +110,8 @@ tunnel_interface: "{{ network_interface }}"
neutron_plugin_agent: "openvswitch"
# The default ports used by each service.
aodh_api_port: "8042"
ceilometer_api_port: "8777"
iscsi_port: "3260"
@ -213,6 +215,7 @@ enable_nova: "yes"
enable_rabbitmq: "yes"
# Additional optional OpenStack services are specified here
enable_aodh: "no"
enable_ceilometer: "no"
enable_central_logging: "no"
enable_ceph: "no"

View File

@ -87,6 +87,10 @@ control
[ceilometer:children]
control
[aodh:children]
control
# Tempest
[tempest:children]
control
@ -235,6 +239,19 @@ mistral
[mistral-engine:children]
mistral
# Aodh
[aodh-api:children]
aodh
[aodh-evaluator:children]
aodh
[aodh-listener:children]
aodh
[aodh-notifier:children]
aodh
# Ceilometer
[ceilometer-api:children]
ceilometer

View File

@ -99,6 +99,9 @@ control
[ceilometer:children]
control
[aodh:children]
control
# Tempest
[tempest:children]
control
@ -264,6 +267,19 @@ ceilometer
[ceilometer-compute:children]
compute
# Aodh
[aodh-api:children]
aodh
[aodh-evaluator:children]
aodh
[aodh-listener:children]
aodh
[aodh-notifier:children]
aodh
# Multipathd
[multipathd:children]
compute

View File

@ -0,0 +1,43 @@
---
project_name: "aodh"
####################
# Database
####################
aodh_database_name: "aodh"
aodh_database_user: "aodh"
aodh_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
####################
# Docker
####################
aodh_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-aodh-api"
aodh_api_tag: "{{ openstack_release }}"
aodh_api_image_full: "{{ aodh_api_image }}:{{ aodh_api_tag }}"
aodh_evaluator_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-aodh-evaluator"
aodh_evaluator_tag: "{{ openstack_release }}"
aodh_evaluator_image_full: "{{ aodh_evaluator_image }}:{{ aodh_evaluator_tag }}"
aodh_listener_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-aodh-listener"
aodh_listener_tag: "{{ openstack_release }}"
aodh_listener_image_full: "{{ aodh_listener_image }}:{{ aodh_listener_tag }}"
aodh_notifier_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-aodh-notifier"
aodh_notifier_tag: "{{ openstack_release }}"
aodh_notifier_image_full: "{{ aodh_notifier_image }}:{{ aodh_notifier_tag }}"
####################
# OpenStack
####################
aodh_admin_endpoint: "{{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ aodh_api_port }}"
aodh_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ aodh_api_port }}"
aodh_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn }}:{{ aodh_api_port }}"
aodh_logging_debug: "{{ openstack_logging_debug }}"
aodh_keystone_user: "aodh"
openstack_aodh_auth: "{'auth_url':'{{ openstack_auth.auth_url }}','username':'{{ openstack_auth.username }}','password':'{{ openstack_auth.password }}','project_name':'{{ openstack_auth.project_name }}','domain_name':'default'}"

View File

@ -0,0 +1,3 @@
---
dependencies:
- { role: common }

View File

@ -0,0 +1,41 @@
---
- name: Creating aodh database
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_db
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ aodh_database_name }}'"
register: database
changed_when: "{{ database.stdout.find('localhost | SUCCESS => ') != -1 and
(database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['aodh-api'][0] }}"
- name: Reading json from variable
set_fact:
database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
- name: Creating aodh database user and setting permissions
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m mysql_user
-a "login_host='{{ database_address }}'
login_port='{{ database_port }}'
login_user='{{ database_user }}'
login_password='{{ database_password }}'
name='{{ aodh_database_name }}'
password='{{ aodh_database_password }}'
host='%'
priv='{{ aodh_database_name }}.*:ALL'
append_privs='yes'"
register: database_user_create
changed_when: "{{ database_user_create.stdout.find('localhost | SUCCESS => ') != -1 and
(database_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: database_user_create.stdout.split()[2] != 'SUCCESS'
run_once: True
delegate_to: "{{ groups['aodh-api'][0] }}"
- include: bootstrap_service.yml
when: database_created

View File

@ -0,0 +1,21 @@
---
- name: Running aodh bootstrap container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
detach: False
environment:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ aodh_api_image_full }}"
labels:
BOOTSTRAP:
name: "bootstrap_aodh"
restart_policy: "never"
volumes:
- "{{ node_config_directory }}/aodh-api/:{{ container_config_directory }}/:ro"
- "aodh:/var/lib/aodh/"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True
delegate_to: "{{ groups['aodh-api'][0] }}"

View File

@ -0,0 +1,50 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
with_items:
- "aodh-api"
- "aodh-evaluator"
- "aodh-listener"
- "aodh-notifier"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "aodh-api"
- "aodh-listener"
- "aodh-evaluator"
- "aodh-notifier"
- name: Copying over aodh.conf
merge_configs:
vars:
service_name: "{{ item }}"
sources:
- "{{ role_path }}/templates/aodh.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/database.conf"
- "{{ node_custom_config }}/messaging.conf"
- "{{ node_custom_config }}/aodh.conf"
- "{{ node_custom_config }}/aodh/{{ item }}.conf"
- "{{ node_custom_config }}/aodh/{{ inventory_hostname }}/{{ item }}.conf"
dest: "{{ node_config_directory }}/{{ item }}/aodh.conf"
with_items:
- "aodh-api"
- "aodh-evaluator"
- "aodh-listener"
- "aodh-notifier"
- name: Copying over wsgi-aodh files for services
template:
src: "wsgi-aodh.conf.j2"
dest: "{{ node_config_directory }}/{{ item }}/wsgi-aodh.conf"
with_items:
- "aodh-api"
- "aodh-evaluator"
- "aodh-listener"
- "aodh-notifier"

View File

@ -0,0 +1,18 @@
---
- include: register.yml
when: inventory_hostname in groups['aodh-api']
- include: config.yml
when: inventory_hostname in groups['aodh-api'] or
inventory_hostname in groups['aodh-evaluator'] or
inventory_hostname in groups['aodh-listener'] or
inventory_hostname in groups['aodh-notifier']
- include: bootstrap.yml
when: inventory_hostname in groups['aodh-api']
- include: start.yml
when: inventory_hostname in groups['aodh-api'] or
inventory_hostname in groups['aodh-evaluator'] or
inventory_hostname in groups['aodh-listener'] or
inventory_hostname in groups['aodh-notifier']

View File

@ -0,0 +1,79 @@
---
- name: Ensuring the containers up
kolla_docker:
name: "{{ item.name }}"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups[item.group]
with_items:
- { name: aodh_api, group: aodh-api }
- { name: aodh_listener, group: aodh-listener }
- { name: aodh_evaluator, group: aodh-evaluator }
- { name: aodh_notifier, group: aodh-notifier }
- include: config.yml
- name: Check the configs
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups[item.group]
with_items:
- { name: aodh_api, group: aodh-api }
- { name: aodh_listener, group: aodh-listener }
- { name: aodh_evaluator, group: aodh-evaluator }
- { name: aodh_notifier, group: aodh-notifier }
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
# just remove the container and start again
- name: Containers config strategy
kolla_docker:
name: "{{ item.name }}"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups[item.group]
with_items:
- { name: aodh_api, group: aodh-api }
- { name: aodh_listener, group: aodh-listener }
- { name: aodh_evaluator, group: aodh-evaluator }
- { name: aodh_notifier, group: aodh-notifier }
- name: Remove the containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "remove_container"
register: remove_containers
when:
- inventory_hostname in groups[item[0]['group']]
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- item[2]['rc'] == 1
with_together:
- [{ name: aodh_api, group: aodh-api },
{ name: aodh_listener, group: aodh-listener },
{ name: aodh_evaluator, group: aodh-evaluator },
{ name: aodh_notifier, group: aodh-notifier }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "restart_container"
when:
- inventory_hostname in groups[item[0]['group']]
- config_strategy == 'COPY_ALWAYS'
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- item[2]['rc'] == 1
with_together:
- [{ name: aodh_api, group: aodh-api },
{ name: aodh_listener, group: aodh-listener },
{ name: aodh_evaluator, group: aodh-evaluator },
{ name: aodh_notifier, group: aodh-notifier }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"

View File

@ -0,0 +1,2 @@
---
- include: "{{ action }}.yml"

View File

@ -0,0 +1,28 @@
---
- name: Pulling aodh-api image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_api_image_full }}"
when: inventory_hostname in groups['aodh-api']
- name: Pulling aodh-listener image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_listener_image_full }}"
when: inventory_hostname in groups['aodh-listener']
- name: Pulling aodh-evaluator image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_evaluator_image_full }}"
when: inventory_hostname in groups['aodh-evaluator']
- name: Pulling aodh-notifier image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_notifier_image_full }}"
when: inventory_hostname in groups['aodh-notifier']

View File

@ -0,0 +1,7 @@
---
- include: do_reconfigure.yml
serial: "30%"
when: inventory_hostname in groups['aodh-api']
or inventory_hostname in groups['aodh-listener']
or inventory_hostname in groups['aodh-evaluator']
or inventory_hostname in groups['aodh-notifier']

View File

@ -0,0 +1,40 @@
---
- name: Creating the aodh service and endpoint
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m kolla_keystone_service
-a "service_name=aodh
service_type=alarming
description='OpenStack Alarming Service'
endpoint_region={{ openstack_region_name }}
url='{{ item.url }}'
interface='{{ item.interface }}'
region_name={{ openstack_region_name }}
auth={{ '{{ openstack_aodh_auth }}' }}"
-e "{'openstack_aodh_auth':{{ openstack_aodh_auth }}}"
register: aodh_endpoint
changed_when: "{{ aodh_endpoint.stdout.find('localhost | SUCCESS => ') != -1 and (aodh_endpoint.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
until: aodh_endpoint.stdout.split()[2] == 'SUCCESS'
retries: 10
delay: 5
run_once: True
with_items:
- {'interface': 'admin', 'url': '{{ aodh_admin_endpoint }}'}
- {'interface': 'internal', 'url': '{{ aodh_internal_endpoint }}'}
- {'interface': 'public', 'url': '{{ aodh_public_endpoint }}'}
- name: Creating the aodh project, user, and role
command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-m kolla_keystone_user
-a "project=service
user=aodh
password={{ aodh_keystone_password }}
role=admin
region_name={{ openstack_region_name }}
auth={{ '{{ openstack_aodh_auth }}' }}"
-e "{'openstack_aodh_auth':{{ openstack_aodh_auth }}}"
register: aodh_user
changed_when: "{{ aodh_user.stdout.find('localhost | SUCCESS => ') != -1 and (aodh_user.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
until: aodh_user.stdout.split()[2] == 'SUCCESS'
retries: 10
delay: 5
run_once: True

View File

@ -0,0 +1,45 @@
---
- name: Starting aodh-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_api_image_full }}"
name: "aodh_api"
volumes:
- "{{ node_config_directory }}/aodh-api/:{{ container_config_directory }}/:ro"
- "aodh:/var/lib/aodh/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['aodh-api']
- name: Starting aodh-evaluator container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_evaluator_image_full }}"
name: "aodh_evaluator"
volumes:
- "{{ node_config_directory }}/aodh-evaluator/:{{ container_config_directory }}/:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['aodh-evaluator']
- name: Starting aodh-listener container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_listener_image_full }}"
name: "aodh_listener"
volumes:
- "{{ node_config_directory }}/aodh-listener/:{{ container_config_directory }}/:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['aodh-listener']
- name: Starting aodh-notifier container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_notifier_image_full }}"
name: "aodh_notifier"
volumes:
- "{{ node_config_directory }}/aodh-notifier/:{{ container_config_directory }}/:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['aodh-notifier']

View File

@ -0,0 +1,25 @@
{% set aodh_cmd = 'apache2' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd' %}
{% set aodh_dir = 'apache2/conf-enabled' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd/conf.d' %}
{
"command": "{{ aodh_cmd }} -DFOREGROUND",
"config_files": [
{
"source": "{{ container_config_directory }}/aodh.conf",
"dest": "/etc/aodh/aodh.conf",
"owner": "aodh",
"perm": "0644"
},
{
"source": "{{ container_config_directory }}/api_paste.ini",
"dest": "/etc/aodh/api_paste.ini",
"owner": "aodh",
"perm": "0644"
},
{
"source": "{{ container_config_directory }}/wsgi-aodh.conf",
"dest": "/etc/{{ aodh_dir }}/wsgi-aodh.conf",
"owner": "aodh",
"perm": "0644"
}
]
}

View File

@ -0,0 +1,11 @@
{
"command": "aodh-evaluator",
"config_files": [
{
"source": "{{ container_config_directory }}/aodh.conf",
"dest": "/etc/aodh/aodh.conf",
"owner": "aodh",
"perm": "0600"
}
]
}

View File

@ -0,0 +1,11 @@
{
"command": "aodh-listener",
"config_files": [
{
"source": "{{ container_config_directory }}/aodh.conf",
"dest": "/etc/aodh/aodh.conf",
"owner": "aodh",
"perm": "0600"
}
]
}

View File

@ -0,0 +1,11 @@
{
"command": "aodh-notifier",
"config_files": [
{
"source": "{{ container_config_directory }}/aodh.conf",
"dest": "/etc/aodh/aodh.conf",
"owner": "aodh",
"perm": "0600"
}
]
}

View File

@ -0,0 +1,45 @@
[DEFAULT]
auth_strategy = keystone
log_dir = /var/log/kolla/aodh
debug = {{ aodh_logging_debug }}
rpc_backend = rabbit
notification_topics = notifications
[oslo_messaging_rabbit]
rabbit_userid = {{ rabbitmq_user }}
rabbit_password = {{ rabbitmq_password }}
rabbit_ha_queues = true
rabbit_hosts = {% for host in groups['rabbitmq'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ rabbitmq_port }}{% if not loop.last %},{% endif %}{% endfor %}
[api]
port = {{ aodh_api_port }}
host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
[database]
connection = mysql+pymysql://{{ aodh_database_user }}:{{ aodh_database_password }}@{{ aodh_database_address }}/{{ aodh_database_name }}
[keystone_authtoken]
memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ memcache_secret_key }}
memcache_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address']
auth_uri = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_public_port }}
project_domain_name = default
project_name = service
user_domain_name = default
username = {{ aodh_keystone_user }}
password = {{ aodh_keystone_password }}
auth_url = {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}
auth_type = password
[service_credentials]
auth_url = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_public_port }}/v3
region_name = {{ openstack_region_name }}
password = {{ aodh_keystone_password }}
username = {{ aodh_keystone_user }}
project_name = service
project_domain_id = default
user_domain_id = default
auth_type = password

View File

@ -0,0 +1,25 @@
{% set python_path = '/usr/lib/python2.7/site-packages' if kolla_install_type == 'binary' else '/var/lib/kolla/venv/lib/python2.7/site-packages' %}
Listen {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ aodh_api_port }}
<VirtualHost *:{{ aodh_api_port }}>
## Vhost docroot
DocumentRoot "/var/www/cgi-bin/aodh"
## Directories, there should at least be a declaration for /var/www/cgi-bin/aodh
<Directory "/var/www/cgi-bin/aodh">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
## Logging
ErrorLog "/var/log/kolla/aodh/aodh_wsgi_error.log"
ServerSignature Off
CustomLog "/var/log/kolla/aodh/aodh_wsgi_access.log" combined
WSGIApplicationGroup %{GLOBAL}
WSGIDaemonProcess aodh group=aodh processes=2 threads=2 user=aodh python-path={{ python_path }}
WSGIProcessGroup aodh
WSGIScriptAlias / "/var/www/cgi-bin/aodh/app.wsgi"
</VirtualHost>

View File

@ -23,6 +23,7 @@
dest: "{{ node_config_directory }}/heka/heka-{{ item.name }}.toml"
when: item.enabled | bool
with_items:
- { name: "aodh", enabled: "{{ enable_aodh }}" }
- { name: "elasticsearch", enabled: "{{ enable_central_logging }}" }
- { name: "global", enabled: "yes" }
- { name: "haproxy", enabled: "{{ enable_haproxy }}" }
@ -54,6 +55,7 @@
dest: "{{ node_config_directory }}/cron/logrotate/{{ item }}.conf"
with_items:
- "ansible"
- "aodh"
- "cinder"
- "glance"
- "global"

View File

@ -0,0 +1,3 @@
"/var/log/kolla/aodh/*.log"
{
}

View File

@ -1,5 +1,5 @@
{% set cron_cmd = 'cron -f' if kolla_base_distro in ['ubuntu', 'debian'] else 'crond -s -n' %}
{% set services = ["ansible", "cinder", "glance", "haproxy", "heat", "keepalived", "keystone", "magnum", "manila", "mariadb", "mistral", "murano", "neutron", "nova", "rabbitmq", "swift"] %}
{% set services = ["ansible", "aodh", "cinder", "glance", "haproxy", "heat", "keepalived", "keystone", "magnum", "manila", "mariadb", "mistral", "murano", "neutron", "nova", "rabbitmq", "swift"] %}
{
"command": "{{ cron_cmd }}",
"config_files": [

View File

@ -0,0 +1,13 @@
[aodh_apache_log_decoder]
type = "SandboxDecoder"
filename = "lua_decoders/os_aodh_apache_log.lua"
[aodh_apache_log_decoder.config]
apache_log_pattern = '%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"'
[aodh_apache_logstreamer_input]
type = "LogstreamerInput"
decoder = "aodh_apache_log_decoder"
log_directory = "/var/log/kolla"
file_match = 'aodh/aodh-apache-(?P<Service>.+)-access\.log\.?(?P<Seq>\d*)$'
priority = ["^Seq"]
differentiator = ["aodh-apache-", "Service"]

View File

@ -239,6 +239,15 @@
tags: ceilometer,
when: enable_ceilometer | bool }
- hosts:
- aodh
- rabbitmq
- memcached
roles:
- { role: aodh,
tags: aodh,
when: enable_aodh | bool }
- hosts:
- tempest
roles:

View File

@ -21,6 +21,9 @@ docker_registry_password:
####################
# OpenStack options
####################
aodh_database_password:
aodh_keystone_password:
keystone_admin_password:
keystone_database_password:

View File

@ -0,0 +1,3 @@
---
features:
- Implement Aodh ansible role