diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 583c2b84ec..32d1ea79d3 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -122,6 +122,8 @@ congress_api_port: "1789" iscsi_port: "3260" +gnocchi_api_port: "8041" + mariadb_port: "{{ database_port }}" mariadb_wsrep_port: "4567" mariadb_ist_port: "4568" @@ -230,6 +232,7 @@ enable_ceph_rgw: "no" enable_cinder: "no" enable_cinder_backend_lvm: "no" enable_congress: "no" +enable_gnocchi: "no" enable_heat: "yes" enable_horizon: "yes" enable_ironic: "no" diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index ac28357747..8f03580079 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -84,6 +84,9 @@ control [manila:children] control +[gnocchi:children] +control + [ceilometer:children] control @@ -256,6 +259,16 @@ aodh [aodh-notifier:children] aodh +# Gnocchi +[gnocchi-api:children] +gnocchi + +[gnocchi-statsd:children] +gnocchi + +[gnocchi-metricd:children] +gnocchi + # Ceilometer [ceilometer-api:children] ceilometer diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index dcdcdc7d07..7775448ae0 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -110,6 +110,9 @@ control [congress:children] control +[gnocchi:children] +control + # Tempest [tempest:children] control @@ -299,6 +302,16 @@ congress [congress-policy-engine:children] congress +# Gnocchi +[gnocchi-api:children] +gnocchi + +[gnocchi-statsd:children] +gnocchi + +[gnocchi-metricd:children] +gnocchi + # Multipathd [multipathd:children] compute diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 83c87652b3..cf31a54ac7 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -28,6 +28,7 @@ - { name: "aodh", enabled: "{{ enable_aodh }}" } - { name: "elasticsearch", enabled: "{{ enable_central_logging }}" } - { name: "global", enabled: "yes" } + - { name: "gnocchi", enabled: "{{ enable_gnocchi }}" } - { name: "haproxy", enabled: "{{ enable_haproxy }}" } - { name: "horizon", enabled: "{{ enable_horizon }}" } - { name: "keepalived", enabled: "{{ enable_haproxy }}" } @@ -71,6 +72,7 @@ - "cinder" - "glance" - "global" + - "gnocchi" - "haproxy" - "heat" - "keepalived" diff --git a/ansible/roles/common/templates/cron-logrotate-gnocchi.conf.j2 b/ansible/roles/common/templates/cron-logrotate-gnocchi.conf.j2 new file mode 100644 index 0000000000..d6d5d6f449 --- /dev/null +++ b/ansible/roles/common/templates/cron-logrotate-gnocchi.conf.j2 @@ -0,0 +1,3 @@ +"/var/log/kolla/gnocchi/*.log" +{ +} diff --git a/ansible/roles/common/templates/cron.json.j2 b/ansible/roles/common/templates/cron.json.j2 index 4c8d32b95a..2bc594f039 100644 --- a/ansible/roles/common/templates/cron.json.j2 +++ b/ansible/roles/common/templates/cron.json.j2 @@ -1,5 +1,5 @@ {% set cron_cmd = 'cron -f' if kolla_base_distro in ['ubuntu', 'debian'] else 'crond -s -n' %} -{% set services = ["ansible", "aodh", "cinder", "glance", "haproxy", "heat", "keepalived", "keystone", "magnum", "manila", "mariadb", "mistral", "murano", "neutron", "nova", "rabbitmq", "swift"] %} +{% set services = ["ansible", "aodh", "cinder", "glance", "gnocchi", "haproxy", "heat", "keepalived", "keystone", "magnum", "manila", "mariadb", "mistral", "murano", "neutron", "nova", "rabbitmq", "swift"] %} { "command": "{{ cron_cmd }}", "config_files": [ diff --git a/ansible/roles/common/templates/heka-gnocchi.toml.j2 b/ansible/roles/common/templates/heka-gnocchi.toml.j2 new file mode 100644 index 0000000000..e2596762d8 --- /dev/null +++ b/ansible/roles/common/templates/heka-gnocchi.toml.j2 @@ -0,0 +1,13 @@ +[gnocchi_apache_log_decoder] +type = "SandboxDecoder" +filename = "lua_decoders/os_gnocchi_apache_log.lua" + [gnocchi_apache_log_decoder.config] + apache_log_pattern = '%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"' + +[gnocchi_apache_logstreamer_input] +type = "LogstreamerInput" +decoder = "gnocchi_apache_log_decoder" +log_directory = "/var/log/kolla" +file_match = 'gnocchi/gnocchi-apache-(?P.+)-access\.log\.?(?P\d*)$' +priority = ["^Seq"] +differentiator = ["gnocchi-apache-", "Service"] diff --git a/ansible/roles/gnocchi/defaults/main.yml b/ansible/roles/gnocchi/defaults/main.yml new file mode 100644 index 0000000000..3dacdee6ba --- /dev/null +++ b/ansible/roles/gnocchi/defaults/main.yml @@ -0,0 +1,39 @@ +--- +project_name: "gnocchi" + + +#################### +# Database +#################### +gnocchi_database_name: "gnocchi" +gnocchi_database_user: "gnocchi" +gnocchi_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}" + + +#################### +# Docker +#################### +gnocchi_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-gnocchi-api" +gnocchi_api_tag: "{{ openstack_release }}" +gnocchi_api_image_full: "{{ gnocchi_api_image }}:{{ gnocchi_api_tag }}" + +gnocchi_statsd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-gnocchi-statsd" +gnocchi_statsd_tag: "{{ openstack_release }}" +gnocchi_statsd_image_full: "{{ gnocchi_statsd_image }}:{{ gnocchi_statsd_tag }}" + +gnocchi_metricd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-gnocchi-metricd" +gnocchi_metricd_tag: "{{ openstack_release }}" +gnocchi_metricd_image_full: "{{ gnocchi_metricd_image }}:{{ gnocchi_metricd_tag }}" + +#################### +# OpenStack +#################### +gnocchi_admin_endpoint: "{{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ gnocchi_api_port }}" +gnocchi_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ gnocchi_api_port }}" +gnocchi_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn }}:{{ gnocchi_api_port }}" + +gnocchi_logging_debug: "{{ openstack_logging_debug }}" + +gnocchi_keystone_user: "gnocchi" + +openstack_gnocchi_auth: "{'auth_url':'{{ openstack_auth.auth_url }}','username':'{{ openstack_auth.username }}','password':'{{ openstack_auth.password }}','project_name':'{{ openstack_auth.project_name }}','domain_name':'default'}" diff --git a/ansible/roles/gnocchi/meta/main.yml b/ansible/roles/gnocchi/meta/main.yml new file mode 100644 index 0000000000..6b4fff8fef --- /dev/null +++ b/ansible/roles/gnocchi/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - { role: common } diff --git a/ansible/roles/gnocchi/tasks/bootstrap.yml b/ansible/roles/gnocchi/tasks/bootstrap.yml new file mode 100644 index 0000000000..70611b85d5 --- /dev/null +++ b/ansible/roles/gnocchi/tasks/bootstrap.yml @@ -0,0 +1,41 @@ +--- +- name: Creating gnocchi 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='{{ gnocchi_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['gnocchi-api'][0] }}" + +- name: Reading json from variable + set_fact: + database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" + +- name: Creating gnocchi 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='{{ gnocchi_database_name }}' + password='{{ gnocchi_database_password }}' + host='%' + priv='{{ gnocchi_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['gnocchi-api'][0] }}" + +- include: bootstrap_service.yml + when: database_created diff --git a/ansible/roles/gnocchi/tasks/bootstrap_service.yml b/ansible/roles/gnocchi/tasks/bootstrap_service.yml new file mode 100644 index 0000000000..91e140cf7c --- /dev/null +++ b/ansible/roles/gnocchi/tasks/bootstrap_service.yml @@ -0,0 +1,21 @@ +--- +- name: Running gnocchi bootstrap container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + detach: False + environment: + KOLLA_BOOTSTRAP: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + image: "{{ gnocchi_api_image_full }}" + labels: + BOOTSTRAP: + name: "bootstrap_gnocchi" + restart_policy: "never" + volumes: + - "{{ node_config_directory }}/gnocchi-api/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "gnocchi:/var/lib/gnocchi/" + - "kolla_logs:/var/log/kolla/" + run_once: True + delegate_to: "{{ groups['gnocchi-api'][0] }}" diff --git a/ansible/roles/gnocchi/tasks/config.yml b/ansible/roles/gnocchi/tasks/config.yml new file mode 100644 index 0000000000..64765a1d07 --- /dev/null +++ b/ansible/roles/gnocchi/tasks/config.yml @@ -0,0 +1,51 @@ +--- +- name: Ensuring config directories exist + file: + path: "{{ node_config_directory }}/{{ item }}" + state: "directory" + recurse: yes + with_items: + - "gnocchi-api" + - "gnocchi-statsd" + - "gnocchi-metricd" + +- name: Copying over config.json files for services + template: + src: "{{ item }}.json.j2" + dest: "{{ node_config_directory }}/{{ item }}/config.json" + with_items: + - "gnocchi-api" + - "gnocchi-metricd" + - "gnocchi-statsd" + +- name: Copying over api-paste.ini files for services + template: + src: "gnocchi-api-paste.ini.j2" + dest: "{{ node_config_directory }}/{{ item }}/gnocchi-api-paste.ini" + with_items: + - "gnocchi-api" + +- name: Copying over gnocchi.conf + merge_configs: + vars: + service_name: "{{ item }}" + sources: + - "{{ role_path }}/templates/gnocchi.conf.j2" + - "{{ node_custom_config }}/global.conf" + - "{{ node_custom_config }}/database.conf" + - "{{ node_custom_config }}/messaging.conf" + - "{{ node_custom_config }}/gnocchi.conf" + - "{{ node_custom_config }}/gnocchi/{{ item }}.conf" + - "{{ node_custom_config }}/gnocchi/{{ inventory_hostname }}/gnocchi.conf" + dest: "{{ node_config_directory }}/{{ item }}/gnocchi.conf" + with_items: + - "gnocchi-api" + - "gnocchi-statsd" + - "gnocchi-metricd" + +- name: Copying over wsgi-gnocchi.conf + template: + src: "wsgi-gnocchi.conf.j2" + dest: "{{ node_config_directory }}/{{ item }}/wsgi-gnocchi.conf" + with_items: + - "gnocchi-api" diff --git a/ansible/roles/gnocchi/tasks/deploy.yml b/ansible/roles/gnocchi/tasks/deploy.yml new file mode 100644 index 0000000000..df3d43d96d --- /dev/null +++ b/ansible/roles/gnocchi/tasks/deploy.yml @@ -0,0 +1,16 @@ +--- +- include: register.yml + when: inventory_hostname in groups['gnocchi-api'] + +- include: config.yml + when: inventory_hostname in groups['gnocchi-statsd'] or + inventory_hostname in groups['gnocchi-api'] or + inventory_hostname in groups['gnocchi-metricd'] + +- include: bootstrap.yml + when: inventory_hostname in groups['gnocchi-api'] + +- include: start.yml + when: inventory_hostname in groups['gnocchi-statsd'] or + inventory_hostname in groups['gnocchi-api'] or + inventory_hostname in groups['gnocchi-metricd'] diff --git a/ansible/roles/gnocchi/tasks/do_reconfigure.yml b/ansible/roles/gnocchi/tasks/do_reconfigure.yml new file mode 100644 index 0000000000..39798455c8 --- /dev/null +++ b/ansible/roles/gnocchi/tasks/do_reconfigure.yml @@ -0,0 +1,74 @@ +--- +- 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: gnocchi_api, group: gnocchi-api } + - { name: gnocchi_metricd, group: gnocchi-metricd } + - { name: gnocchi_statsd, group: gnocchi-statsd } + +- 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: gnocchi_api, group: gnocchi-api } + - { name: gnocchi_metricd, group: gnocchi-metricd } + - { name: gnocchi_statsd, group: gnocchi-statsd } + +# 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: gnocchi_api, group: gnocchi-api } + - { name: gnocchi_metricd, group: gnocchi-metricd } + - { name: gnocchi_statsd, group: gnocchi-statsd } + +- 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: gnocchi_api, group: gnocchi-api }, + { name: gnocchi_metricd, group: gnocchi-metricd }, + { name: gnocchi_statsd, group: gnocchi-statsd }] + - "{{ 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: gnocchi_api, group: gnocchi-api }, + { name: gnocchi_metricd, group: gnocchi-metricd }, + { name: gnocchi_statsd, group: gnocchi-statsd }] + - "{{ container_envs.results }}" + - "{{ check_results.results }}" diff --git a/ansible/roles/gnocchi/tasks/main.yml b/ansible/roles/gnocchi/tasks/main.yml new file mode 100644 index 0000000000..b017e8b4ad --- /dev/null +++ b/ansible/roles/gnocchi/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include: "{{ action }}.yml" diff --git a/ansible/roles/gnocchi/tasks/pull.yml b/ansible/roles/gnocchi/tasks/pull.yml new file mode 100644 index 0000000000..caefd8aaf6 --- /dev/null +++ b/ansible/roles/gnocchi/tasks/pull.yml @@ -0,0 +1,21 @@ +--- +- name: Pulling gnocchi-api image + kolla_docker: + action: "pull_image" + common_options: "{{ docker_common_options }}" + image: "{{ gnocchi_api_image_full }}" + when: inventory_hostname in groups['gnocchi-api'] + +- name: Pulling gnocchi-metricd image + kolla_docker: + action: "pull_image" + common_options: "{{ docker_common_options }}" + image: "{{ gnocchi_metricd_image_full }}" + when: inventory_hostname in groups['gnocchi-metricd'] + +- name: Pulling gnocchi-statsd image + kolla_docker: + action: "pull_image" + common_options: "{{ docker_common_options }}" + image: "{{ gnocchi_statsd_image_full }}" + when: inventory_hostname in groups['gnocchi-statsd'] diff --git a/ansible/roles/gnocchi/tasks/reconfigure.yml b/ansible/roles/gnocchi/tasks/reconfigure.yml new file mode 100644 index 0000000000..2191b65ecc --- /dev/null +++ b/ansible/roles/gnocchi/tasks/reconfigure.yml @@ -0,0 +1,6 @@ +--- +- include: do_reconfigure.yml + serial: "30%" + when: inventory_hostname in groups['gnocchi-api'] + or inventory_hostname in groups['gnocchi-metricd'] + or inventory_hostname in groups['gnocchi-statsd'] diff --git a/ansible/roles/gnocchi/tasks/register.yml b/ansible/roles/gnocchi/tasks/register.yml new file mode 100644 index 0000000000..5b60ff22f4 --- /dev/null +++ b/ansible/roles/gnocchi/tasks/register.yml @@ -0,0 +1,40 @@ +--- +- name: Creating the gnocchi service and endpoint + command: docker exec -t kolla_toolbox /usr/bin/ansible localhost + -m kolla_keystone_service + -a "service_name=gnocchi + service_type=metric + description='OpenStack Metric Service' + endpoint_region={{ openstack_region_name }} + url='{{ item.url }}' + interface='{{ item.interface }}' + region_name={{ openstack_region_name }} + auth={{ '{{ openstack_gnocchi_auth }}' }}" + -e "{'openstack_gnocchi_auth':{{ openstack_gnocchi_auth }}}" + register: gnocchi_endpoint + changed_when: "{{ gnocchi_endpoint.stdout.find('localhost | SUCCESS => ') != -1 and (gnocchi_endpoint.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" + until: gnocchi_endpoint.stdout.split()[2] == 'SUCCESS' + retries: 10 + delay: 5 + run_once: True + with_items: + - {'interface': 'admin', 'url': '{{ gnocchi_admin_endpoint }}'} + - {'interface': 'internal', 'url': '{{ gnocchi_internal_endpoint }}'} + - {'interface': 'public', 'url': '{{ gnocchi_public_endpoint }}'} + +- name: Creating the gnocchi project, user, and role + command: docker exec -t kolla_toolbox /usr/bin/ansible localhost + -m kolla_keystone_user + -a "project=service + user=gnocchi + password={{ gnocchi_keystone_password }} + role=admin + region_name={{ openstack_region_name }} + auth={{ '{{ openstack_gnocchi_auth }}' }}" + -e "{'openstack_gnocchi_auth':{{ openstack_gnocchi_auth }}}" + register: gnocchi_user + changed_when: "{{ gnocchi_user.stdout.find('localhost | SUCCESS => ') != -1 and (gnocchi_user.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" + until: gnocchi_user.stdout.split()[2] == 'SUCCESS' + retries: 10 + delay: 5 + run_once: True diff --git a/ansible/roles/gnocchi/tasks/start.yml b/ansible/roles/gnocchi/tasks/start.yml new file mode 100644 index 0000000000..98d54241c6 --- /dev/null +++ b/ansible/roles/gnocchi/tasks/start.yml @@ -0,0 +1,34 @@ +--- +- name: Starting gnocchi-api container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ gnocchi_api_image_full }}" + name: "gnocchi_api" + volumes: + - "{{ node_config_directory }}/gnocchi-api/:{{ container_config_directory }}/:ro" + - "gnocchi:/var/lib/gnocchi/" + - "kolla_logs:/var/log/kolla/" + when: inventory_hostname in groups['gnocchi-api'] + +- name: Starting gnocchi-metricd container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ gnocchi_metricd_image_full }}" + name: "gnocchi_metricd" + volumes: + - "{{ node_config_directory }}/gnocchi-metricd/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" + when: inventory_hostname in groups['gnocchi-metricd'] + +- name: Starting gnocchi-statsd container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ gnocchi_statsd_image_full }}" + name: "gnocchi_statsd" + volumes: + - "{{ node_config_directory }}/gnocchi-statsd/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" + when: inventory_hostname in groups['gnocchi-statsd'] diff --git a/ansible/roles/gnocchi/templates/gnocchi-api-paste.ini.j2 b/ansible/roles/gnocchi/templates/gnocchi-api-paste.ini.j2 new file mode 100644 index 0000000000..22b8c44b0c --- /dev/null +++ b/ansible/roles/gnocchi/templates/gnocchi-api-paste.ini.j2 @@ -0,0 +1,38 @@ +# Use gnocchi+noauth in the pipeline if you don't want keystone authentication +[pipeline:main] +pipeline = gnocchi+auth + +[composite:gnocchi+noauth] +use = egg:Paste#urlmap +/ = gnocchiversions +/v1 = gnocchiv1 + +[composite:gnocchi+auth] +use = egg:Paste#urlmap +/ = gnocchiversions +/v1 = gnocchiv1+auth + +[pipeline:gnocchiv1+auth] +pipeline = healthcheck keystone_authtoken gnocchiv1 + +[app:gnocchiversions] +paste.app_factory = gnocchi.rest.app:app_factory +root = gnocchi.rest.VersionsController + +[app:gnocchiv1] +paste.app_factory = gnocchi.rest.app:app_factory +root = gnocchi.rest.V1Controller + +[filter:healthcheck] +paste.filter_factory = oslo_middleware:Healthcheck.factory +path = /status +backends = disable_by_file + + +[filter:keystone_authtoken] +paste.filter_factory = keystonemiddleware.auth_token:filter_factory +oslo_config_project = gnocchi + +[filter:cors] +paste.filter_factory = oslo_middleware.cors:filter_factory +oslo_config_project = gnocchi diff --git a/ansible/roles/gnocchi/templates/gnocchi-api.json.j2 b/ansible/roles/gnocchi/templates/gnocchi-api.json.j2 new file mode 100644 index 0000000000..318807a9f7 --- /dev/null +++ b/ansible/roles/gnocchi/templates/gnocchi-api.json.j2 @@ -0,0 +1,20 @@ +{% set gnocchi_cmd = 'apache2' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd' %} +{% set gnocchi_dir = 'apache2/conf-enabled' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd/conf.d' %} +{ + "command": "{{ gnocchi_cmd }} -DFOREGROUND", + "config_files": [ + { + "source": "{{ container_config_directory }}/gnocchi.conf", + "dest": "/etc/gnocchi/gnocchi.conf", + "owner": "gnocchi", + "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/wsgi-gnocchi.conf", + "dest": "/etc/{{ gnocchi_dir }}/wsgi-gnocchi.conf", + "owner": "gnocchi", + "perm": "0644" + } + + ] +} diff --git a/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2 b/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2 new file mode 100644 index 0000000000..b4bfc3f29b --- /dev/null +++ b/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "gnocchi-metricd --logfile /var/log/kolla/gnocchi/gnocchi-metricd.log", + "config_files": [ + { + "source": "{{ container_config_directory }}/gnocchi.conf", + "dest": "/etc/gnocchi/gnocchi.conf", + "owner": "gnocchi", + "perm": "0600" + } + ] +} diff --git a/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2 b/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2 new file mode 100644 index 0000000000..c2c07f9d1c --- /dev/null +++ b/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "gnocchi-statsd --logfile /var/log/kolla/gnocchi/gnocchi-statsd.log", + "config_files": [ + { + "source": "{{ container_config_directory }}/gnocchi.conf", + "dest": "/etc/gnocchi/gnocchi.conf", + "owner": "gnocchi", + "perm": "0600" + } + ] +} diff --git a/ansible/roles/gnocchi/templates/gnocchi.conf.j2 b/ansible/roles/gnocchi/templates/gnocchi.conf.j2 new file mode 100644 index 0000000000..6493343b0b --- /dev/null +++ b/ansible/roles/gnocchi/templates/gnocchi.conf.j2 @@ -0,0 +1,48 @@ +[DEFAULT] +debug = {{ gnocchi_logging_debug }} + +log_dir = /var/log/kolla/gnocchi + + +[api] +port = {{ gnocchi_api_port }} +host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} +middlewares = keystonemiddleware.auth_token.AuthProtocol + + +[database] +connection = mysql+pymysql://{{ gnocchi_database_user }}:{{ gnocchi_database_password }}@{{ gnocchi_database_address }}/{{ gnocchi_database_name }} +max_pool_size = 50 +max_overflow = 1000 +max_retries = -1 + +[statsd] +resource_id = {{ gnocchi_resource_id }} +user_id = {{ gnocchi_user_id }} +project_id = {{ gnocchi_project_id }} +archive_policy_name = low + +flush_delay=10 + + +[indexer] +url = mysql+pymysql://{{ gnocchi_database_user }}:{{ gnocchi_database_password }}@{{ gnocchi_database_address }}/{{ gnocchi_database_name }} + + +[keystone_authtoken] +auth_uri = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_public_port }}/v3 +project_domain_id = default +project_name = service +user_domain_id = default +username = {{ gnocchi_keystone_user }} +password = {{ gnocchi_keystone_password }} +auth_url = {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }} +auth_type = password + +memcache_security_strategy = ENCRYPT +memcache_secret_key = {{ memcache_secret_key }} +memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %} + +[storage] +driver = file +file_basepath = /var/lib/gnocchi diff --git a/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 b/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 new file mode 100644 index 0000000000..c6bc624c98 --- /dev/null +++ b/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 @@ -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'] }}:{{ gnocchi_api_port }} + + + + ## Vhost docroot + DocumentRoot "/var/www/cgi-bin/gnocchi" + + ## Directories, there should at least be a declaration for /var/www/cgi-bin/gnocchi + + + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Require all granted + + + ## Logging + ErrorLog "/var/log/kolla/gnocchi/gnocchi_wsgi_error.log" + ServerSignature Off + CustomLog "/var/log/kolla/gnocchi/gnocchi_wsgi_access.log" combined + WSGIApplicationGroup %{GLOBAL} + WSGIDaemonProcess gnocchi group=gnocchi processes=2 threads=2 user=gnocchi + WSGIProcessGroup gnocchi + WSGIScriptAlias / "/var/www/cgi-bin/gnocchi/app" + diff --git a/ansible/roles/haproxy/templates/haproxy.cfg.j2 b/ansible/roles/haproxy/templates/haproxy.cfg.j2 index a4af2cafa4..a0bb55f10a 100644 --- a/ansible/roles/haproxy/templates/haproxy.cfg.j2 +++ b/ansible/roles/haproxy/templates/haproxy.cfg.j2 @@ -392,6 +392,22 @@ listen kibana_external {% endif %} {% endif %} +{% if enable_gnocchi | bool %} +listen gnocchi_api + bind {{ kolla_internal_vip_address }}:{{ gnocchi_api_port }} +{% for host in groups['gnocchi-api'] %} + server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ gnocchi_api_port }} check inter 2000 rise 2 fall 5 +{% endfor %} +{% if haproxy_enable_external_vip | bool %} + +listen gnocchi_api_external + bind {{ kolla_external_vip_address }}:{{ gnocchi_api_port }} {{ tls_bind_info }} +{% for host in groups['gnocchi-api'] %} + server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ gnocchi_api_port }} check inter 2000 rise 2 fall 5 +{% endfor %} +{% endif %} +{% endif %} + {% if enable_elasticsearch | bool %} listen elasticsearch option dontlog-normal diff --git a/ansible/roles/prechecks/tasks/port_checks.yml b/ansible/roles/prechecks/tasks/port_checks.yml index 91a0305a3c..482bc41b19 100644 --- a/ansible/roles/prechecks/tasks/port_checks.yml +++ b/ansible/roles/prechecks/tasks/port_checks.yml @@ -39,6 +39,22 @@ state: stopped when: inventory_hostname in groups['glance-registry'] +- name: Checking free port for Gnocchi API + wait_for: + host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}" + port: "{{ gnocchi_api_port }}" + connect_timeout: 1 + state: stopped + when: inventory_hostname in groups['gnocchi-api'] + +- name: Checking free port for Gnocchi API HAProxy + wait_for: + host: "{{ kolla_internal_vip_address }}" + port: "{{ gnocchi_api_port }}" + connect_timeout: 1 + state: stopped + when: inventory_hostname in groups['haproxy'] + - name: Checking free port for Glance Registry HAProxy wait_for: host: "{{ kolla_internal_vip_address }}" diff --git a/ansible/site.yml b/ansible/site.yml index 5508c4f222..7bec545b87 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -216,6 +216,15 @@ tags: manila, when: enable_manila | bool } +- hosts: + - gnocchi-api + - gnocchi-metricd + - gnocchi-statsd + roles: + - { role: gnocchi, + tags: gnocchi, + when: enable_gnocchi | bool } + - hosts: - ceilometer - compute diff --git a/etc/kolla/passwords.yml b/etc/kolla/passwords.yml index 1817baec4b..b635c6851c 100644 --- a/etc/kolla/passwords.yml +++ b/etc/kolla/passwords.yml @@ -30,6 +30,9 @@ keystone_database_password: glance_database_password: glance_keystone_password: +gnocchi_database_password: +gnocchi_keystone_password: + nova_database_password: nova_api_database_password: nova_keystone_password: @@ -95,6 +98,13 @@ bifrost_ssh_key: private_key: public_key: +#################### +# Gnocchi options +#################### +gnocchi_project_id: +gnocchi_resource_id: +gnocchi_user_id: + #################### # RabbitMQ options #################### diff --git a/kolla/cmd/genpwd.py b/kolla/cmd/genpwd.py index 60b6d55955..288b35036b 100755 --- a/kolla/cmd/genpwd.py +++ b/kolla/cmd/genpwd.py @@ -40,7 +40,9 @@ def main(): passwords_file = os.path.expanduser(args.passwords) # These keys should be random uuids - uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid'] + uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid', + 'gnocchi_project_id', 'gnocchi_resource_id', + 'gnocchi_user_id'] # SSH key pair ssh_keys = ['kolla_ssh_key', 'nova_ssh_key', diff --git a/releasenotes/notes/add-gnocchi-94296c3ed6e979a8.yaml b/releasenotes/notes/add-gnocchi-94296c3ed6e979a8.yaml new file mode 100644 index 0000000000..4e76f085cf --- /dev/null +++ b/releasenotes/notes/add-gnocchi-94296c3ed6e979a8.yaml @@ -0,0 +1,3 @@ +--- +features: + - Implement Gnocchi ansible role