From 0e4da819fd4cfb86c18d5e6747deec38e6d8981c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Thu, 28 Jun 2018 09:56:48 +0200 Subject: [PATCH] Fix monasca MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures the dependencies on the monasca roles are deployed after the initial deploy steps of monasca. This allows us to install on the host the packages required for the extra roles, until they are fixed. Moreover, the grafana-ansible role is being moved to ansible-grafana from cloudalchemy repository. Change-Id: I9381c4994e38933fd12c02c673bfe409daf2a59c Co-Authored-By: Guilherme Steinmüller --- defaults/main.yml | 8 ++- examples/monasca-dependencies.yml | 71 +++++++++++++++++++ examples/playbook.yml | 7 ++ extras/ansible-role-requirements.yml | 16 ----- extras/user_secrets.yml | 1 + library/monasca_alarm_definition.py | 14 +--- library/monasca_notification_method.py | 14 +--- meta/main.yml | 39 ---------- tasks/monasca_alarms_setup.yml | 16 +++++ tasks/monasca_influxdb_setup.yml | 3 +- templates/monasca-thresh/thresh-config.yml.j2 | 4 +- tests/ansible-role-requirements.yml | 6 +- tests/group_vars/monasca_all.yml | 2 + tests/test-install-monasca.yml | 2 + zuul.d/project.yaml | 4 +- 15 files changed, 116 insertions(+), 91 deletions(-) create mode 100644 examples/monasca-dependencies.yml delete mode 100644 extras/ansible-role-requirements.yml diff --git a/defaults/main.yml b/defaults/main.yml index 991c8ff..85fb677 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -71,9 +71,9 @@ monasca_system_shell: /bin/false monasca_system_comment: monasca system user monasca_system_user_home: "/var/lib/{{ monasca_system_user_name }}" -## DB info -magnum_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" -magnum_galera_address: "{{ galera_address | default('127.0.0.1') }}" +## Database info +monasca_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" +monasca_galera_address: "{{ galera_address | default('127.0.0.1') }}" monasca_galera_database: monasca monasca_galera_user: monasca @@ -276,6 +276,7 @@ monasca_pip_packages: - PyOpenSSL - python-monascaclient - python-memcached + - future ## Service Names monasca_services: @@ -320,3 +321,4 @@ monasca_persister_config_overrides: {} monasca_persister_logging_config_overrides: {} monasca_thresh_config_overrides: {} monasca_notification_config_overrides: {} + diff --git a/examples/monasca-dependencies.yml b/examples/monasca-dependencies.yml new file mode 100644 index 0000000..a91f765 --- /dev/null +++ b/examples/monasca-dependencies.yml @@ -0,0 +1,71 @@ +--- +# Copyright 2018, SUSE LINUX GmbH. +# +# 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. +# +# (c) 2018 Jean-Philippe Evrard + +- name: Install ansible-zookeeper + hosts: monasca_zookeeper + roles: + - ansible-zookeeper + tags: + - zookeeper + - skip_ansible_lint + - monasca-install + +- name: Install ansible-kafka + hosts: monasca_kafka + roles: + - ansible-kafka + vars: + kafka_listen_address: "{{ ansible_host }}" + tags: + - kafka + - skip_ansible_lint + - monasca-install + +- name: Install ansible-storm + hosts: monasca_api + roles: + - ansible-storm + vars: + storm_nimbus_enabled: True + storm_supervisor_enabled: True + nimbus_host: "{{ ansible_ssh_host }}" + tags: + - storm + - skip_ansible_lint + - monasca-install + +- name: Install ansible-influxdb + hosts: monasca_influxdb + roles: + - ansible-influxdb + tags: + - influxdb + - skip_ansible_lint + - monasca-install + +- name: Install ansible-grafana + hosts: monasca_grafana + roles: + - ansible-grafana + vars: + grafana_security: + admin_user: admin + admin_password: "{{ monasca_grafana_password | default('password') }}" #TODO(evrardjp) remove this when ready + tags: + - grafana + - skip_ansible_lint + - monasca-install diff --git a/examples/playbook.yml b/examples/playbook.yml index 87c506d..a939d5a 100644 --- a/examples/playbook.yml +++ b/examples/playbook.yml @@ -11,6 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Please check your inventory to install the appropriate +# dependencies for your monasca install + +# Please also make sure the appropriate roles are installed. +- name: Install monasca dependencies + include: monasca-dependencies.yml + - name: Install monasca server hosts: monasca_all user: root diff --git a/extras/ansible-role-requirements.yml b/extras/ansible-role-requirements.yml deleted file mode 100644 index a77dba1..0000000 --- a/extras/ansible-role-requirements.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: ansible-zookeeper - scm: git - src: https://github.com/Chillisystems/ansible-zookeeper -- name: ansible-kafka - scm: git - src: https://github.com/flaviodsr/ansible-kafka -- name: ansible-storm - scm: git - src: https://github.com/flaviodsr/ansible-storm -- name: ansible-influxdb - scm: git - src: https://github.com/flaviodsr/ansible-influxdb -- name: grafana-ansible - scm: git - src: https://github.com/flaviodsr/grafana-ansible diff --git a/extras/user_secrets.yml b/extras/user_secrets.yml index 4d5dcce..7a2f8ab 100644 --- a/extras/user_secrets.yml +++ b/extras/user_secrets.yml @@ -1,6 +1,7 @@ --- grafana_admin_password: grafana_galera_password: +monasca_grafana_password: monasca_container_mysql_password: monasca_influxdb_admin_password: monasca_api_influxdb_password: diff --git a/library/monasca_alarm_definition.py b/library/monasca_alarm_definition.py index 2953987..a01efe0 100644 --- a/library/monasca_alarm_definition.py +++ b/library/monasca_alarm_definition.py @@ -144,17 +144,7 @@ import os # NOQA try: from monascaclient import client except ImportError: - # In many installs the python-monascaclient is available in a venv, switch - # to the most common location - activate_this = os.path.realpath( - '/opt/venvs/monasca-client/bin/activate_this.py') - try: - execfile(activate_this, dict(__file__=activate_this)) - from monascaclient import client - except ImportError: - monascaclient_found = False - else: - monascaclient_found = True + monascaclient_found = False else: monascaclient_found = True @@ -306,7 +296,7 @@ def main(): ) if not monascaclient_found: - module.fail_json(msg="python-monascaclient >= 1.6.1 is required") + module.fail_json(msg="python-monascaclient is required") definition = MonascaDefinition(module) definition.run() diff --git a/library/monasca_notification_method.py b/library/monasca_notification_method.py index bbf1fe3..e0e224a 100644 --- a/library/monasca_notification_method.py +++ b/library/monasca_notification_method.py @@ -120,17 +120,7 @@ import os # NOQA try: from monascaclient import client except ImportError: - # In many installs the python-monascaclient is available in a venv, switch - # to the most common location - activate_this = os.path.realpath( - '/opt/venvs/monasca-client/bin/activate_this.py') - try: - execfile(activate_this, dict(__file__=activate_this)) - from monascaclient import client - except ImportError: - monascaclient_found = False - else: - monascaclient_found = True + monascaclient_found = False else: monascaclient_found = True @@ -251,7 +241,7 @@ def main(): ) if not monascaclient_found: - module.fail_json(msg="python-monascaclient >= 1.6.1 is required") + module.fail_json(msg="python-monascaclient is required") notification = MonascaNotification(module) notification.run() diff --git a/meta/main.yml b/meta/main.yml index 4fef3ba..a60467e 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -40,42 +40,3 @@ dependencies: - role: apt_package_pinning when: - ansible_pkg_mgr == 'apt' - - role: ansible-zookeeper - when: - - inventory_hostname in groups['monasca_zookeeper'] - tags: - - zookeeper - - skip_ansible_lint - - role: ansible-kafka - kafka_listen_address: "{{ ansible_host }}" - when: - - inventory_hostname in groups['monasca_kafka'] - tags: - - kafka - - skip_ansible_lint - - role: ansible-storm - storm_nimbus_enabled: True - storm_supervisor_enabled: True - nimbus_host: "{{ ansible_ssh_host }}" - when: - - inventory_hostname in groups['monasca_api'] - tags: - - storm - - skip_ansible_lint - - role: ansible-influxdb - when: - - inventory_hostname in groups['monasca_influxdb'] - tags: - - influxdb - - skip_ansible_lint - - role: grafana-ansible - grafana_mysql_host: "{{ galera_address }}" - grafana_mysql_root_user: "{{ galera_root_user }}" - grafana_mysql_root_password: "{{ galera_root_password }}" - grafana_mysql_password: "{{ grafana_galera_password }}" - grafana_keystone_url: "{{ keystone_service_internaluri }}" - when: - - inventory_hostname in groups['monasca_grafana'] - tags: - - grafana - - skip_ansible_lint diff --git a/tasks/monasca_alarms_setup.yml b/tasks/monasca_alarms_setup.yml index 5b806fe..fd279df 100644 --- a/tasks/monasca_alarms_setup.yml +++ b/tasks/monasca_alarms_setup.yml @@ -32,6 +32,14 @@ monasca_api_url: "{{ monasca_service_internalurl }}" register: default_notification no_log: True + # TODO(evrardjp): Add conditional for deploy from + # packages to set the python_interpreter to the + # system's one. + # Make sure the module doesn't load the code on the + # target node, but inside target node's venv when + # deploying from source + vars: + ansible_python_interpreter: "{{ monasca_bin }}/python" - name: Create default alarm definitions monasca_alarm_definition: @@ -53,3 +61,11 @@ monasca_api_url: "{{ monasca_service_internalurl }}" with_items: "{{ monasca_default_alarms }}" no_log: True + # TODO(evrardjp): Add conditional for deploy from + # packages to set the python_interpreter to the + # system's one. + # Make sure the module doesn't load the code on the + # target node, but inside target node's venv when + # deploying from source + vars: + ansible_python_interpreter: "{{ monasca_bin }}/python" diff --git a/tasks/monasca_influxdb_setup.yml b/tasks/monasca_influxdb_setup.yml index ea03041..dc22ef4 100644 --- a/tasks/monasca_influxdb_setup.yml +++ b/tasks/monasca_influxdb_setup.yml @@ -42,11 +42,10 @@ influxdb_user: hostname: "{{ monasca_influxdb_host }}" port: "{{ monasca_influxdb_port }}" - database_name: "{{ monasca_influxdb_database }}" username: "{{ monasca_influxdb_admin }}" password: "{{ monasca_influxdb_admin_password }}" user_name: "{{ item.username }}" - user_pass: "{{ item.password }}" + user_password: "{{ item.password }}" with_items: - "{{ monasca_influxdb_users }}" no_log: True diff --git a/templates/monasca-thresh/thresh-config.yml.j2 b/templates/monasca-thresh/thresh-config.yml.j2 index d295964..66164b1 100644 --- a/templates/monasca-thresh/thresh-config.yml.j2 +++ b/templates/monasca-thresh/thresh-config.yml.j2 @@ -109,8 +109,8 @@ sporadicMetricNamespaces: - foo database: - driverClass: "com.mysql.jdbc.jdbc2.optional.MysqlDataSource" - url: "jdbc:mysql://{{ monasca_galera_address }}/{{ monasca_galera_database }}?useSSL=true" + driverClass: "org.drizzle.jdbc.DrizzleDriver" + url: "jdbc:drizzle://{{ monasca_galera_address }}:3306/{{ monasca_galera_database }}" user: "{{ monasca_galera_user }}" password: "{{ monasca_container_mysql_password }}" properties: diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index 4cbb383..8e5a897 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -60,11 +60,11 @@ scm: git version: master - name: ansible-influxdb - src: https://github.com/flaviodsr/ansible-influxdb + src: https://github.com/guilhermesteinmuller/ansible-influxdb.git scm: git version: master -- name: grafana-ansible - src: https://github.com/flaviodsr/grafana-ansible +- name: ansible-grafana + src: https://github.com/cloudalchemy/ansible-grafana scm: git version: master - name: systemd_service diff --git a/tests/group_vars/monasca_all.yml b/tests/group_vars/monasca_all.yml index ab4b393..7cc6c33 100644 --- a/tests/group_vars/monasca_all.yml +++ b/tests/group_vars/monasca_all.yml @@ -14,6 +14,8 @@ influxdb_host: "{{ internal_lb_vip_address }}" influxdb_port: 8086 +zookeeper_client_port: 2181 zookeeper_hosts: "{% for host in groups['monasca_zookeeper'] %}{{ hostvars[host]['ansible_host'] }}:{{ zookeeper_client_port }}{% if not loop.last %},{% endif %}{% endfor %}" +kafka_port: 9092 kafka_hosts: "{% for host in groups['monasca_kafka'] %}{{ hostvars[host]['ansible_host'] }}:{{ kafka_port }}{% if not loop.last %},{% endif %}{% endfor %}" diff --git a/tests/test-install-monasca.yml b/tests/test-install-monasca.yml index f336878..3fa4ac8 100644 --- a/tests/test-install-monasca.yml +++ b/tests/test-install-monasca.yml @@ -16,6 +16,8 @@ # (c) 2016 Donovan Francesco # (c) 2016 Paul Stevens +- include: "{{ playbook_dir }}/../examples/monasca-dependencies.yml" + - name: Install monasca server hosts: monasca_all remote_user: root diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 3030723..5c45f71 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -17,8 +17,8 @@ check: jobs: - openstack-ansible-linters - - openstack-ansible-functional-ubuntu-xenial: - voting: false + - openstack-ansible-functional-ubuntu-xenial gate: jobs: - openstack-ansible-linters + - openstack-ansible-functional-ubuntu-xenial