File ardana-monasca-9.0+git.1589385256.7fbfaaf.obscpio of Package ardana-monasca

07070100000000000081A40000000000000000000000015EBC18280000005B000000000000000000000000000000000000003B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/.copyrightignoreREADME.md
roles/monasca-agent/files/sudoers
roles/monasca-api/templates/api-config.conf.j2
07070100000001000081A40000000000000000000000015EBC18280000007A000000000000000000000000000000000000003500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/.gitreview[gerrit]
host=gerrit.prv.suse.net
port=29418
project=ardana/monasca-ansible.git
defaultremote=ardana
defaultbranch=master
07070100000002000081A40000000000000000000000015EBC18280000000C000000000000000000000000000000000000003800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/.rsync-filter- ardana-ci
07070100000003000081A40000000000000000000000015EBC18280000279F000000000000000000000000000000000000003200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/LICENSE
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

07070100000004000081A40000000000000000000000015EBC18280000008A000000000000000000000000000000000000003400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/README.md# Monasca Ansible playbooks and roles for use with Ardana
The Monasca team maintains public Ansible roles for use in installing Monasca. 
07070100000005000081A40000000000000000000000015EBC1828000002EB000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/_monasca-agent-schedule-restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
# Schedule a restart of monasca-agent services
# using ardana_notify_... variables
- hosts: all
  tasks:
    - include: roles/monasca-agent/tasks/_schedule_restart.yml07070100000006000081A40000000000000000000000015EBC182800000453000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/_monasca-schedule-restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
# Schedule a restart of monasca services using ardana_notify_... variables
- hosts: all
  tasks:
    - include: roles/kafka/tasks/_schedule_restart.yml
    - include: roles/influxdb/tasks/_schedule_restart.yml
    - include: roles/monasca-api/tasks/_schedule_restart.yml
    - include: roles/monasca-persister/tasks/_schedule_restart.yml
    - include: roles/monasca-notification/tasks/_schedule_restart.yml
    - include: roles/storm/tasks/_schedule_restart.yml
    - include: roles/monasca-thresh/tasks/_schedule_restart.yml
07070100000007000081A40000000000000000000000015EBC1828000002E1000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/_zookeeper-schedule-restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
# Schedule a restart of zookeeper services using ardana_notify_... variables
- hosts: all
  tasks:
    - include: roles/zookeeper/tasks/_schedule_restart.yml07070100000008000041ED0000000000000000000000045EBC182800000000000000000000000000000000000000000000003400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci07070100000009000041ED0000000000000000000000035EBC182800000000000000000000000000000000000000000000003C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/project0707010000000A000041ED0000000000000000000000035EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/project/input-model0707010000000B000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/project/input-model/data0707010000000C000081A40000000000000000000000015EBC1828000006A0000000000000000000000000000000000000005F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/project/input-model/data/control_plane.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
  product:
    version: 2

  control-planes:
    - name: ccp
      control-plane-prefix: ccp
      region-name: region1
      failure-zones:
        - AZ1
        - AZ2
        - AZ3

      common-service-components:
        - lifecycle-manager-target
        - monasca-agent

      clusters:
        - name: cluster0
          cluster-prefix: c0
          server-role:
            - SERVER1-ROLE
            - SERVER2-ROLE
            - SERVER3-ROLE
          member-count: 3
          allocation-policy: strict
          service-components:
            - lifecycle-manager
            - openstack-client
            - ntp-server
            - mysql
            - ip-cluster
            - keystone-api
            - keystone-client
            - rabbitmq
            - memcached
            - zookeeper
            - kafka
            - storm
            - monasca-api
            - monasca-persister
            - monasca-notifier
            - monasca-threshold
            - monasca-client
            - tempest
            - monasca-liveness-check
0707010000000D000081A40000000000000000000000015EBC1828000005D4000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/project/input-model/data/servers.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
  product:
    version: 2

  baremetal:
    netmask: 255.255.255.0
    subnet: 192.168.110.0
    server-interface: eth2

  servers:

    - id: server1
      ip-addr: 192.168.110.3
      role: SERVER1-ROLE
      server-group: RACK1
      mac-addr: b2:72:8d:ac:7c:6f
      ilo-ip: 192.168.109.3
      ilo-password: password
      ilo-user: admin
      nic-mapping: VAGRANT

    - id: server2
      ip-addr: 192.168.110.4
      role: SERVER2-ROLE
      server-group: RACK2
      mac-addr: 8a:8e:64:55:43:76
      ilo-ip: 192.168.109.4
      ilo-password: password
      ilo-user: admin
      nic-mapping: VAGRANT

    - id: server3
      ip-addr: 192.168.110.5
      role: SERVER3-ROLE
      server-group: RACK3
      mac-addr: 26:67:3e:49:5a:a7
      ilo-ip: 192.168.109.5
      ilo-password: password
      ilo-user: admin
      nic-mapping: VAGRANT
0707010000000E000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests0707010000000F000081ED0000000000000000000000015EBC182800000DDA000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/test-plan.yaml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Validate monasca smoketest
  logfile: testsuite-initial-monasca-smoketest.log
  prefix: smoketest-monasca
  exec:
    - validate-monasca-smoke.bash

- name: Test monasca stop
  logfile: testsuite-stop-monasca.log
  prefix: stop-monasca
  playbooks:
    - monasca-stop.yml

- name: Validate monasca down
  logfile: testsuite-stop-monasca.log
  prefix: validate-monasca-down
  exec:
    - validate-monasca-down.bash

- name: Test zookeeper stop
  logfile: testsuite-stop-zookeeper.log
  prefix: stop-zookeeper
  playbooks:
    - zookeeper-stop.yml

- name: Validate zookeeper down
  logfile: testsuite-stop-zookeeper.log
  prefix: stop-zookeeper
  exec:
    - validate-zookeeper-down.bash

- name: Test zookeeper start
  logfile: testsuite-start-zookeeper.log
  prefix: start-zookeeper
  playbooks:
    - zookeeper-start.yml

- name: Validate zookeeper up
  logfile: testsuite-start-zookeeper.log
  prefix: start-zookeeper
  exec:
    - validate-zookeeper-up.bash

- name: Test zookeeper reconfigure
  logfile: testsuite-reconfigure-zookeeper.log
  prefix: reconfigure-zookeeper
  playbooks:
    - zookeeper-reconfigure.yml

- name: Validate zookeeper up
  logfile: testsuite-reconfigure-zookeeper.log
  prefix: reconfigure-zookeeper
  exec:
    - validate-zookeeper-up.bash

- name: Test monasca start
  logfile: testsuite-start-monasca.log
  prefix: start-monasca
  playbooks:
    - monasca-start.yml

- name: Validate monasca up
  logfile: testsuite-start-monasca.log
  prefix: start-monasca
  exec:
    - validate-monasca-up.bash

- name: Test monasca reconfigure
  logfile: testsuite-reconfigure-monasca.log
  prefix: reconfigure-monasca
  playbooks:
    - monasca-reconfigure.yml

- name: Validate monasca up
  logfile: testsuite-reconfigure-monasca.log
  prefix: reconfigure-monasca
  exec:
    - validate-monasca-up.bash

- name: Validate monasca smoketest
  logfile: testsuite-reconfigure-monasca-smoketest.log
  prefix: smoketest-monasca
  exec:
    - validate-monasca-smoke.bash

- name: Test monasca agent stop
  logfile: testsuite-stop-agent.log
  prefix: stop-monasca-agent
  playbooks:
    - monasca-agent-stop.yml

- name: Validate monasca agent down
  logfile: testsuite-stop-agent.log
  prefix: stop-monasca-agent
  exec:
    - validate-monasca-agent-down.bash

- name: Test monasca agent start
  logfile: testsuite-start-agent.log
  prefix: start-monasca-agent
  playbooks:
    - monasca-agent-start.yml

- name: Validate monasca agent up
  logfile: testsuite-start-agent.log
  prefix: start-monasca-agent
  exec:
    - validate-monasca-agent-up.bash

- name: Test monasca agent reconfigure
  logfile: testsuite-reconfigure-agent.log
  prefix: reconfigure-monasca-agent
  playbooks:
    - monasca-agent-reconfigure.yml

- name: Validate monasca agent up
  logfile: testsuite-agent-reconfigure.log
  prefix: reconfigure-monasca-agent
  exec:
    - validate-monasca-agent-up.bash
07070100000010000081ED0000000000000000000000015EBC18280000036A000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-monasca-agent-down.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts monasca-agent-status.yml
monasca_agent_status=$?
echo "Monasca Agent Status is $monasca_agent_status"
if [ $monasca_agent_status -eq 0 ]
then
  echo "Fail"
  exit 1
else
  echo "OK"
fi
07070100000011000081ED0000000000000000000000015EBC18280000036A000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-monasca-agent-up.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts monasca-agent-status.yml
monasca_agent_status=$?
echo "Monasca Agent Status is $monasca_agent_status"
if [ $monasca_agent_status -eq 0 ]
then
  echo "OK"
else
  echo "Fail"
  exit 1
fi
07070100000012000081ED0000000000000000000000015EBC18280000034C000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-monasca-down.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts monasca-status.yml
monasca_status=$?
echo "Monasca Status is $monasca_status"
if [ $monasca_status -eq 0 ]
then
  echo "Fail"
  exit 1
else
  echo "OK"
fi
07070100000013000081ED0000000000000000000000015EBC182800000359000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-monasca-smoke.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts monasca-smoketest.yml
monasca_status=$?
echo "Monasca smoketest status is $monasca_status"
if [ $monasca_status -eq 0 ]
then
  echo "OK"
else
  echo "Fail"
  exit 1
fi
07070100000014000081ED0000000000000000000000015EBC18280000034C000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-monasca-up.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts monasca-status.yml
monasca_status=$?
echo "Monasca Status is $monasca_status"
if [ $monasca_status -eq 0 ]
then
  echo "OK"
else
  echo "Fail"
  exit 1
fi
07070100000015000081ED0000000000000000000000015EBC182800000356000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-zookeeper-down.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts zookeeper-status.yml
zookeeper_status=$?
echo "Zookeeper Status is $zookeeper_status"
if [ $zookeeper_status -eq 0 ]
then
  echo "Fail"
  exit 1
else
  echo "OK"
fi
07070100000016000081ED0000000000000000000000015EBC182800000356000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/ardana-ci/tests/validate-zookeeper-up.bash#!/bin/bash
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

ansible-playbook -i hosts/verb_hosts zookeeper-status.yml
zookeeper_status=$?
echo "Zookeeper Status is $zookeeper_status"
if [ $zookeeper_status -eq 0 ]
then
  echo "OK"
else
  echo "Fail"
  exit 1
fi
07070100000017000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/config07070100000018000081A40000000000000000000000015EBC18280000074E000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/config/monasca-symlinks.yml# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.

---
symlinks:
    "monasca/configuration.yml": "roles/monasca-variables/vars/configuration.yml"
    "monasca/api-config.yml.j2": "roles/monasca-api/templates/api-config.yml.j2"
    "monasca/notification.yaml.j2": "roles/monasca-notification/templates/notification.yaml.j2"
    "monasca/influxdb.conf.j2": "roles/influxdb/templates/influxdb.conf.j2"
    "monasca/storm.yaml.j2": "roles/storm/templates/storm.yaml.j2"
    "monasca/thresh-cluster.xml.j2": "roles/storm/templates/cluster.xml.j2"
    "monasca/thresh-config.yml.j2": "roles/monasca-thresh/templates/thresh-config.yml.j2"
    "monasca/kafka.conf.j2": "roles/kafka/templates/kafka.conf.j2"
    "monasca/kafka.server.properties.j2": "roles/kafka/templates/server.properties.j2"
    "monasca/kafka.log4j.properties.j2": "roles/kafka/templates/log4j.properties.j2"
    "monasca/zoo.cfg.j2": "roles/zookeeper/templates/zoo.cfg.j2"
    "monasca/zookeeper.log4j.properties.j2": "roles/zookeeper/templates/log4j.properties.j2"
    "monasca/plugin.yaml.j2": "roles/monasca-agent/templates/plugin.yaml.j2"
    "monasca/persister-config.yml.j2": "roles/monasca-persister/templates/persister-config.yml.j2"
    "monasca/agent-defaults.yml": "roles/monasca-agent/defaults/main.yml"
07070100000019000081A40000000000000000000000015EBC1828000002D6000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/config/zookeeper-symlinks.yml# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.

---
symlinks:
    "zookeeper/configuration.yml": "roles/zookeeper/vars/configuration.yml"
0707010000001A000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/filter_plugins0707010000001B000081A40000000000000000000000015EBC18280000077F000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/filter_plugins/systemctl_status.py#
# (c) Copyright 2020 SUSE LLC
#
# 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.
#

from exceptions import KeyError, ValueError

# given a result object from running a systemctl status for a service
# return true if the Active line indicates one of "active (running)",
# "active (exited)" or "inactive (dead)" with the appropriate command
# exit status.
def active_or_dead(result):
    if not result.has_key('cmd'):
        raise KeyError("Not a shell or command action result")
    if (('systemctl' not in result['cmd']) and
        ('status' not in result['cmd'])):
        raise ValueError("Not a systemctl status command")

    active_lines = [l for l in result['stdout'].splitlines()
                    if l.strip().startswith('Active: ')]
    if len(active_lines) > 1:
        raise ValueError("Multiple 'Active:' lines detected")
    elif len(active_lines) < 1:
        raise ValueError("No 'Active:' lines detected")

    active_line = active_lines[0]

    if (((": active (exited)" in active_line) or
        (": active (running)" in active_line)) and
        (int(result['rc']) == 0)):
        return True

    if (": inactive (dead)" in active_line) and int(result['rc']) != 0:
        return True

    return False


def test():
    pass


class FilterModule(object):
    def filters(self):
        return {
            'systemctl_active_or_dead': active_or_dead
        }


if __name__ == "__main__":
    test()
0707010000001C000081A40000000000000000000000015EBC1828000006C7000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/kafka-configure-monasca.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Kafka Monasca Agent detection plugin
  hosts: FND-KFK:&MON-AGN
  become: yes
  tags: [kafka]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-agent, run_mode: Use, tags: [kafka]}
  tasks:
    - name: Check if config file exists
      stat:
        path: "{{ kafka_consumer_path }}"
      register: kafka_config_result
    - name: Fix obsolete config file
      lineinfile:
        dest: "{{ kafka_consumer_path }}"
        backrefs: True
        state: present
        regexp: '(^  name: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,4}(?!_monasca))$'
        line: '\1_monasca'
      when: kafka_config_result.stat.exists == True
    - name: Run Monasca Agent detection plugin for kafka
      monasca_agent_plugin:
        name: "kafka"
        args:
          1_alarm-state-transitions: alarm-state-transitions
          1_metrics: metrics
          monasca-notification: alarm-state-transitions
          thresh-event: events
          thresh-metric: metrics
          service_name: monasca
0707010000001D000081A40000000000000000000000015EBC182800000BB2000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-deploy.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- include: pbstart.yml
  vars:
    playbook_name: "monasca-agent-deploy.yml"

- name: Install the Monasca Agent on all systems
  hosts: MON-AGN
  become: yes
  tags: [monasca-agent]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-agent,
        monasca_virtualenv_dir: "{{ monasca_agent_virtualenv_dir }}",
        tags: [monasca-agent]}
  tasks:
    - name: Run Monasca Agent detection plugin for the monasca-agent processes
      monasca_agent_plugin:
        name="MonAgent"
        monasca_setup_path="{{monasca_setup_bin_dir}}/monasca-setup"
      register: monasca_agent_detection_result
      until: not monasca_agent_detection_result | failed
      retries: 5
      delay: 5
    - name: Run Monasca Agent detection plugin for ntp
      monasca_agent_plugin:
        name="ntp"
        monasca_setup_path="{{monasca_setup_bin_dir}}/monasca-setup"
      tags: [monasca-agent-ntp]
    - name: Determine if kdump directory exists
      stat: path=/sys/kernel/kexec_crash_loaded
      register: kdump_dir_result
    - name: Determine if kdump is configured
      command: cat /sys/kernel/kexec_crash_loaded
      register: kdump_config_result
      when: kdump_dir_result.stat.exists
    - name: Run Monasca Agent detection plugin for crash detection
      monasca_agent_plugin:
        name="crash"
        monasca_setup_path="{{monasca_setup_bin_dir}}/monasca-setup"
      tags: [monasca-agent-crash]
      when: "kdump_dir_result.stat.exists and '1' in kdump_config_result.stdout"

- name: Install the Monasca Agent libvirt plugin requirements on NOV-CMP (RPM)
  hosts: NOV-CMP:&MON-AGN
  tags: [monasca-agent]
  tasks:
    # these monasca-agent requirements are only on the compute nodes needed
    # that's why they are not in the openstack-monasca-agent package itself
    # Not needed for RHEL computes as monasca-agent is installed in venv
    - name: Install required packages for libvirt plugin (RPM)
      become: yes
      package:
        name: "{{ item }}"
        state: present
      with_items:
        - python-libvirt-python
        - python-novaclient
        - python-neutronclient
      when:
        - ansible_os_family | lower == 'suse'


- include: pbfinish.yml
  vars:
    playbook_name: "monasca-agent-deploy.yml"
0707010000001E000081A40000000000000000000000015EBC1828000002AD000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-reconfigure-credentials-change.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---

- include: monasca-agent-reconfigure.yml
0707010000001F000081A40000000000000000000000015EBC1828000002BB000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-reconfigure.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---

- include: monasca-agent-deploy.yml run_mode=Configure
07070100000020000081A40000000000000000000000015EBC182800000297000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
- include: _monasca-agent-schedule-restart.yml

- include: monasca-agent-start.yml
07070100000021000081A40000000000000000000000015EBC18280000037A000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-start.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Start the Monasca Agent on all systems
  hosts: MON-AGN
  become: yes
  vars:
    run_mode: Start
  roles:
    - { role: monasca-agent,
      monasca_virtualenv_dir: "{{ monasca_agent_virtualenv_dir }}",
      tags: [monasca-agent] }
07070100000022000081A40000000000000000000000015EBC1828000003D3000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-status.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-agent Status (on all systems)
  hosts: MON-AGN
  max_fail_percentage: 0
  tags: [monasca-agent]
  vars_files:
    - roles/monasca-agent/defaults/main.yml
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml,
        service_name: "{{ monasca_agent_service_name }}",
        become: yes }
07070100000023000081A40000000000000000000000015EBC182800000378000000000000000000000000000000000000004100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Stop the Monasca Agent on all systems
  hosts: MON-AGN
  become: yes
  vars:
    run_mode: Stop
  roles:
    - { role: monasca-agent,
      monasca_virtualenv_dir: "{{ monasca_agent_virtualenv_dir }}",
      tags: [monasca-agent] }
07070100000024000081A40000000000000000000000015EBC1828000002B8000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-agent-upgrade.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
- include: monasca-agent-deploy.yml run_mode=Upgrade
07070100000025000081A40000000000000000000000015EBC1828000005FD000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-cli-dev.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
# This playbook sets up a credentials file to ease use of the monasca cli, it should be run with --limit to only apply to select dev boxes
- name: Setup credentials for using the monasca cli
  hosts: all
  gather_facts: no
  vars:
    keystone_url: "{{KEY_API.advertises.vips.private[0].url}}/v3"
    monasca_user: "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_user }}"
    monasca_password: "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_password | quote }}"
    monasca_project: "{{KEY_API.vars.keystone_admin_tenant}}"
  tasks:
    - copy: dest="~/monasca-env.sh" content=". /opt/stack/service/monasca-agent/venv/bin/activate\nexport OS_USERNAME='{{monasca_user}}'\nexport OS_PASSWORD='{{monasca_password}}'\nexport OS_PROJECT_NAME='{{monasca_project}}'\nexport OS_AUTH_URL={{keystone_url}} \nexport OS_PROJECT_DOMAIN_NAME=Default \nexport OS_USERNAME_DOMAIN_NAME=Default"
07070100000026000081A40000000000000000000000015EBC1828000034BC000000000000000000000000000000000000003D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-deploy.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- include: pbstart.yml
  vars:
    playbook_name: "monasca-deploy.yml"

- name: Installs kafka
  hosts: FND-KFK
  become: yes
  tags: [kafka]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: kafka, tags: [kafka]}

- name: Installs kafka dynamic retention cron job
  hosts: FND-KFK--first-member
  become: yes
  tags: [kafka]
  vars_files:
    - roles/kafka/defaults/main.yml
    - roles/kafka/vars/main.yml
  tasks:
    - include: roles/kafka/tasks/dynamic-retention.yml
      when: run_mode == 'Configure' or run_mode == 'Install' or
            run_mode == 'Deploy' or run_mode == 'Upgrade'

- include: kafka-configure-monasca.yml

- name: Installs Influxdb
  hosts: FND-IDB
  become: yes
  tags: [influxdb]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: influxdb, when: database_type == 'influxdb', tags: [influxdb]}

- name: Set up mysql
  hosts: MON-API--first-member
  become: yes
  tags: [monasca-schema-mysql, monasca-schema]
  vars:
    influxdb_schema_enabled: False
    kafka_topics_enabled: False
    cassandra_schema_enabled: False
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-schema, tags: [monasca-schema-mysql, monasca-schema]}

- name: Sets up kafka
  hosts: FND-KFK--first-member
  become: yes
  tags: [monasca-schema-kafka, monasca-schema]
  vars:
    influxdb_schema_enabled: False
    kafka_topics_enabled: True
    mysql_schema_enabled: False
    winchester_schema_enabled: False
    cassandra_schema_enabled: False
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-schema, tags: [monasca-schema-kafka, monasca-schema]}

- name: Set up influxdb
  hosts: FND-IDB--first-member
  become: yes
  tags: [monasca-schema-influx, monasca-schema]
  vars:
    influxdb_schema_enabled: True
    kafka_topics_enabled: False
    mysql_schema_enabled: False
    winchester_schema_enabled: False
    cassandra_schema_enabled: False
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-schema, when: database_type == 'influxdb', tags: [monasca-schema-influx, monasca-schema]}

- name: Set up cassandra schema
  hosts: FND-CDB--first-member
  become: yes
  tags: [monasca-schema-cassandra, monasca-schema]
  vars:
    influxdb_schema_enabled: False
    kafka_topics_enabled: False
    mysql_schema_enabled: False
    winchester_schema_enabled: False
    cassandra_schema_enabled: True
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-schema, when: database_type == 'cassandra', tags: [monasca-schema-cassandra, monasca-schema]}

- name: Set up Cassandra Monasca Agent configuration
  hosts: FND-CDB
  become: yes
  tags: [cassandra]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: FND-CDB, when: database_type == 'cassandra', tags: [cassandra]}
  tasks:
    - name: Run Monasca Agent detection plugin for Cassandra
      monasca_agent_plugin:
        name="Cassandra"
        args="directory_names={{ FND_CDB.vars.cassandra_data_dir }},{{ FND_CDB.vars.cassandra_commit_log_dir }} process_username={{ FND_CDB.vars.cassandra_user }}"
      when: database_type == 'cassandra'

- name: Set up Monasca keystone users
  hosts: MON-API
  become: yes
  tags: [monasca-keystone]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
    - roles/ardana-monasca-keystone/defaults/main.yml
  tasks:
    - include: roles/ardana-monasca-keystone/tasks/main.yml
      ansible_python_interpreter: "{{KEY_CLI.vars.keystone_client_python_interpreter}}"

- name: Sets up Monasca API
  hosts: MON-API
  become: yes
  tags: [monasca-api]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-api, tags: [monasca-api]}
  tasks:
    - name: Run Monasca Agent detection plugin for the API
      monasca_agent_plugin: name="MonAPI"

- name: Sets up Monasca Persister
  hosts: MON-PST
  become: yes
  tags: [persister]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-persister, tags: [persister]}
  tasks:
    - name: Run Monasca Agent detection plugin for the persister
      monasca_agent_plugin: name="MonPersister"

- name: Sets up Monasca Notification Engine
  hosts: MON-NTF
  become: yes
  tags: [notification]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  roles:
    - {role: monasca-notification, tags: [notification]}
  tasks:
    - name: Run Monasca Agent detection plugin for the notifier
      monasca_agent_plugin: name="MonNotification"

- name: Sets up Monasca default alarms
  hosts: MON-API--first-member
  tags: [alarms]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  pre_tasks:
    - name: Compute Maximum Kafka Lag for Alarm Definitions
      set_fact:
        monasca_create_definitions: True
        monasca_kafka_alarms_max_lag: "{{ monasca_persister_alarm_threads | int *
                                          monasca_persister_alarm_batch_size | int *
                                          ( groups['MON-PST'] | length ) | int }}"
        monasca_kafka_persister_metrics_max_lag: "{{ ( monasca_persister_metric_threads | int *
                                                       monasca_persister_metric_batch_size | int *
                                                       ( groups['MON-PST'] | length ) | int * (3/2) ) | int }}"
  roles:
    - {role: monasca-default-alarms, tags: [alarms]}

- name: Stop Thresh and Storm on Upgrade of Storm
  hosts: MON-THR
  become: yes
  tags: [thresh, storm]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
    - roles/storm/vars/nodes.yml
    - roles/storm/defaults/main.yml
  tasks:
    - include: roles/storm/tasks/stop_on_upgrade.yml
      when:
        - run_mode == "Upgrade"

- name: Sets up Storm
  hosts: MON-THR
  become: yes
  tags: [thresh, storm]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  pre_tasks:
    - name: Install the monasca venv
      install_package: name=monasca service=monasca state=present
  roles:
    - {role: storm, tags: [storm, thresh]}

- name: Sets up Threshold engine
  hosts: MON-THR
  become: yes
  tags: [thresh]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
    - roles/monasca-thresh/vars/nodes.yml
  roles:
    - role: monasca-thresh
      tags: [thresh]
      when: thresh_start_enabled
  tasks:
    - name: Run Monasca Agent detection plugin for the Threshold engine
      monasca_agent_plugin:
        name="MonThresh"
        args="backtype.storm.daemon=true"

- name: Configure active host checks for all machines
  hosts: MON-LVC
  become: yes
  tags: [active_ping_checks]
  roles:
    - {role: monasca-agent, run_mode: Use}
  tasks:
      # Look in MON_LVC.consumes_MON_AGN.members.ping and find the entry
      # that matches the ardana_ansible_host for each compute nodes. They can
      # be different for multi homed hosts
    - name: Determine hostname and target hostname for each compute node
      set_fact:
        compute_node_hostname: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 selectattr('ardana_ansible_host','equalto', item) |
                 map(attribute='host_dimensions.hostname') | first }}
        compute_node_target_hostname: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 selectattr('ardana_ansible_host','equalto', item) |
                 map(attribute='host') | first }}
      register: compute_node_result
      with_items: groups | item((verb_hosts.NOV_CMP | default('')),default=[])
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1
      # Combine the compute node hostnames and target hostnames into lists
    - name: Create compute node hostnames and target hostnames lists
      set_fact:
        compute_node_hostnames: >
          {%- if not compute_node_result | skipped -%}
            {{ compute_node_result.results |
                 map(attribute='ansible_facts.compute_node_hostname') |
                   list }}
          {%- else -%}
            []
          {%- endif -%}
        compute_node_target_hostnames: >
          {%- if not compute_node_result | skipped -%}
            {{ compute_node_result.results |
                 map(attribute='ansible_facts.compute_node_target_hostname') |
                   list }}
          {%- else -%}
            []
          {%- endif -%}
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1
    - name: Get the lists for all hosts to have liveness checks
      set_fact:
         all_checked_hostnames: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 map(attribute='host_dimensions.hostname') | list }}
         all_checked_target_hostnames: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 map(attribute='host') | list }}
      # Look in MON_LVC.consumes_MON_AGN.members.ping and find the entry
      # that matches the ardana_ansible_host for this host. They can
      # be different for multi homed hosts
    - name: Determine the hostname and target hostname for this host
      set_fact:
         this_hostname: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 selectattr('ardana_ansible_host','equalto',inventory_hostname) |
                   map(attribute='host_dimensions.hostname') | first }}
         this_target_hostname: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 selectattr('ardana_ansible_host','equalto',inventory_hostname) |
                   map(attribute='host') | first }}
      # Have this system ping all nodes except itself and the compute nodes
    - name: Setup ping active checks for control hosts
      monasca_agent_plugin:
        name: "HostAlive"
        args:
          type: ping
          hostname: >
            {{ all_checked_hostnames |
                 difference([this_hostname]) |
                 difference(compute_node_hostnames) | join(',') }}
          target_hostname: >
            {{ all_checked_target_hostnames |
                 difference([this_target_hostname]) |
                 difference(compute_node_target_hostnames) | join(',') }}
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1 and
            (groups[verb_hosts.MON_LVC] | length) >= 1
      # Set up checks for compute nodes separately because they have a dimension
      # of service=compute
    - name: Setup ping active checks for compute hosts
      monasca_agent_plugin:
        name: "HostAlive"
        args:
          type: ping
          hostname:  "{{ compute_node_hostnames | join(',') }}"
          target_hostname:  "{{ compute_node_target_hostnames | join(',') }}"
          dimensions: "service:compute"
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1 and
            (compute_node_hostnames | length) > 0

- include: pbfinish.yml
  vars:
    playbook_name: "monasca-deploy.yml"
07070100000027000081A40000000000000000000000015EBC182800000EAF000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-post-upgrade.yml# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- hosts: FND-KFK:MON-API:MON-PST:MON-THR
  vars_files:
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  tasks:
  - name: monasca-post-upgrade | Remove OS specific packages
    become: yes
    package:
      name: "{{ item }}"
      state: absent
    with_items: monasca_post_upgrade_cleanup

- name: Stop monasca-api
  hosts: MON-API
  become: yes
  tags: [monasca-api]
  vars:
    run_mode: Stop
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-api, tags: [monasca-api]}

- name: Start monasca-api
  hosts: MON-API
  become: yes
  tags: [monasca-api]
  vars:
    run_mode: Start
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-api, tags: [monasca-api]}

- name: Delete Alarms for Old Storm Version
  hosts: MON-API
  tags: [alarms]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-default-alarms/defaults/main.yml
    - roles/monasca-api/defaults/main.yml
  roles:
    - { role: monasca-alarm-definition }
  tasks:
    - name: start | wait for api port
      wait_for: port={{monasca_api_client_port}} host={{monasca_api_bind_host | default('127.0.0.1') }} state=started timeout={{ monasca_wait_for_period }}
      when: verify

    - name: Clean up old Storm Alarms
      monasca_alarm_cleanup:
        alarm_definition_name: "Process Check"
        metric_dimensions:
          process_name: "backtype.storm.daemon.nimbus|backtype.storm.daemon.supervisor|backtype.storm.daemon.worker"
        keystone_url: "{{ monasca_keystone_url }}"
        keystone_user: "{{ monasca_keystone_user }}"
        keystone_password: "{{ monasca_keystone_password }}"
        keystone_project: "{{ monasca_keystone_project }}"
        keystone_project_domain: "{{ monasca_keystone_project_domain }}"
        keystone_user_domain: "{{ monasca_keystone_user_domain }}"
        monasca_api_url: "{{ monasca_api_url }}"
      run_once: True
      register: alarm_cleanup_result
      until: not alarm_cleanup_result | failed
      retries: "{{ monasca_client_retries }}"
      delay: "{{ monasca_client_retry_delay }}"

- hosts: all:!MON-API--first-member
  tags: [alarms]
  tasks:
  - name: cleanup | Remove old VM alarm cleanup from crontab
    cron:
      name: "Alarm cleanup for deleted VMs"
      minute: "*/5"
      job: "/opt/monasca/bin/vm_alarm_cleanup"
      state: absent
    become: yes
  - name: cleanup | Remove old VM alarm cleanup cron job file
    file:
      src: vm_alarm_cleanup.j2
      dest: /opt/monasca/bin/vm_alarm_cleanup
      state: absent
    become: yes

- hosts: all
  tags: [monasca-schema-mysql, monasca-schema]
  vars_files:
    - roles/monasca-schema/defaults/main.yml
  tasks:
    - name: monasca-schema | mysql | remove temporary files
      file:
        dest: "{{ item }}"
        state: absent
      with_items:
        - "{{ monasca_script_file }}"
        - "{{ monasca_schema_file }}"
07070100000028000081A40000000000000000000000015EBC182800000F10000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-pre-upgrade.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- hosts: FND-IDB
  become: yes
  vars_files:
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  tasks:
  - name:  monasca-pre-upgrade | Install aptitude in Debian
    become: yes
    apt:
      name: aptitude
      state: latest
      force: yes
    when: ansible_os_family | lower == 'debian'

- name: Delete Alarm Definitions from previous Ardana installs
  hosts: MON-API--first-member
  tags: [alarms]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-default-alarms/defaults/main.yml
  roles:
    - { role: monasca-alarm-definition }
  tasks:
  - name: monasca-pre-upgrade | Remove alarm definitions
    monasca_alarm_definition:
      name: "{{ item.name }}"
      state: "absent"
      keystone_url: "{{ monasca_keystone_url }}"
      keystone_user: "{{ monasca_keystone_user }}"
      keystone_password: "{{ monasca_keystone_password }}"
      keystone_project: "{{ monasca_keystone_project }}"
      keystone_project_domain: "{{ monasca_keystone_project_domain }}"
      keystone_user_domain: "{{ monasca_keystone_user_domain }}"
      monasca_api_url: "{{ monasca_api_url }}"
    with_items:
      - { name: "Kafka Consumer Lag" }
      - { name: "Monasca Agent Emit Time" }
      - { name: "Vertica Status" }

- name: Fix active host checks for all machines on Upgrade
  hosts: MON-LVC
  become: yes
  tags: [active_ping_checks]
  roles:
    - {role: monasca-agent, run_mode: Use}
  tasks:
    - name: Get hostnames and target hostnames for hosts with liveness checks
      set_fact:
         all_checked_hostnames: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 map(attribute='host_dimensions.hostname') | list }}
         all_checked_target_hostnames: >
            {{ MON_LVC.consumes_MON_AGN.members.ping |
                 map(attribute='host') | list }}
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1
    - name: Determine which ones have different names
      set_fact:
        names_to_remove: >
          {{ all_checked_target_hostnames | difference(all_checked_hostnames) }}
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1
    # Dimensions have to match for the entry to be removed. Rather
    # than spending the time to determine if a host is a compute
    # node, these tasks just try to remove the hosts with dimensions and
    # without dimensions and one of them will remove it
    - name: Remove incorrect ping active checks for control hosts
      monasca_agent_plugin:
        name: "HostAlive"
        state: absent
        args:
          type: ping
          hostname: "{{ names_to_remove | join(',') }}"
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1 and
            ((names_to_remove | length) > 1)
    - name: Remove ping incorrect active checks for compute nodes
      monasca_agent_plugin:
        name: "HostAlive"
        state: absent
        args:
          type: ping
          hostname: "{{ names_to_remove | join(',') }}"
          dimensions: "service:compute"
      when: (MON_LVC.consumes_MON_AGN.members.ping | length) > 1 and
            ((names_to_remove | length) > 1)
07070100000029000081A40000000000000000000000015EBC182800000CE5000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-reconfigure-credentials-change.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Change influxdb passwords if influxdb used
  hosts: FND-IDB--first-member
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/influxdb/defaults/main.yml
    - roles/influxdb/vars/main.yml
    - roles/monasca-schema/defaults/main.yml
  tasks:
    - include: roles/monasca-schema/tasks/influxdb-change-passwords.yml
      when: database_type == 'influxdb'

- name: Change cassandra passwords if cassandra used
  hosts: FND-CDB--first-member
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-schema/defaults/main.yml
  tasks:
    - include: roles/monasca-schema/tasks/cassandra-change-passwords.yml
      when: database_type == 'cassandra'

- name: Change Monasca keystone user passwords
  hosts: MON-API
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/ardana-monasca-keystone/defaults/main.yml
  tasks:
    - include: roles/ardana-monasca-keystone/tasks/change_passwords.yml
      ansible_python_interpreter:
        "{{ KEY_CLI.vars.keystone_client_python_interpreter }}"

- name: Change Monasca API passwords
  hosts: MON-API
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - { role: monasca-api, run_mode: Configure }

- name: Change Monasca Persister passwords
  hosts: MON-PST
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - { role: monasca-persister, run_mode: Configure }

- name: Change Monasca Notification Engine passwords
  hosts: MON-NTF
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - { role: monasca-notification, run_mode: Configure }

- name: Change Threshold engine passwords
  hosts: MON-THR
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-thresh/vars/nodes.yml
  roles:
    - role: monasca-thresh
      run_mode: Configure
      when: thresh_start_enabled

- name: Change passwords for VM alarm cleanup
  hosts: MON-API--first-member
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-default-alarms/defaults/main.yml
  tasks:
    - include: roles/monasca-default-alarms/tasks/cleanup.yml
0707010000002A000081A40000000000000000000000015EBC1828000002B5000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-reconfigure.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---

- include: monasca-deploy.yml run_mode=Configure
0707010000002B000081A40000000000000000000000015EBC18280000028B000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
- include: _monasca-schedule-restart.yml

- include: monasca-start.yml
0707010000002C000081A40000000000000000000000015EBC18280000038F000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-smoketest.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Runs Smoketest
  hosts: MON-API--first-member
  become: yes
  tags: [smoke]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  tasks:
    - include: roles/monasca-variables/tasks/smoke_test.yml
0707010000002D000081A40000000000000000000000015EBC1828000008B6000000000000000000000000000000000000003C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-start.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Start kafka
  hosts: FND-KFK
  become: yes
  tags: [kafka]
  vars:
    run_mode: Start
  roles:
    - {role: kafka, tags: [kafka]}

- name: Start influxdb
  hosts: FND-IDB
  become: yes
  tags: [influxdb]
  vars:
    run_mode: Start
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: influxdb, when: database_type == 'influxdb', tags: [influxdb]}

- name: Start monasca-api
  hosts: MON-API
  become: yes
  tags: [monasca-api]
  vars:
    run_mode: Start
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-api, tags: [monasca-api]}

- name: Start monasca-persister
  hosts: MON-PST
  become: yes
  tags: [persister]
  vars:
    run_mode: Start
  roles:
    - {role: monasca-persister, tags: [persister]}

- name: Start monasca-notification
  hosts: MON-NTF
  become: yes
  tags: [notification]
  vars:
    run_mode: Start
  roles:
    - {role: monasca-notification, tags: [notification]}

- name: Start storm
  hosts: MON-THR
  become: yes
  tags: [storm, thresh]
  vars:
    run_mode: Start
  roles:
    - {role: storm, tags: [storm, thresh]}

- name: Start monasca-thresh
  hosts: MON-THR
  become: yes
  tags: [thresh]
  vars:
    run_mode: Start
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-thresh/vars/nodes.yml
  roles:
    - {role: monasca-thresh, tags: [thresh], when: thresh_start_enabled}
0707010000002E000081A40000000000000000000000015EBC182800000CB3000000000000000000000000000000000000003D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-status.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: kafka Status
  hosts: FND-KFK
  max_fail_percentage: 0
  become: yes
  tags: [kafka]
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml, service_name: kafka}

- name: influxdb Status
  hosts: FND-IDB
  max_fail_percentage: 0
  become: yes
  tags: [influxdb]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml, service_name: influxdb, when: database_type=='influxdb'}

- name: cassandra Status
  hosts: FND-CDB
  max_fail_percentage: 0
  become: yes
  tags: [cassandra]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  tasks:
    - { include: roles/FND-CDB/tasks/status.yml, service_name: cassandra, when: database_type=='cassandra'}

- name: monasca-api Status
  hosts: MON-API
  max_fail_percentage: 0
  become: yes
  tags: [monasca-api]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml, service_name: monasca-api, when: monasca_api_implementation_lang == 'java' }

- name: monasca-persister Status
  hosts: MON-PST
  max_fail_percentage: 0
  become: yes
  tags: [monasca-persister]
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml, service_name: monasca-persister}

- name: monasca-notification Status
  hosts: MON-NTF
  max_fail_percentage: 0
  become: yes
  tags: [monasca-notification]
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml, service_name: monasca-notification}

- name: storm Status
  hosts: MON-THR
  max_fail_percentage: 0
  become: yes
  tags: [storm, thresh]
  vars_files:
    - roles/storm/defaults/main.yml
    - roles/storm/vars/nodes.yml
  tasks:
    - include: roles/monasca-variables/tasks/service_status.yml service_name=storm-nimbus
    - include: roles/monasca-variables/tasks/service_status.yml service_name=storm-supervisor
    - include: roles/monasca-variables/tasks/service_status.yml service_name=storm-ui
      when: storm_ui_enabled | bool
    - include: roles/monasca-variables/tasks/service_status.yml service_name=storm-logviewer
      when: storm_logviewer_enabled | bool

- name: monasca-thresh Status
  hosts: MON-THR
  max_fail_percentage: 0
  become: yes
  tags: [thresh]
  vars_files:
    - roles/monasca-thresh/vars/nodes.yml
  tasks:
    - include: roles/monasca-variables/tasks/service_status.yml service_name=monasca-thresh
      when: thresh_start_enabled | bool
0707010000002F000081A40000000000000000000000015EBC182800000B20000000000000000000000000000000000000003B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-stop.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Stop monasca-thresh
  hosts: MON-THR
  become: yes
  tags: [thresh]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-thresh/vars/nodes.yml
  vars:
    run_mode: Stop
  roles:
    - {role: monasca-thresh, tags: [thresh], when: thresh_start_enabled}

- name: Stop storm-supervisor
  hosts: MON-THR
  become: yes
  tags: [storm, thresh]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  vars:
    run_mode: Stop
  roles:
    - {role: storm, tags: [storm, thresh]}

- name: Stop storm-nimbus
  hosts: MON-THR
  become: yes
  tags: [storm, thresh]
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  vars:
    run_mode: Stop
  roles:
    - {role: storm, tags: [storm, thresh]}

- name: Stop monasca-notification
  hosts: MON-NTF
  become: yes
  tags: [notification]
  vars:
    run_mode: Stop
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-notification, tags: [notification]}

- name: Stop monasca-persister
  hosts: MON-PST
  become: yes
  tags: [persister]
  vars:
    run_mode: Stop
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-persister, tags: [persister]}

- name: Stop monasca-api
  hosts: MON-API
  become: yes
  tags: [monasca-api]
  vars:
    run_mode: Stop
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: monasca-api, tags: [monasca-api]}

- name: Stop influxdb
  hosts: FND-IDB
  become: yes
  tags: [influxdb]
  vars:
    run_mode: Stop
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
  roles:
    - {role: influxdb, when: database_type == 'influxdb', tags: [influxdb]}

- name: Stop kafka
  hosts: FND-KFK
  become: yes
  tags: [kafka]
  vars:
    run_mode: Stop
  roles:
    - {role: kafka, tags: [kafka]}
07070100000030000081A40000000000000000000000015EBC1828000002B2000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca-upgrade.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
- include: monasca-deploy.yml run_mode=Upgrade
07070100000031000081A40000000000000000000000015EBC1828000005C2000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/monasca_tune_libvirt_metrics.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Tune the Monasca Agent libvirt plugin.
  hosts: MON-AGN:&NOV-CMP
  become: yes
  vars_files:
    - roles/monasca-variables/vars/configuration.yml
    - roles/monasca-variables/defaults/main.yml
    - roles/monasca-agent/defaults/main.yml
  tasks:
    - name: Check if libvirt is configured
      stat: path=/etc/monasca/agent/conf.d/libvirt.yaml
      register: libvirt_status
    - name: Tune libvirt metrics
      shell: >
        {{ monasca_setup_bin_dir }}/monasca-setup
        -d libvirt
        --user '{{ monasca_agent_user_name }}'
        {% if monasca_libvirt_agent_detection_args is defined %} -a '{{monasca_libvirt_agent_detection_args}}' {% endif %}
        --agent_service_name '{{ monasca_agent_service_name }}'
        --overwrite
      when: libvirt_status.stat.exists
      ignore_errors: True
07070100000032000041ED0000000000000000000000125EBC182800000000000000000000000000000000000000000000003000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles07070100000033000041ED0000000000000000000000045EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone07070100000034000081A40000000000000000000000015EBC182800002C3D000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/LICENSEApache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   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.

07070100000035000081A40000000000000000000000015EBC1828000002A9000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/README.md#Ardana Monasca Keystone
Performs some Keystone setup for Monasca in Ardana.
This role adds one or more users/projects/roles to Keystone, as specified in mon_keystone_users:

```
mon_keystone_users:
  - username: monasca-agent
    password: some-password
    project: some-project
    role: monasca-agent
```
It also creates a Monasca endpoint in keystone.

Keystone Authentication:
Configure by setting `keystone_admin`, `keystone_admin_password`, and `keystone_admin_project`

##Requirements
- Server running OpenStack Keystone
- Hostname or IP of Monasca API server

##Optional

##License
Apache

##Author Information
Ryan Brandt

Monasca Team email monasca@lists.launchpad.net
07070100000036000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/defaults07070100000037000081A40000000000000000000000015EBC182800000A20000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---

keystone_admin: "{{KEY_API.vars.keystone_admin_user}}"
keystone_admin_password: "{{ KEY_API.vars.keystone_admin_pwd | quote }}"
keystone_default_domain_name: "{{ KEY_API.vars.keystone_default_domain }}"
keystone_admin_project: "{{KEY_API.vars.keystone_admin_tenant}}"
keystone_url: "{{KEY_API.advertises.vips.private[0].url}}/v3"
mon_keystone_users:
  - username: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_user}}"
    password: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_password| quote }}"
    project: "{{keystone_admin_project}}"
    role: monasca-user
  - username: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_user}}"
    password: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_password| quote }}"
    project: "{{keystone_admin_project}}"
    role: admin
  - username: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_user}}"
    password: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_password| quote }}"
    project: "{{keystone_admin_project}}"
    role: "{{KEY_API.vars.keystone_service_role}}"
  - username: "{{MON_AGN.consumes_KEY_API.vars.keystone_monasca_agent_user}}"
    password: "{{MON_AGN.consumes_KEY_API.vars.keystone_monasca_agent_password| quote }}"
    project: "{{keystone_admin_project}}"
    role: monasca-agent
  - username: "{{MON_AGN.consumes_KEY_API.vars.keystone_monasca_agent_user}}"
    password: "{{MON_AGN.consumes_KEY_API.vars.keystone_monasca_agent_password| quote }}"
    project: "{{keystone_admin_project}}"
    role: monitoring-delegate
  - username: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_read_only_user}}"
    password: "{{MON_API.consumes_KEY_API.vars.keystone_monasca_read_only_password| quote }}"
    project: "{{keystone_admin_project}}"
    role: monasca-read-only-user
  # include external monasca users below this line and exclude their passwords
  - username: "{{keystone_admin}}"
    project: "{{keystone_admin_project}}"
    role: monasca-user
07070100000038000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/tasks07070100000039000081A40000000000000000000000015EBC182800000694000000000000000000000000000000000000006300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/tasks/change_passwords.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
# These tasks need a Keystone v3 endpoint
- set_fact:
     keystone_url_v3: "{{ keystone_url | replace('/v2.0', '/v3') }}"

- name: ardana-monasca-keystone | change_passwords | Get keystone domain scoped token
  keystone_v3:
    endpoint: "{{ keystone_url_v3 }}"
    login_username: "{{ keystone_admin }}"
    login_password: "{{ keystone_admin_password }}"
    login_user_domain_name: "{{ keystone_default_domain_name }}"
    login_domain_name: "{{ keystone_default_domain_name }}"
    action: "token_get"
  run_once_per: verb_hosts.MON_API
  register: domain_scoped_token
 
- name: ardana-monasca-keystone | change_passwords | Update Monasca user passwords
  keystone_v3:
    login_token: "{{ domain_scoped_token.result }}"
    endpoint: "{{ keystone_url_v3 }}"
    action: "reset_password_by_admin"
    user_name: "{{ item.username }}"
    user_password: "{{ item.password }}"
    user_domain_name: "Default"
  no_log: True
  run_once_per: verb_hosts.MON_API
  with_items: "{{ mon_keystone_users }}"
  when: item.password is defined
0707010000003A000081A40000000000000000000000015EBC182800000B5B000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/ardana-monasca-keystone/tasks/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
# These tasks need a Keystone v3 endpoint
- set_fact:
     keystone_url_v3: "{{ keystone_url | replace('/v2.0', '/v3') }}"
  run_once_per: verb_hosts.MON_API

- name: Keystone Service - Get keystone domain scoped tokens
  keystone_v3:
    endpoint: "{{ keystone_url_v3 }}"
    login_username: "{{ keystone_admin }}"
    login_password: "{{ keystone_admin_password }}"
    login_user_domain_name: "{{ keystone_default_domain_name }}"
    login_domain_name: "{{ keystone_default_domain_name }}"
    action: "token_get"
  run_once_per: verb_hosts.MON_API
  register: domain_scoped_token

- name: Keystone Service - Define Monasca tenant(s)
  become: yes
  keystone_v3:
    login_token: "{{ domain_scoped_token.result }}"
    endpoint: "{{ keystone_url_v3 }}"
    action: "create_project"
    project_name: "{{ item.project }}"
    project_domain_name: "Default"
    description: "Create Monasca tenants"
  no_log: True
  run_once_per: verb_hosts.MON_API
  with_items: "{{ mon_keystone_users }}"

- name: Keystone - Define Monasca roles
  keystone_v3:
    login_token: "{{ domain_scoped_token.result }}"
    endpoint: "{{ keystone_url_v3 }}"
    action: "create_role"
    role_name: "{{ item.role }}"
    description: "Create Monasca user roles"
  no_log: True
  run_once_per: verb_hosts.MON_API
  with_items: "{{ mon_keystone_users }}"

- name: Keystone - Define Monasca users
  become: yes
  keystone_v3:
    login_token: "{{ domain_scoped_token.result }}"
    endpoint: "{{ keystone_url_v3 }}"
    action: "create_user"
    user_name: "{{ item.username }}"
    user_password: "{{ item.password }}"
    description: "Create Monasca users"
    user_domain_name: "Default"
  no_log: True
  run_once_per: verb_hosts.MON_API
  with_items: "{{ mon_keystone_users }}"
  when: item.password is defined

- name: Keystone - Assign roles to users
  become: yes
  keystone_v3:
    login_token: "{{ domain_scoped_token.result }}"
    endpoint: "{{ keystone_url_v3 }}"
    action: "grant_project_role"
    user_name: "{{ item.username }}"
    project_name: "{{ item.project }}"
    user_domain_name: "Default"
    project_domain_name: "Default"
    role_name: "{{ item.role }}"
  no_log: True
  run_once_per: verb_hosts.MON_API
  with_items: "{{ mon_keystone_users }}"
0707010000003B000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000003900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb0707010000003C000081A40000000000000000000000015EBC1828000004B6000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/README.md# InfluxDB

Install [InfluxDB](http://influxdb.org/) time series database

## Role Variables

| Name                        | Default Value | Description                                                      |
|-----------------------------|---------------|------------------------------------------------------------------|
| influxdb_client_port        | 8086          | The port for influxdb client connections                         |
| influxdb_ssl_certificate    | None          | If defined the influxdb_client_port will be set to SSL           |
| influxdb_ssl_certificate_src| None          | If defined the file at this location wil be copied to the host   |
| influxdb_use_apt            | false         | If true apt will be used to install influxdb                     |
| influxdb_deb_src_url        | http://s3.amazonaws.com/influxdb/ | If not using apt the url base to pull the deb from |


##Optional
- run_mode - One of Deploy, Stop, Install, Start, or Use. The default is Deploy which will do Install, Configure, then Start.

### Clustering
To enable clustering define `influxdb_peers` on all nodes.
`influxdb_peers` is a list of `host:port` entries, one for each node.

## License

MIT
0707010000003D000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/defaults0707010000003E000081A40000000000000000000000015EBC182800000588000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
influxdb_raft_port: 8088
influxdb_hostname: "{{ host.bind.FND_IDB.internal.ip_address }}"

run_mode: Deploy
skip_install: False

influxdb_bind_address: "{{ host.bind.FND_IDB.internal.ip_address }}"
influxdb_client_port: "{{ FND_IDB.members.private[0].port }}"
influxdb_node_count: "{{ FND_IDB.members.private | length }}"
influxdb_admin: "{{ FND_IDB.vars.influxdb_admin_user_name | default('root') }}"
influxdb_admin_password: "{{ FND_IDB.vars.influxdb_admin_user_password | default('root') }}"
influxdb_url: http://{{ influxdb_bind_address | ipwrap }}:{{ influxdb_client_port }}
influxdb_data_dir: "/var/opt/influxdb"
influxdb_log_dir: "/var/log/influxdb"
influxdb_https_enabled: "false"
influxdb_http_cert: "/etc/ssl/influxdb.pem"
influxdb_conf_dir: "/etc/influxdb"
0707010000003F000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/meta07070100000040000081A40000000000000000000000015EBC1828000003D8000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Tim Kuhlman
  description: Install InfluxDB Time Series Database - Originally based on the version by Benjamin Curtis
  license: MIT
  min_ansible_version: 1.3
  platforms:
  - name: Ubuntu
    versions:
    - all
  - name: Debian
    versions:
    - all
  categories:
  - database
  - database:nosql
dependencies: []
07070100000041000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks07070100000042000081A40000000000000000000000015EBC182800000311000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: influxdb | _schedule_restart | Schedule a restart for influxdb
  debug:
    msg: "Trigger a change notification in influxdb"
  changed_when: true
  register: ardana_notify_influxdb_restart_required07070100000043000081A40000000000000000000000015EBC18280000088A000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/configure.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Influxdb | install | Update config
  template: src=influxdb.conf.j2 dest={{ influxdb_conf_dir }}/influxdb.conf
  register: ardana_notify_influxdb_restart_required

- name: Influxdb | install | Copy ssl key
  copy:
    dest: "{{influxdb_ssl_certificate}}"
    src: "{{influxdb_ssl_certificate_src}}"
    owner: influxdb
    group: root
    mode: 0440
  when: influxdb_ssl_certificate_src is defined
  register: ardana_notify_influxdb_restart_required

- name: Influxdb | install | Create Influxdb Data Directory
  file:
    path: "{{ influxdb_data_dir }}"
    state: directory
    recurse: yes
    owner: influxdb
    group: influxdb
    mode: 0750

- name: Influxdb | install | Create Influxdb log dir
  file:
    path: "{{influxdb_log_dir}}"
    state: directory
    owner: root
    group: influxdb
    mode: 0775

- name: Influxdb | install | Create Join Script if Influxdb Slave
  template:
    src: influxdb.j2
    dest: /etc/default/influxdb
    owner: root
    group: root
    mode: 0444
  when: host.vars.member_id != influxdb_master.member_id

- name: Influxdb | install | Detect if this is a systemd based system
  command: cat /proc/1/comm
  register: init

- name: Influxdb | install | This is a systemd based system
  set_fact: use_systemd=True
  when: init.stdout == 'systemd'

- name: Influxdb | install | This is not a systemd based system
  set_fact: use_systemd=False
  when: init.stdout != 'systemd'

- name: Influxdb | install | Reload the systemd manager
  command: systemctl daemon-reload
  when: use_systemd
07070100000044000081A40000000000000000000000015EBC18280000060C000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/fix_auth.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: influxdb | fix_auth | Determine if old Influxdb Version
  stat: path=/etc/opt/influxdb/influxdb.conf
  run_once_per: verb_hosts.FND_IDB
  register: old_auth_exists_result

- name: influxdb | fix_auth | Determine Auth Status
  command: grep auth-enabled /etc/opt/influxdb/influxdb.conf
  run_once_per: verb_hosts.FND_IDB
  register: auth_enabled_result
  when: old_auth_exists_result.stat.exists

- name: influxdb | fix_auth | Write upgrade script
  template: dest=/opt/influxdb/influxdb_upgrade.py owner=root group=root mode=0750 src=influxdb_upgrade.py.j2
  run_once_per: verb_hosts.FND_IDB
  when: old_auth_exists_result.stat.exists and 'false' in auth_enabled_result.stdout

- name: influxdb | fix_auth | Run upgrade script
  command: /opt/influxdb/influxdb_upgrade.py
  run_once_per: verb_hosts.FND_IDB
  when: old_auth_exists_result.stat.exists and 'false' in auth_enabled_result.stdout
07070100000045000081A40000000000000000000000015EBC182800000337000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/install.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: influxdb | install | Install required OS specific packages
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_influxdb_required_packages
07070100000046000081A40000000000000000000000015EBC182800000494000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: influxdb | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: stop.yml
  when: run_mode == 'Stop'

- include: install.yml
  when: not skip_install and ( run_mode == 'Install' or run_mode == 'Deploy' )

- include: upgrade.yml
  when: run_mode == 'Upgrade'

- include: configure.yml
  when: run_mode == 'Configure' or run_mode == 'Deploy' or run_mode == 'Upgrade'

- include: start.yml
  when: run_mode == 'Configure' or run_mode == 'Start' or run_mode == 'Deploy'
07070100000047000081A40000000000000000000000015EBC18280000071D000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/start.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: influxdb | restart | restart influxdb
  service: name=influxdb state=restarted enabled=yes
  when: (run_mode == 'Configure' or run_mode == 'Upgrade'
        or run_mode == 'Start' ) and
        ardana_notify_influxdb_restart_required is defined and
        ardana_notify_influxdb_restart_required | changed

- name: influxdb | start | start influxdb service on leader
  service: name=influxdb state=started enabled=yes
  when: host.vars.member_id == influxdb_master.member_id

# need to wait for port on initial deploy to make node1 leader
- name: influxdb | start | wait for influxdb port on leader
  wait_for: port={{influxdb_client_port}} host={{influxdb_bind_address | default('127.0.0.1') }} state=started timeout=120
  when: host.vars.member_id == influxdb_master.member_id and run_mode == 'Deploy'

- name: influxdb | start | start influxdb service on peers
  service: name=influxdb state=started enabled=yes
  when: host.vars.member_id != influxdb_master.member_id

- name: influxdb | start | wait for influxdb port on all nodes
  wait_for: port={{influxdb_client_port}} host={{influxdb_bind_address | default('127.0.0.1') }} state=started timeout=120
07070100000048000081A40000000000000000000000015EBC18280000049A000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/stop.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: influxdb | stop | stop influxdb on peers
  service: name=influxdb state=stopped
  when: host.vars.member_id != influxdb_master.member_id

- name: influxdb | stop | wait for port stopped on peers
  wait_for: port={{influxdb_client_port}} host={{influxdb_bind_address | default('127.0.0.1') }} state=stopped timeout=120
  when: host.vars.member_id != influxdb_master.member_id

- name: influxdb | stop | stop influxdb on leader
  service: name=influxdb state=stopped
  when: host.vars.member_id == influxdb_master.member_id
07070100000049000081A40000000000000000000000015EBC18280000049C000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/tasks/upgrade.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- include: fix_auth.yml

- name: influxdb | upgrade | OS specific upgrade Influxdb
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_influxdb_required_packages
  register: influxdb_upgrade_result
  notify:
    - influxdb | restart | restart all influxdb services

- name: influxdb | upgrade | Stop Infludb if upgraded
  service: name=influxdb state=stopped
  when: influxdb_upgrade_result | changed

- name: influxdb | upgrade | Remove old config if present
  file: path=/etc/opt/influxdb state=absent
0707010000004A000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/templates0707010000004B000081A40000000000000000000000015EBC182800002CA0000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/templates/influxdb.conf.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
#}
### Welcome to the InfluxDB configuration file.

# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com
# The data includes raft id (random 8 bytes), os, arch, version, and metadata.
# We don't track ip addresses of servers reporting. This is only used
# to track the number of instances running and the versions, which
# is very helpful for us.
# Change this option to true to disable reporting.
reporting-disabled = false

###
### Enterprise registration control
###

[registration]
# enabled = true
# url = "https://enterprise.influxdata.com" # The Enterprise server URL
# token = "" # Registration token for Enterprise server

###
### [meta]
###
### Controls the parameters for the Raft consensus group that stores metadata
### about the InfluxDB cluster.
###

[meta]
  dir = "{{ influxdb_data_dir }}/meta"
  hostname = "{{ influxdb_hostname }}"
  # bind-address = "{{ influxdb_bind_address | default('') }}:{{ influxdb_raft_port }}"
  bind-address = ":{{ influxdb_raft_port }}"
  retention-autocreate = true
  election-timeout = "1s"
  heartbeat-timeout = "1s"
  leader-lease-timeout = "500ms"
  commit-timeout = "50ms"
  cluster-tracing = false

  # If enabled, when a Raft cluster loses a peer due to a `DROP SERVER` command,
  # the leader will automatically ask a non-raft peer node to promote to a raft
  # peer. This only happens if there is a non-raft peer node available to promote.
  # This setting only affects the local node, so to ensure if operates correctly, be sure to set
  # it in the config of every node.
  raft-promotion-enabled = true

###
### [data]
###
### Controls where the actual shard data for InfluxDB lives and how it is
### flushed from the WAL. "dir" may need to be changed to a suitable place
### for your system, but the WAL settings are an advanced configuration. The
### defaults should work for most systems.
###

[data]
  dir = "{{ influxdb_data_dir }}/data"

  # Controls the engine type for new shards. Options are b1, bz1, or tsm1.
  # b1 is the 0.9.2 storage engine, bz1 is the 0.9.3 and 0.9.4 engine.
  # tsm1 is the 0.9.5 engine and is currenly EXPERIMENTAL. Until 0.9.5 is
  # actually released data written into a tsm1 engine may be need to be wiped
  # between upgrades.
  # engine ="bz1"

  # The following WAL settings are for the b1 storage engine used in 0.9.2. They won't
  # apply to any new shards created after upgrading to a version > 0.9.3.
  max-wal-size = 104857600 # Maximum size the WAL can reach before a flush. Defaults to 100MB.
  wal-flush-interval = "10m" # Maximum time data can sit in WAL before a flush.
  wal-partition-flush-delay = "2s" # The delay time between each WAL partition being flushed.

  # These are the WAL settings for the storage engine >= 0.9.3
  wal-dir = "{{ influxdb_data_dir }}/wal"
  wal-enable-logging = true

  # When a series in the WAL in-memory cache reaches this size in bytes it is marked as ready to
  # flush to the index
  # wal-ready-series-size = 25600

  # Flush and compact a partition once this ratio of series are over the ready size
  # wal-compaction-threshold = 0.6

  # Force a flush and compaction if any series in a partition gets above this size in bytes
  # wal-max-series-size = 2097152

  # Force a flush of all series and full compaction if there have been no writes in this
  # amount of time. This is useful for ensuring that shards that are cold for writes don't
  # keep a bunch of data cached in memory and in the WAL.
  # wal-flush-cold-interval = "10m"

  # Force a partition to flush its largest series if it reaches this approximate size in
  # bytes. Remember there are 5 partitions so you'll need at least 5x this amount of memory.
  # The more memory you have, the bigger this can be.
  # wal-partition-size-threshold = 20971520

  # Whether queries should be logged before execution. Very useful for troubleshooting, but will
  # log any sensitive data contained within a query.
  # query-log-enabled = true

###
### [hinted-handoff]
###
### Controls the hinted handoff feature, which allows nodes to temporarily
### store queued data when one node of a cluster is down for a short period
### of time.
###

[hinted-handoff]
  enabled = true
  dir = "{{ influxdb_data_dir }}/hh"
  max-size = 1073741824
  max-age = "168h"
  retry-rate-limit = 0

  # Hinted handoff will start retrying writes to down nodes at a rate of once per second.
  # If any error occurs, it will backoff in an exponential manner, until the interval
  # reaches retry-max-interval. Once writes to all nodes are successfully completed the
  # interval will reset to retry-interval.
  retry-interval = "1s"
  retry-max-interval = "1m"

  # Interval between running checks for data that should be purged. Data is purged from
  # hinted-handoff queues for two reasons. 1) The data is older than the max age, or
  # 2) the target node has been dropped from the cluster. Data is never dropped until
  # it has reached max-age however, for a dropped node or not.
  purge-interval = "1h"

###
### [cluster]
###
### Controls non-Raft cluster behavior, which generally includes how data is
### shared across shards.
###

[cluster]
  shard-writer-timeout = "10s" # The time within which a shard must respond to write.
  write-timeout = "5s" # The time within which a write operation must complete on the cluster.

###
### [retention]
###
### Controls the enforcement of retention policies for evicting old data.
###

[retention]
  enabled = true
  check-interval = "30m"

###
### [shard-precreation]
###
### Controls the precreation of shards, so they are created before data arrives.
### Only shards that will exist in the future, at time of creation, are precreated.

[shard-precreation]
  enabled = true
  check-interval = "10m"
  advance-period = "30m"

###
### Controls the system self-monitoring, statistics and diagnostics.
###
### The internal database for monitoring data is created automatically if
### if it does not already exist. The target retention within this database
### is called 'monitor' and is also created with a retention period of 7 days
### and a replication factor of 1, if it does not exist. In all cases the
### this retention policy is configured as the default for the database.

[monitor]
  store-enabled = true # Whether to record statistics internally.
  store-database = "_internal" # The destination database for recorded statistics
  store-interval = "10s" # The interval at which to record statistics

###
### [admin]
###
### Controls the availability of the built-in, web-based admin interface. If HTTPS is
### enabled for the admin interface, HTTPS must also be enabled on the [http] service.
###

[admin]
  enabled = true
  bind-address = "{{ influxdb_bind_address | default('') }}:8083"
  https-enabled = {{ influxdb_https_enabled }}
  https-certificate = "{{ influxdb_http_cert }}"

###
### [http]
###
### Controls how the HTTP endpoints are configured. These are the primary
### mechanism for getting data into and out of InfluxDB.
###

[http]
  enabled = true
  bind-address = "{{ influxdb_bind_address | default('') }}:{{ influxdb_client_port }}"
  auth-enabled = true
  log-enabled = true
  write-tracing = false
  pprof-enabled = false
  https-enabled = {{ influxdb_https_enabled }}
  https-certificate = "{{ influxdb_http_cert }}"

###
### [[graphite]]
###
### Controls one or many listeners for Graphite data.
###

[[graphite]]
  enabled = false
  # database = "graphite"
  # bind-address = ":2003"
  # protocol = "tcp"
  # consistency-level = "one"
  # name-separator = "."

  # These next lines control how batching works. You should have this enabled
  # otherwise you could get dropped metrics or poor performance. Batching
  # will buffer points in memory if you have many coming in.

  # batch-size = 1000 # will flush if this many points get buffered
  # batch-pending = 5 # number of batches that may be pending in memory
  # batch-timeout = "1s" # will flush at least this often even if we haven't hit buffer limit
  # udp-read-buffer = 0 # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.

  ## "name-schema" configures tag names for parsing the metric name from graphite protocol;
  ## separated by `name-separator`.
  ## The "measurement" tag is special and the corresponding field will become
  ## the name of the metric.
  ## e.g. "type.host.measurement.device" will parse "server.localhost.cpu.cpu0" as
  ## {
  ##     measurement: "cpu",
  ##     tags: {
  ##         "type": "server",
  ##         "host": "localhost,
  ##         "device": "cpu0"
  ##     }
  ## }
  # name-schema = "type.host.measurement.device"

  ## If set to true, when the input metric name has more fields than `name-schema` specified,
  ## the extra fields will be ignored.
  ## Otherwise an error will be logged and the metric rejected.
  # ignore-unnamed = true

###
### [collectd]
###
### Controls the listener for collectd data.
###

[collectd]
  enabled = false
  # bind-address = ""
  # database = ""
  # typesdb = ""

  # These next lines control how batching works. You should have this enabled
  # otherwise you could get dropped metrics or poor performance. Batching
  # will buffer points in memory if you have many coming in.

  # batch-size = 1000 # will flush if this many points get buffered
  # batch-pending = 5 # number of batches that may be pending in memory
  # batch-timeout = "1s" # will flush at least this often even if we haven't hit buffer limit
  # read-buffer = 0 # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.

###
### [opentsdb]
###
### Controls the listener for OpenTSDB data.
###

[opentsdb]
  enabled = false
  # bind-address = ":4242"
  # database = "opentsdb"
  # retention-policy = ""
  # consistency-level = "one"
  # tls-enabled = false
  # certificate= ""

  # These next lines control how batching works. You should have this enabled
  # otherwise you could get dropped metrics or poor performance. Only points
  # metrics received over the telnet protocol undergo batching.

  # batch-size = 1000 # will flush if this many points get buffered
  # batch-pending = 5 # number of batches that may be pending in memory
  # batch-timeout = "1s" # will flush at least this often even if we haven't hit buffer limit

###
### [[udp]]
###
### Controls the listeners for InfluxDB line protocol data via UDP.
###

[[udp]]
  enabled = false
  # bind-address = ""
  # database = "udp"
  # retention-policy = ""

  # These next lines control how batching works. You should have this enabled
  # otherwise you could get dropped metrics or poor performance. Batching
  # will buffer points in memory if you have many coming in.

  # batch-size = 1000 # will flush if this many points get buffered
  # batch-pending = 5 # number of batches that may be pending in memory
  # batch-timeout = "1s" # will flush at least this often even if we haven't hit buffer limit
  # read-buffer = 0 # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.

###
### [continuous_queries]
###
### Controls how continuous queries are run within InfluxDB.
###

[continuous_queries]
  log-enabled = true
  enabled = true
  recompute-previous-n = 2
  recompute-no-older-than = "10m"
  compute-runs-per-interval = 10
  compute-no-more-than = "2m"
0707010000004C000081A40000000000000000000000015EBC1828000002CA000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/templates/influxdb.j2#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
INFLUXD_OPTS="-join {{ influxdb_master.host }}:{{ influxdb_master.port }}"
0707010000004D000081A40000000000000000000000015EBC182800000816000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/templates/influxdb_upgrade.py.j2#!/usr/bin/env python
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
"""A simple script to add the admin user
"""

ADMIN = '{{influxdb_admin}}'
ADMIN_PASS = '{{influxdb_admin_password}}'

URL = '{{influxdb_url}}'

import json
import sys
import time
import urllib
import urllib2


def influxdb_get(uri, query):
    """Runs a query via HTTP GET and returns the response as a Python list."""

    getparams = {"q": query}

    try:
        params = urllib.urlencode(getparams)
        uri = "{}&{}".format(uri,params)
        req = urllib2.urlopen(uri)
        json_value = json.loads(req.read())

        if (len(json_value['results'][0]) > 0 and
           'values' in json_value['results'][0]['series'][0]):
            return json_value['results'][0]['series'][0]['values']
        else:
            return []

    except KeyError:
        print "Query returned a non-successful result: {0}".format(json_value['results'])
        sys.exit(1)


def main(argv=None):
    auth_str = '?u=%s&p=%s' % (ADMIN, ADMIN_PASS)
    api_uri = "{0}/query{1}".format(URL, auth_str)

#   List Users, if the admin user does exist, create it
    users = influxdb_get(uri=api_uri, query="SHOW USERS")
    all_users = [ name for name, admin in users ]
    if not all_users or ADMIN not in all_users:
        create = "CREATE USER {0} WITH PASSWORD '{1}' WITH ALL PRIVILEGES"
        influxdb_get(uri=api_uri, query=create.format(ADMIN, ADMIN_PASS))

if __name__ == "__main__":
    sys.exit(main())
0707010000004E000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/vars0707010000004F000081A40000000000000000000000015EBC182800000275000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/vars/debian.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_influxdb_required_packages:
  - influxdb
07070100000050000081A40000000000000000000000015EBC182800000303000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/vars/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
influxdb_host_list: "{{ FND_IDB.members.admin | sort(attribute='member_id') }}"
influxdb_master: "{{ influxdb_host_list[0] }}"
07070100000051000081A40000000000000000000000015EBC182800000275000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/influxdb/vars/suse.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_influxdb_required_packages:
  - influxdb
07070100000052000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000003600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka07070100000053000081A40000000000000000000000015EBC1828000003CD000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/README.md#Kafka
Installs [kafka](https://kafka.apache.org/)

##Requirements
- kafka_hosts - comma separated list of host:port pairs in the cluster, defaults to 'ansible_fqdn:9092' for a single node
- zookeeper_hosts - comma separated list of host:port pairs.

##Optional
- kafka_listen_address - defines a specifc address for kafka to listen on, by defaults listens on all interfaces
- kafka_id - Id to be used if one can't or shouldn't be derived from kafka_hosts. This will happen if kafka_hosts doesn't contain the fqdn but an alias
- monasca_log_level - Log level to be used for Kafka logs. Defaults to WARN
- monasca_wait_for_period - The time in seconds for how long to wait for Kafka's port to be available after starting it. Default is 30 seconds.
- run_mode - One of Deploy, Stop, Install, Start, or Use. The default is Deploy which will do Install, Configure, then Start.

##License
Apache

##Author Information
Tim Kuhlman

Monasca Team email monasca@lists.launchpad.net
07070100000054000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/defaults07070100000055000081A40000000000000000000000015EBC1828000008B2000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
kafka_version: 0.8.1.1
run_mode: Deploy
skip_install: False

kafka_num_network_threads: 2
kafka_num_io_threads: 2
kafka_num_partitions: 2
kafka_socket_send_buffer_bytes: 1048576
kafka_socket_receive_buffer_bytes: 1048576
kafka_socket_request_max_bytes: 104857600
# This is setting the idle timeout to 1 day to workaround
# https://bugzilla.suse.com/show_bug.cgi?id=1081169
kafka_connections_max_idle_ms: 86400000
kafka_log_flush_interval_messages: 10000
kafka_log_flush_interval_ms: 1000
kafka_log_retention_hours: 4
kafka_log_segment_bytes: 1048576 #1M
kafka_low_disk_retention: 1800000 # 30 minutes in milliseconds
kafka_log_cleanup_interval_mins: 1
kafka_tarball_name: "kafka_2.9.2-{{kafka_version}}.tgz"
monasca_wait_for_period: 30
monasca_log_level: WARN
# In MB
kafka_logfile_max_size: 50
monasca_log_rotation_backup_count: 4
zookeeper_connection_timeout_ms: 1000000

verify: True

zookeeper_nodes: "{{ FND_KFK.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"
kafka_port: "{{ FND_KFK.members.private[0].port }}"
kafka_nodes: "{{ FND_KFK.members.private }}"
kafka_hosts: "{% for node in kafka_nodes | sort(attribute='member_id') %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"
kafka_id: "{{host.vars.member_id | int - 1}}"
kafka_tarball_location: "{{ monasca_jars_virtualenv_dir }}/lib"
kafka_listen_address: "{{ host.bind.FND_KFK.internal.ip_address }}"
kafka_shell: /usr/sbin/nologin

kafka_restart_required: False
07070100000056000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/meta07070100000057000081A40000000000000000000000015EBC1828000003A5000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs kafka
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - clustering
  - system
dependencies: []
07070100000058000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks07070100000059000081A40000000000000000000000015EBC1828000003B8000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Kafka | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in Kafka package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: monasca_kafka_restart_packages
  register: ardana_notify_kafka_restart_required

0707010000005A000081A40000000000000000000000015EBC182800000305000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: kafka | _schedule_restart | Schedule a restart for kafka
  debug:
    msg: "Trigger a change notification in kafka"
  changed_when: true
  register: ardana_notify_kafka_restart_required0707010000005B000081A40000000000000000000000015EBC182800000742000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/configure.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: kafka | install | Print out RAM tuning selector
  debug:
    msg: "monasca_ram_tuning_selector = {{ monasca_ram_tuning_selector }}"

- name: kafka | install | Print out tuning selector
  debug:
    msg: "monasca_tuning_selector = {{ monasca_tuning_selector }}"

- name: kafka | install | install kafka (rpm)
  zypper:
    name: kafka
    state: present
  become: yes

- name: Create data_dir
  file: path={{kafka_data_dir}} state=directory owner={{kafka_user}} group={{kafka_group}} mode=0755
  register: ardana_notify_kafka_restart_required

- name: Remove lost+found in the datadir
  file: path="{{kafka_data_dir}}/lost+found" state=absent
  register: ardana_notify_kafka_restart_required

# Setup log4j.properties
- name: create log4j.properties
  template: dest="{{kafka_conf_dir}}/log4j.properties" owner={{kafka_user}} group={{kafka_group}} mode=0644 src=log4j.properties.j2
  register: ardana_notify_kafka_restart_required

# Setup server.properties
- name: create server.properties
  template: dest="{{kafka_conf_dir}}/server.properties" owner={{kafka_user}} group={{kafka_group}} mode=0640 src=server.properties.j2
  register: ardana_notify_kafka_restart_required

- meta: flush_handlers
0707010000005C000081A40000000000000000000000015EBC182800000461000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/dynamic-retention.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: kafka | dynamic-retention | Add dynamic kafka retention cron job
  template:
    src: kafka-retention.sh.j2
    dest: /usr/local/bin/kafka-retention.sh
    owner: root
    group: root
    mode: 0700
  become: yes

- name: kafka | dynamic-retention | Add dynamic kafka retention to crontab
  cron:
    name: "Dynamic kafka retention"
    minute: "*/5"
    job: /usr/local/bin/kafka-retention.sh 2>&1 | /usr/bin/logger -t kafka_retention
    state: present
  become: yes
 0707010000005D000081A40000000000000000000000015EBC182800000431000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/install.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: kafka | install | Install OS specific required packages
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_kafka_required_packages

- name: install | Update venv cache
  become: yes
  install_package:
    cache: update

- name: install | Install kafka from venv
  install_package:
    name: monasca
    service: monasca
    state: present
  register: ardana_notify_kafka_restart_required
0707010000005E000081A40000000000000000000000015EBC1828000004D3000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: kafka | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: stop.yml
  when: run_mode == 'Stop'

- include: upgrade.yml
  when: run_mode == 'Upgrade'

- include: install.yml
  when: not skip_install and
    ( run_mode == 'Install' or run_mode == 'Deploy' or run_mode == 'Upgrade')

- include: configure.yml
  when: run_mode == 'Configure' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'

- include: start.yml
  when: run_mode == 'Configure' or run_mode == 'Start' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'
0707010000005F000081A40000000000000000000000015EBC18280000064D000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
# use double negative in when clause to avoid marking ardana_notify for deletion
- name: kafka | start | stop kafka service
  service: name=kafka state=stopped
  when: not (ardana_notify_kafka_restart_required is not defined) and
        ardana_notify_kafka_restart_required.changed
  register: kafka_stopped

- name: kafka | start | delay to allow kafka to completely shut down
  pause: seconds=30
  when: kafka_stopped is defined and
        kafka_stopped.changed

- name: kafka | start | restart kafka service
  service: name=kafka state=restarted enabled=yes
  when: ardana_notify_kafka_restart_required is defined and
        ardana_notify_kafka_restart_required.changed

- name: kafka | start | Start kafka service
  service: name=kafka state=started enabled=yes

- name: kafka | start | wait for kafka port
  wait_for: host={{kafka_listen_address| default('localhost')}} port={{kafka_port}} state=started timeout={{ monasca_wait_for_period }}
  when: verify
07070100000060000081A40000000000000000000000015EBC1828000002BA000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop Kafka
  service: name=kafka state=stopped
07070100000061000081A40000000000000000000000015EBC182800000515000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/tasks/upgrade.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
- include_vars:
    roles/monasca-agent/vars/main.yml

- include: _check_upgraded_pkgs.yml

- name: kafka | upgrade | set agent kafka configuration file path
  set_fact:
    agent_kafka_config:
      "{{ monasca_conf_dir }}/agent/conf.d/kafka_consumer.yaml"
    correct_config:
      "kafka_connect_str: {{ kafka_listen_address }}:9092"

- name: kafka | upgrade | check if config file is incorrect
  command: grep "{{ correct_config}}" {{ agent_kafka_config }}
  register: config_check_result
  ignore_errors: yes

- name: kafka | upgrade | remove incorrect config file
  file: path={{ agent_kafka_config }} state=absent
  when: config_check_result | failed
07070100000062000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/templates07070100000063000081ED0000000000000000000000015EBC182800000698000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/templates/kafka-retention.sh.j2#!/bin/bash

#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#

function decrease_retention() {
    # note this is post-0.9.0 behavior
    {{ kafka_bin_dir }}/kafka-configs.sh --zookeeper {{ zookeeper_hosts }} --alter \
        --entity-type topics --entity-name $1 \
        --config retention.ms={{ kafka_low_disk_retention }}
}

function reset_retention() {
    # note this is post-0.9.0 behavior
    {{ kafka_bin_dir }}/kafka-configs.sh --zookeeper {{ zookeeper_hosts }} --alter \
        --entity-type topics --entity-name $1 --delete-config retention.ms
}

kafka_dir={{ kafka_data_dir }}

if [ ! -d "$kafka_dir" ]; then
    echo "No /var/kafka directory found.  Unable to do anything."
    exit 0
fi

size=`df -kh $kafka_dir | tail -1 | awk '{print $5}' | awk -F% '{print $1}'`

if [ "$size" -gt "85" ]; then
    echo "$kafka_dir > 85% usage.  Reducing kafka retention."
    decrease_retention metrics
    decrease_retention logs
fi

if [ "$size" -lt "25" ]; then
    echo "$kafka_dir < 25% usage.  Resetting retention to default."
    reset_retention metrics
    reset_retention logs
fi
07070100000064000081A40000000000000000000000015EBC182800000491000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/templates/kafka.conf.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
description "Kafka"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

limit nofile 32768 32768

# If zookeeper is running on this box also give it time to start up properly
pre-start script
    if [ -e /etc/init.d/zookeeper ]; then
        /etc/init.d/zookeeper start
    fi
end script

# Rather than using setuid/setgid sudo is used because the pre-start task must run as root
exec sudo -Hu kafka -g kafka KAFKA_HEAP_OPTS="{{ kafka_heap_opts }}" /opt/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties
07070100000065000081A40000000000000000000000015EBC1828000003B6000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/templates/kafka.service.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Kafka Daemon
After=zookeeper.service

[Service]
Type=simple
User=kafka
Group=kafka
LimitNOFILE=32768
Restart=on-failure
Environment="KAFKA_HEAP_OPTS={{ kafka_heap_opts }}"
ExecStart=/opt/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties

[Install]
WantedBy=multi-user.target
07070100000066000081A40000000000000000000000015EBC182800000ECC000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/templates/log4j.properties.j2#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
log4j.rootLogger={{ monasca_log_level }}, kafkaAppender

log4j.appender.kafkaAppender=org.apache.log4j.RollingFileAppender
log4j.appender.kafkaAppender.MaxFileSize={{ kafka_logfile_max_size }}MB
log4j.appender.kafkaAppender.MaxBackupIndex={{ monasca_log_rotation_backup_count }}
log4j.appender.kafkaAppender.File={{kafka_log_dir}}/server.log
log4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.kafkaAppender.layout.ConversionPattern=[%d] %p %m (%c)%n

log4j.appender.stateChangeAppender=org.apache.log4j.RollingFileAppender
log4j.appender.stateChangeAppender.MaxFileSize={{ kafka_logfile_max_size }}MB
log4j.appender.stateChangeAppender.MaxBackupIndex={{ monasca_log_rotation_backup_count }}
log4j.appender.stateChangeAppender.File={{kafka_log_dir}}/state-change.log
log4j.appender.stateChangeAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.stateChangeAppender.layout.ConversionPattern=[%d] %p %m (%c)%n

log4j.appender.controllerAppender=org.apache.log4j.RollingFileAppender
log4j.appender.controllerAppender.MaxFileSize={{ kafka_logfile_max_size }}MB
log4j.appender.controllerAppender.MaxBackupIndex={{ monasca_log_rotation_backup_count }}
log4j.appender.controllerAppender.File={{kafka_log_dir}}/controller.log
log4j.appender.controllerAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.controllerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n

# Turn on all our debugging info
#log4j.logger.kafka.producer.async.DefaultEventHandler=DEBUG, kafkaAppender
#log4j.logger.kafka.client.ClientUtils=DEBUG, kafkaAppender
#log4j.logger.kafka.perf=DEBUG, kafkaAppender
#log4j.logger.kafka.perf.ProducerPerformance$ProducerThread=DEBUG, kafkaAppender
#log4j.logger.org.I0Itec.zkclient.ZkClient=DEBUG
log4j.logger.kafka={{ monasca_log_level }}, kafkaAppender

# Tracing requests results in large logs
#log4j.appender.requestAppender=org.apache.log4j.RollingFileAppender
#log4j.appender.requestAppender.MaxFileSize={{ kafka_logfile_max_size }}MB
#log4j.appender.requestAppender.MaxBackupIndex={{ monasca_log_rotation_backup_count }}
#log4j.appender.requestAppender.File={{kafka_log_dir}}/kafka-request.log
#log4j.appender.requestAppender.layout=org.apache.log4j.PatternLayout
#log4j.appender.requestAppender.layout.ConversionPattern=[%d] %p %m (%c)%n
#
#log4j.logger.kafka.network.RequestChannel$=TRACE, requestAppender
#log4j.additivity.kafka.network.RequestChannel$=false
#
#log4j.logger.kafka.network.Processor=TRACE, requestAppender
#log4j.logger.kafka.server.KafkaApis=TRACE, requestAppender
#log4j.additivity.kafka.server.KafkaApis=false
#log4j.logger.kafka.request.logger=TRACE, requestAppender
#log4j.additivity.kafka.request.logger=false
#
#log4j.logger.kafka.controller=TRACE, controllerAppender
#log4j.additivity.kafka.controller=false
#
#log4j.logger.state.change.logger=TRACE, stateChangeAppender
#log4j.additivity.state.change.logger=false

07070100000067000081A40000000000000000000000015EBC182800001665000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/templates/server.properties.j2{#
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
{% for url in kafka_hosts.split(',') %}
  {%- set url_host = url.split(':')[0] -%}
  {%- if url_host == ansible_fqdn or url_host in ansible_all_ipv4_addresses
         or ( kafka_id is defined and loop.index0 == kafka_id | int ) -%}
broker.id={{loop.index0}}

auto.leader.rebalance.enable=true
controlled.shutdown.enable=true

############################# Socket Server Settings #############################

# The port the socket server listens on
port={{url.split(':')[1]}}
  {% endif %}
{% endfor %}

# Hostname the broker will bind to. If not set, the server will bind to all interfaces
{% if kafka_listen_address is defined %}
host.name={{kafka_listen_address}}
{% else %}
#host.name=localhost
{% endif %}

# Hostname the broker will advertise to producers and consumers. If not set, it uses the
# value for "host.name" if configured.  Otherwise, it will use the value returned from
# java.net.InetAddress.getCanonicalHostName().
#advertised.host.name=<hostname routable by clients>

# The port to publish to ZooKeeper for clients to use. If this is not set,
# it will publish the same port that the broker binds to.
#advertised.port=<port accessible by clients>

# The number of threads handling network requests
num.network.threads={{kafka_num_network_threads}}

# The number of threads doing disk I/O
num.io.threads={{kafka_num_io_threads}}

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes={{kafka_socket_send_buffer_bytes}}

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes={{kafka_socket_receive_buffer_bytes}}

# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes={{kafka_socket_request_max_bytes}}

# Idle connections timeout: the server socket processor threads close the connections that idle more than this
connections.max.idle.ms={{kafka_connections_max_idle_ms}}

############################# Log Basics #############################

# A comma seperated list of directories under which to store log files
log.dirs={{kafka_data_dir}}

auto.create.topics.enable={{kafka_auto_create_topics}}
# The number of logical partitions per topic per server. More partitions allow greater parallelism
# for consumption, but also mean more files.
num.partitions={{kafka_num_partitions}}

############################# Log Flush Policy #############################

# Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.

# The number of messages to accept before forcing a flush of data to disk
log.flush.interval.messages={{kafka_log_flush_interval_messages}}

# The maximum amount of time a message can sit in a log before we force a flush
log.flush.interval.ms={{kafka_log_flush_interval_ms}}

############################# Log Retention Policy #############################

# The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.

# The minimum age of a log file to be eligible for deletion
log.retention.hours={{kafka_log_retention_hours}}

# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=60000

# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires.
# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction.
log.cleaner.enable=false

############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect={{zookeeper_hosts}}

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms={{zookeeper_connection_timeout_ms}}


07070100000068000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/vars07070100000069000081A40000000000000000000000015EBC1828000002B7000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/vars/debian.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_kafka_required_packages:
  - default-jre-headless

monasca_kafka_restart_packages:
  - default-jre-headless0707010000006A000081A40000000000000000000000015EBC1828000003A4000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/vars/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
kafka_bin_dir: "/usr/bin"
kafka_conf_dir: /etc/kafka
kafka_data_dir: /var/kafka
kafka_group: kafka
kafka_user: kafka
kafka_log_dir: /var/log/kafka
kafka_upstart_conf: /etc/init/kafka.conf
kafka_systemd_service: /etc/systemd/system/kafka.service
kafka_auto_create_topics: "false"
0707010000006B000081A40000000000000000000000015EBC1828000002D4000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/kafka/vars/suse.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_kafka_required_packages:
  - cron
  - java-1_8_0-openjdk-headless

monasca_kafka_restart_packages:
  - java-1_8_0-openjdk-headless
0707010000006C000041ED0000000000000000000000095EBC182800000000000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent0707010000006D000081A40000000000000000000000015EBC182800000C11000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/README.md#monasca-agent
Installs the [monasca-agent](https://github.com/stackforge/monasca-agent) part of the [Monasca](https://wiki.openstack.org/wiki/Monasca) project.
It is installs it into a virtualenv on the box.

## Requirements
virtualenv must be installed on the system.

- keystone_url:
- monasca_agent_user:
- monasca_agent_password:
- monasca_agent_project:

## Optional
- monasca_agent_check_frequency - Sets how often the collection run for the agent will occur
- monasca_agent_detection_args - Sets detection arguments during the monasca-setup run.
- monasca_agent_system_only - setting to true will cause Monasca setup to run in system_only mode
- monasca_agent_service:
- monasca_agent_dimensions: 'role:monitoring,region:a'
- monasca_api_url: if undefined it will be pulled from the keystone service catalog.
- monasca_agent_version: Defines a specific version to install, defaults to latest
- monasca_log_level: Log level of the agent logs, default is WARN
- pip_index_url: Index URL to use instead of the default for installing pip packages
- run_mode: One of Deploy, Stop, Install, Start, or Use. The default is Deploy which will do Install, Configure, then Start. 'Use' can be set if the only desire is to use the monasca_agent_plugin module

## monasca_agent_plugin module
This role contains the module monasca_agent_plugin which can be used to run monasca-setup for specific detection plugins. This is particularily
useful when used with the monasca_agent_system_only option of the role. In a deployment of many machines every machine can have the role applied
in system only mode then as different services are installed they can selectively enable different agent plugins using this module. Example usage:

    - name: Monasca agent ntp plugin configuration
      monasca_agent_plugin: name="ntp"
    - name: Monasca agent plugin configuration
      monasca_agent_plugin:
        names:
            - ntp
            - mysql

You must have the monasca-agent role in your playbook. If the agent is already deployed and you just need to use monasca_agent_plugin, then you can add the role in and have it skip all install, configure and start steps by using these lines in your playbook:

  roles:
    - {role: monasca-agent, run_mode: Use}

To copy custom detection and/or check plugins to the machine before running the monasca_agent_plugin module, use the
[copy module](http://docs.ansible.com/copy_module.html) with the published variables `monasca_agent_check_plugin_dir` or `monasca_agent_detection_plugin_dir`
for example:

    - name: Copy example check plugin
      copy: src=files/check/example.py dest="{{monasca_agent_check_plugin_dir}}"
    - name: Copy example detection plugin
      copy: src=files/detection/example.py dest="{{monasca_agent_detection_plugin_dir}}"
    - name: Run Monasca agent example plugin configuration
      monasca_agent_plugin: name="example"

##License
Apache
(c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
(c) Copyright 2017 SUSE LLC

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
0707010000006E000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/defaults0707010000006F000081A40000000000000000000000015EBC1828000008CA000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/defaults/main.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_agent_system_only: False
agent_reconfigure_script: /usr/local/sbin/monasca-reconfigure

skip_install: False
monasca_virtualenv_dir: /opt/monasca
run_mode: Deploy

default_service_name: system
keystone_url: "{{MON_AGN.consumes_KEY_API.vips.private[0].url}}/v3"
keystone_default_domain_name: "{{ KEY_API.vars.keystone_default_domain }}"
monasca_agent_service_name: openstack-monasca-agent.target
monasca_agent_user: "{{ MON_AGN.consumes_KEY_API.vars.keystone_monasca_agent_user }}"
monasca_agent_password: "{{ MON_AGN.consumes_KEY_API.vars.keystone_monasca_agent_password | quote }}"
monasca_agent_project: "{{KEY_API.vars.keystone_admin_tenant}}"
monasca_agent_region_name: "{{ MON.regions | first }}"
monasca_agent_dimensions: "control_plane:{{ host.my_dimensions.control_plane }},cluster:{{ host.my_dimensions.cluster }},cloud_name:{{ host.my_dimensions.cloud_name }},service:{{ default_service_name }}"
monasca_api_url: "{{MON_AGN.consumes_MON_API.vips.private[0].url}}/v2.0"
monasca_agent_num_collector_threads: 5
monasca_agent_shell: /sbin/nologin

monasca_agent_user_name: monasca-agent
monasca_agent_group_name: monasca
monasca_group_name: monasca

# Number of seconds a plugin collection time exceeds that causes a warning to
# be logged for that plugin
monasca_agent_collect_time_warn: "{{ monasca_agent_check_frequency - 5 }}"

monasca_agent_max_buffer_size: 1000
monasca_agent_max_measurement_buffer_size: -1
monasca_agent_backlog_send_rate: 1

system_cacert_file: "{{ trusted_ca_bundle }}"

monasca_log_dir: /var/log/monasca
monasca_agent_log_dir: "{{ monasca_log_dir }}/agent"
07070100000070000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/files07070100000071000081A40000000000000000000000015EBC182800000086000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/files/sudoersDefaults:monasca-agent !requiretty
Defaults:monasca-agent  secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
07070100000072000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/library07070100000073000081A40000000000000000000000015EBC182800001918000000000000000000000000000000000000005E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/library/monasca_agent_plugin.py#!/usr/bin/python
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
DOCUMENTATION = '''
---
module: monasca_agent_plugin
short_description: Configure the Monasca agent by running the given monasca-setup detection plugin.
description:
    This module uses the --detection_plugins option of monasca-setup and it is assumed that the full primary configuration of monasca-setup has already
    been done. This primary configuration is done when running the monasca-agent ansible role this module is found in.
    - Monasca project homepage - https://wiki.openstack.org/wiki/Monasca
author: Tim Kuhlman <tim@backgroundprocess.com>
requirements: [ ]
options:
    args:
        required: false
        description:
            - Arguments to be passed to the detection plugin.
              A dict containing key value pairs to be passed as arguments
              to the detection plugin. These are reformatted into
              a single argument of space separated key=value pairs, so
              there are limits on the size of the pairs.
              The deprecated format is space separated key=value arguments.
              That format should not be used for any new code and replaced
              where possible
    name:
        required: false
        description:
            - The name of the detection plugin to run, this or names is required.
    names:
        required: false
        description:
            - A list of detection plugins to run, this or name is required.
    state:
        required: false
        default: "configured"
        choices: [ configured, absent ]
        description:
            - If the state is configured the detection plugin will be run causing updates if needed. If absent the configuration created by the
              detection_plugins will be removed.
    monasca_setup_path:
        required: false
        default: None
        description:
            - The path to the monasca-setup command. If "None" (the default) the
              plugin will attempt to discover the command in a monasca
              installation within /usr/local/bin, /usr/bin, or /opt.
              And use the first one that is found.
    overwrite_enable:
        required: false
        default: False
        description:
            - Overwrite existing plugin configuration. The default is to merge. For agent.yaml is always overwritten. Note: Do NOT pass in overwrite_enable=True if the plugin updates the config file including different built_by such as process.yaml and http_check.yaml
'''

EXAMPLES = '''
tasks:
    - name: Monasca agent ntp plugin configuration
      monasca_agent_plugin: name="ntp"
    - name: Monasca agent plugin configuration
      monasca_agent_plugin:
        names:
            - ntp
            - mysql
'''

import os.path
from ansible.module_utils.basic import *


def main():
    module = AnsibleModule(
        argument_spec=dict(
            args=dict(required=False, type='str'),
            name=dict(required=False, type='str'),
            names=dict(required=False, type='list'),
            state=dict(default='configured', choices=['configured', 'absent'], type='str'),
            monasca_setup_path=dict(default=None, type='str'),
            overwrite_enable=dict(default=False, required=False, type='bool')
        ),
        supports_check_mode=True
    )

    if module.params['names'] is None and module.params['name'] is None:
        module.fail_json(msg='Either name or names paramater must be specified')

    if module.params['names'] is not None:
        names = module.params['names']
    else:
        names = [module.params['name']]

    default_setup_paths = ['/usr/local/bin/monasca-setup',
                           '/usr/bin/monasca-setup',
                           '/opt/monasca/bin/monasca-setup']
    monasca_setup_path = module.params['monasca_setup_path']
    if not monasca_setup_path:
        monasca_setup_path = next(
            (path for path in default_setup_paths if os.path.isfile(path)),
            "")

    args = [monasca_setup_path, '--user', 'monasca-agent', '--enable_logrotate', 'false']

    # assume a package based installation if monasca_setup_path is
    # "/usr/bin/monasca-setup" and set service name accordingly
    # use default otherwise
    if monasca_setup_path == '/usr/bin/monasca-setup':
        args.extend(['--agent_service_name', 'openstack-monasca-agent'])
    if module.check_mode:
        args.append('--dry_run')
    if module.params['overwrite_enable']:
        args.append('--overwrite')
    if module.params['state'] == 'absent':
        args.append('-r')
    args.append('-d')
    args.extend(names)

    if module.params['args']:
        if module.params['args'].startswith("{"):
            try:
                dict_args = json.loads(module.params['args'])
            except:
                (result, exc) = module.safe_eval(
                    module.params['args'], dict(), include_exceptions=True)
                if exc is not None:
                    module.fail_json(
                        msg="unable to evaluate dictionary for args")
                dict_args = result
            args_entries = ["{0}={1}".format(k,v) for k,v in dict_args.items()]
            args.extend(['-a', ' '.join(args_entries)])
        else:
            args.extend(['-a', module.params['args']])

    rc, out, err = module.run_command(args, check_rc=True)
    if err.find('Not all plugins found') != -1:
        module.fail_json(msg='Some specified plugins were not found.', stdout=out.rstrip("\r\n"), stderr=err.rstrip("\r\n"))

    if err.find('No changes found') == -1:
        changed = True
    else:
        changed = False

    module.exit_json(changed=changed, cmd=args, stdout=out.rstrip("\r\n"), stderr=err.rstrip("\r\n"), rc=rc)

if __name__ == "__main__":
    main()
07070100000074000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/meta07070100000075000081A40000000000000000000000015EBC1828000003C5000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs the monasca-agent part of the Monasca project.
  company: SUSE
  license: Apache
  min_ansible_version: 1.2
  platforms:
  - name: Ubuntu
    versions:
    - all
  categories:
  - monitoring
dependencies:
  - role: tls-vars
  - role: monasca-variables
07070100000076000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks07070100000077000081A40000000000000000000000015EBC1828000003D0000000000000000000000000000000000000005D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: monasca-agent | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in monasca-agent package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: monasca_agent_required_packages
  register: ardana_notify_monasca_agent_restart_required
07070100000078000081A40000000000000000000000015EBC182800000329000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: monasca-agent | _schedule_restart |
    Schedule a restart for monasca-agent
  debug:
    msg: "Trigger a change notification in monasca-agent"
  changed_when: true
  register: ardana_notify_monasca_agent_restart_required07070100000079000081A40000000000000000000000015EBC182800001482000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/configure.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-agent | configure | Setup monasca agent group
  become: yes
  group:
    name: "{{ monasca_agent_group_name }}"
    system: yes
  register: ardana_notify_monasca_agent_restart_required

- name: monasca-agent | configure | Setup user
  become: yes
  user:
    name: "{{ monasca_agent_user_name }}"
    system: yes
    groups: "{{ monasca_agent_group_name }}"
    shell: "{{ monasca_agent_shell }}"
  register: ardana_notify_monasca_agent_restart_required

- name: monasca-agent | configure | create /opt/monasca
  file:
    path: /opt/monasca
    state: directory
    owner: root
    group: root
    mode: 0755

- name: monasca-agent | configure | copy sudoers
  become: yes
  copy:
    src: sudoers
    dest: /etc/sudoers.d/monasca-agent
    owner: root
    group: root
    mode: 0440

# to be consistent with the rpm
- name: monasca-agent | configure | create conf.d dir
  become: yes
  file:
    path: "{{ item }}"
    state: directory
    owner: "{{ monasca_agent_user_name }}"
    group: "{{ monasca_agent_group_name }}"
    mode: 0750
  with_items:
    - "{{ monasca_conf_dir }}/agent"
    - "{{ monasca_conf_dir }}/agent/conf.d"

- name: monasca-agent | configure | create custom plugin dirs RHEL
  become: yes
  file:
    path: "{{ item }}"
    state: directory
    owner: "{{ monasca_agent_user_name }}"
    group: "{{ monasca_agent_group_name }}"
    mode: 0750
  with_items:
    - "{{ monasca_agent_check_plugin_dir }}"
    - "{{ monasca_agent_detection_plugin_dir }}"
  when: ansible_os_family|lower == 'redhat'


- name: monasca-agent | configure | create monasca log dir
  become: yes
  file:
    path: "{{ monasca_log_dir }}"
    state: directory
    owner: root
    group: root
    mode: 0775

- name: monasca-agent | configure | create agent log dir
  become: yes
  file:
    path: "{{ monasca_agent_log_dir }}"
    state: directory
    owner: "{{ monasca_agent_user_name }}"
    group: "{{ monasca_agent_group_name }}"
    mode: 0775

- name: monasca-agent | configure | Determine paths for RHEL systemd setup
  set_fact:
    _ma_vdir: "{{ 'monasca-agent' | venv_dir() }}/lib/systemd/system"
    _ma_edir: "/etc/systemd/system"

- name: monasca-agent | configure | Copy systemd file from venv to expected
        systemd location
  become: yes
  # rename file to eliminate spurious 'venv-' prefix added by venvjail
  command: install -v -g root -o root -m 755 {{ _ma_vdir }}/{{ item }} {{ _ma_edir }}/{{ item | replace('venv-', '') }}
  when:
    - ansible_os_family | lower == 'redhat'
  with_items:
    - openstack-monasca-agent.target
    - venv-openstack-monasca-agent-collector.service
    - venv-openstack-monasca-agent-forwarder.service
    - venv-openstack-monasca-agent-statsd.service

- name: monasca-agent | configure | Create tmpfiles.d file to handle reboots
        for agent process pid file
  become: yes
  lineinfile:
    dest: "/etc/tmpfiles.d/openstack-monasca-agent.conf"
    state: present
    create: yes
    line: "D /run/openstack-monasca-agent 0644 {{
              monasca_agent_user_name }} {{ monasca_agent_group_name }} -"
  when:
    - ansible_os_family | lower == 'redhat'

- name: monasca-agent | configure | Create run directory for agent process
        pid file
  become: yes
  file:
    path: "/run/openstack-monasca-agent"
    state: directory
    owner: "{{ monasca_agent_user_name }}"
    group: "{{ monasca_agent_group_name }}"
    mode: 0644
  when:
    - ansible_os_family | lower == 'redhat'

# Needed venv/usr/share --> venv/share symlink because of the way monasca-agent
# venv is created. Agent template lookup path ends up venv/share/monasca/agent/
- name: monasca-agent | configure | Create symlinks for RHEL case
  file:
    path: "{{ item.path }}"
    src: "{{ item.src }}"
    state: link
    owner: "{{ monasca_agent_user_name }}"
    group: "{{ monasca_agent_group_name }}"
    mode: 0640
  with_items:
    - { path: "/usr/local/bin/monasca-setup" ,
        src: "{{ 'monasca-agent' | venv_dir() }}/usr/bin/monasca-setup"}
    - { path: "{{ 'monasca-agent' | venv_dir() }}/share" ,
        src: "{{ 'monasca-agent' | venv_dir() }}/usr/share"}
  when:
    - ansible_os_family | lower == 'redhat'

# Instead of running this directly by creating a file to run
# it changes such as user/pass will trigger a rerun.
# Also a user can run it manually
- name: monasca-agent | configure | Create reconfigure script
  become: yes
  template:
    dest: "{{ agent_reconfigure_script }}"
    src: monasca-reconfigure.j2
    owner: root
    group: root
    mode: 0750
  register: ardana_notify_monasca_agent_restart_required
0707010000007A000081A40000000000000000000000015EBC1828000003C7000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/install-legacy.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-agent | install-legacy | Update venv cache
  install_package:
    cache: update

- name: monasca-agent | install-legacy | Install monasca-agent service
  install_package:
    name: monasca_agent
    service: monasca-agent
    state: present
  register: ardana_notify_monasca_agent_restart_required
0707010000007B000081A40000000000000000000000015EBC182800000533000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/install.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-agent | install | Install required packages
  become: yes
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_agent_required_packages

# Use legacy mode install for RHEL computes as well
- name: monasca-agent | install | Install monasca-agent (venv)
  include: install-legacy.yml
  when: ansible_os_family|lower == 'redhat'

- name: monasca-agent | install | Install the monasca-agent service
  become: yes
  package:
    name: "{{ item }}"
    state: present
  with_items:
    - openstack-monasca-agent
    - python-monasca-common
  register: ardana_notify_monasca_agent_restart_required
  when:
    - ansible_os_family | lower == 'suse'
0707010000007C000081A40000000000000000000000015EBC18280000031F000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: "monasca-agent | run_mode_{{ run_mode | lower }} | deffered include"
  include: "run_mode_{{ run_mode | default('Deploy') | lower }}.yml"
0707010000007D000081A40000000000000000000000015EBC182800000299000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_configure.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
# Perform "Configure" run_mode actions
---
- include: configure.yml
- include: start.yml
0707010000007E000081A40000000000000000000000015EBC182800000354000000000000000000000000000000000000005800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_deploy.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
# Perform "Deploy" run_mode actions
---
- name: "monasca-agent | run_mode_{{ run_mode | lower }} | Set os-specific variables"
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: install.yml
  when: not skip_install

- include: configure.yml
- include: start.yml
0707010000007F000081A40000000000000000000000015EBC182800000355000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_install.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
# Perform "Install" run_mode actions
---
- name: "monasca-agent | run_mode_{{ run_mode | lower }} | Set os-specific variables"
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: install.yml
  when: not skip_install

- include: configure.yml
- include: start.yml
07070100000080000081A40000000000000000000000015EBC1828000002AE000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_logging.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: "monasca-agent | run_mode_{{ run_mode | lower }} | No action required"
  debug:
      msg: 'noop'
07070100000081000081A40000000000000000000000015EBC1828000002D0000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_start.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
# Perform "Start" run_mode actions
---
- name: "monasca-agent | run_mode_{{ run_mode | lower }} | run the actual run_mode"
  include: start.yml
07070100000082000081A40000000000000000000000015EBC1828000002CE000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_stop.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
# Perform "Stop" run_mode actions
---
- name: "monasca-agent | run_mode_{{ run_mode | lower }} | run the actual run_mode"
  include: stop.yml
07070100000083000081A40000000000000000000000015EBC18280000037A000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_upgrade.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
# Perform "Upgrade" run_mode actions
---
- name: "monasca-agent | run_mode_{{ run_mode | lower }} | Set os-specific variables"
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: _check_upgraded_pkgs.yml

- include: install.yml
  when: not skip_install

- include: configure.yml
- include: start.yml
07070100000084000081A40000000000000000000000015EBC1828000002AE000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/run_mode_use.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: "monasca-agent | run_mode_{{ run_mode | lower }} | No action required"
  debug:
      msg: 'noop'
07070100000085000081A40000000000000000000000015EBC1828000006EA000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
# Checking if the restart flag is defined marks it for deletion
# Check for the opposite to avoid deleting it too early
- name: monasca-agent | start | run monasca-setup
  become: yes
  command: "{{ agent_reconfigure_script }}"
  when: (run_mode == 'Deploy' or run_mode == "Configure"
        or run_mode == 'Upgrade') and
        not (ardana_notify_monasca_agent_restart_required is not defined) and
        ardana_notify_monasca_agent_restart_required.changed

- name: monasca-agent | start | restart monasca-agent
  service:
    name: "{{ monasca_agent_service_name }}"
    state: restarted
    enabled: yes
  when: (run_mode == 'Deploy' or run_mode == "Configure"
        or run_mode == 'Upgrade' or run_mode == 'Start') and
        ardana_notify_monasca_agent_restart_required is defined and
        ardana_notify_monasca_agent_restart_required.changed

- name: monasca-agent | start | Start monasca-agent
  service:
    name: "{{ monasca_agent_service_name }}"
    state: started
    enabled: yes
  when: (run_mode == 'Deploy' or run_mode == 'Start' or
        run_mode == "Configure" or run_mode == 'Upgrade')
07070100000086000081A40000000000000000000000015EBC182800000305000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/tasks/stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-agent | stop | Stop Monasca-Agent
  service:
    name: "{{ monasca_agent_service_name }}"
    state: stopped
07070100000087000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/templates07070100000088000081A40000000000000000000000015EBC1828000008FA000000000000000000000000000000000000005F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/templates/monasca-reconfigure.j2#!/bin/sh
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#

'{{monasca_setup_bin_dir}}/monasca-setup' \
    --user '{{monasca_agent_user_name}}' \
    --username '{{monasca_agent_user}}' \
    --password '{{monasca_agent_password}}' \
    --user_domain_name '{{keystone_default_domain_name}}' \
    --ca_file '{{system_cacert_file}}' \
    {% if monasca_agent_service is defined %} -s '{{monasca_agent_service}}' {% endif %} \
    --keystone_url '{{keystone_url}}' \
    --project_name '{{monasca_agent_project}}' \
    --project_domain_name '{{keystone_default_domain_name}}' \
    --region_name '{{monasca_agent_region_name}}' \
    {% if monasca_api_url is defined %} --monasca_url '{{monasca_api_url}}' {% endif %} \
    {% if monasca_agent_dimensions is defined %} --dimensions '{{monasca_agent_dimensions}}' {% endif %} \
    {% if monasca_agent_check_frequency is defined %} --check_frequency '{{monasca_agent_check_frequency}}' {% endif %} \
    {% if monasca_agent_detection_args is defined %} -a '{{monasca_agent_detection_args}}' {% endif %} \
    {% if monasca_agent_system_only %} --system_only {% endif %} \
    {% if monasca_log_level is defined %} --log_level '{{monasca_log_level}}' {% endif %} \
    --plugin_collect_time_warn={{ monasca_agent_collect_time_warn | int }} \
    --num_collector_threads={{ monasca_agent_num_collector_threads }} \
    --max_measurement_buffer_size={{ monasca_agent_max_measurement_buffer_size }} \
    --backlog_send_rate={{ monasca_agent_backlog_send_rate }} \
    --max_buffer_size={{ monasca_agent_max_buffer_size }} \
    --agent_service_name={{ monasca_agent_service_name }} \
    --skip_enable \
    --enable_logrotate false \
    --overwrite
07070100000089000081A40000000000000000000000015EBC1828000002A3000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/templates/plugin.yaml.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
{{item.value | to_nice_yaml}}
0707010000008A000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/vars0707010000008B000081A40000000000000000000000015EBC1828000002CF000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/vars/debian.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_agent_required_packages:
  - libyaml-0-2
  - libxml2
  - libxslt1.1
0707010000008C000081A40000000000000000000000015EBC18280000033B000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/vars/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_conf_dir: /etc/monasca
monasca_agent_check_plugin_dir: /usr/lib/monasca/agent/custom_checks.d/
monasca_agent_detection_plugin_dir: /usr/lib/monasca/agent/custom_detect.d/
0707010000008D000081A40000000000000000000000015EBC1828000002F1000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/vars/redhat.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_agent_required_packages:
  - libcap
  - libyaml
  - libxml2
  - libxslt
  - python-monascaclient
0707010000008E000081A40000000000000000000000015EBC1828000002D3000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-agent/vars/suse.yml#
# (c) Copyright 2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_agent_required_packages:
  - libxml2
  - libxslt1
  - libcap-progs
0707010000008F000041ED0000000000000000000000035EBC182800000000000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition07070100000090000081A40000000000000000000000015EBC1828000007B0000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition/README.md# monasca-alarm-definition

This role provides an Ansible module for creation of Monasca alarm definitions and notifications.
More details on alarm definitions can be found at the [Monasca API documentation](https://github.com/stackforge/monasca-api/blob/master/docs/monasca-api-spec.md#alarm-definitions-and-alarms)

##Requirements
It is assumed the service endpoint for Monasca is properly registered in keystone.

##Role Variables

These variables must be defined.

- keystone_url
- monasca_keystone_user
- monasca_keystone_password

## Monasca Modules Usage
There are two modules available in the library subdirectory, one for Monasca notifications and the other for alarm definitions. For example:

    - name: Setup default email notification method
      monasca_notification_method:
        name: "Default Email"
        type: 'EMAIL'
        address: "root@localhost"
        keystone_url: "{{ keystone_url }}"
        keystone_user: "{{ monasca_keystone_user }}"
        keystone_password: "{{ monasca_keystone_password }}"
        keystone_project: "{{ monasca_keystone_project }}"
      register: default_notification_result
    - name: Host Alive Alarm
      monasca_alarm_definition:
        name: "Host Alive Alarm"
        description: "Trigger when a host alive check fails"
        expression: "host_alive_status > 0"
        monasca_keystone_token: "{{ default_notification_result.keystone_token }}"
        monasca_api_url: "{{ default_notification_result.monasca_api_url }}"
        severity: "HIGH"
        alarm_actions:
          - "{{ default_notification_result.notification_method_id }}"
        ok_actions:
          - "{{ default_notification_result.notification_method_id }}"
        undetermined_actions:
          - "{{ default_notification_result.notification_method_id }}"

Refer to the documentation within the module for full detail

##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
07070100000091000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition/library07070100000092000081A40000000000000000000000015EBC1828000000BB000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition/library/README.md# ansible-module-monasca
Ansible modules for Monasca. See the documentation for each module for more details.

For more information on [Monasca](https://wiki.openstack.org/wiki/Monasca).
07070100000093000081A40000000000000000000000015EBC182800002263000000000000000000000000000000000000006A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition/library/monasca_alarm_cleanup.py#!/usr/bin/python
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
DOCUMENTATION = '''
---
module: monasca_alarm_cleanup
short_description: Cleanup Alarms based on included metrics
description:
    - Deletes Alarms that match the given criteria
    - Monasca project homepage - https://wiki.openstack.org/wiki/Monasca
requirements: [ python-monascaclient ]
options:
    alarm_definition_name:
        required: false
        description:
            -  If given, only alarms that belong to the Alarm Definition with that name will be deleted
    api_version:
        required: false
        default: '2_0'
        description:
            - The monasca api version.
    keystone_password:
        required: false
        description:
            - Keystone password to use for authentication, required unless a keystone_token is specified.
    keystone_url:
        required: false
        description:
            - Keystone url to authenticate against, required unless keystone_token is defined.
              Example http://192.168.10.5:5000/v3
    keystone_token:
        required: false
        description:
            - Keystone token to use with the monasca api. If this is specified the monasca_api_url is required but
              the keystone_user and keystone_password aren't.
    keystone_user:
        required: false
        description:
            - Keystone user to log in as, required unless a keystone_token is specified.
    keystone_project:
        required: false
        description:
            - Keystone project name to obtain a token for, defaults to the user's default project
    keystone_project_domain:
        required: false
        description:
            - Keystone project domain to obtain a token for, defaults to the default project domain
    keystone_user_domain:
        required: false
        description:
            - Keystone project domain to obtain a token for, defaults to the default user domain
    keystone_verify:
        required: false
        description:
            - See 'verify' parameter in
              https://github.com/openstack/keystoneauth/blob/master/keystoneauth1/session.py
              The verification arguments to pass to requests. These are of
              the same form as requests expects, so True or False to
              verify (or not) against system certificates or a path to a
              bundle or CA certs to check against or None for requests to
              attempt to locate and use certificates. (optional, defaults to True)
    metric_dimensions:
        required: true
        description:
            - Map of name/value pairs. All alarms which have all metrics matching these dimension names and values will be deleted
    monasca_api_url:
        required: false
        description:
            - If unset the service endpoint registered with keystone will be used.
'''

EXAMPLES = '''
- name: Host Alive Alarm
  monasca_alarm_cleanup:
    metric_dimensions:
       process_name: storm.nimbus
    keystone_url: "{{monasca_keystone_url}}"
    keystone_user: "{{monasca_keystone_user}}"
    keystone_password: "{{monasca_keystone_password}}"
  tags:
    - alarms
  register: out
'''

from ansible.module_utils.basic import *
import os

try:
    from monascaclient import client
except ImportError:
    paths = ["/opt/stack/service/monascaclient/venv", "/opt/monasca"]
    for path in paths:
        activate_this = os.path.realpath(path + '/bin/activate_this.py')
        if not os.path.exists(activate_this):
            continue
        try:
            execfile(activate_this, dict(__file__=activate_this))
            from monascaclient import client
        except ImportError:
            monascaclient_found = False
        else:
            monascaclient_found = True
            break
else:
    monascaclient_found = True


# With Ansible modules including other files presents difficulties otherwise this would be in its own module
class MonascaAnsible(object):
    """ A base class used to build Monasca Client based Ansible Modules
        As input an ansible.module_utils.basic.AnsibleModule object is expected. It should have at least
        these params defined:
        - api_version
        - keystone_token and monasca_api_url or keystone_url, keystone_user and keystone_password and optionally
          monasca_api_url
    """
    def __init__(self, module):
        self.module = module
        self.api_url = self.module.params['monasca_api_url']
        auth_args = self._get_keystone_auth_args()
        auth_args["endpoint"] = self.api_url
        self.monasca = client.Client(self.module.params['api_version'],
                                     **auth_args)
        self.exit_data = {'monasca_api_url': self.api_url}

    def _exit_json(self, **kwargs):
        """ Exit with supplied kwargs combined with the self.exit_data
        """
        kwargs.update(self.exit_data)
        self.module.exit_json(**kwargs)

    def _get_keystone_auth_args(self):
        """get arguments that should be passed on to monascaclient. """
        if self.module.params['monasca_api_url'] is None:
            self.module.fail_json(msg='Error: monasca_api_url is required')

        keystone_verify = self.module.params.get('keystone_verify', None)
        if keystone_verify and keystone_verify == "True":
            verify_flag = True
        elif keystone_verify and keystone_verify == "False":
            verify_flag = False
        else:
            # path to ca cert
            verify_flag = keystone_verify

        keystone_auth_args = {'auth_url': self.module.params['keystone_url'],
                              'project_name': self.module.params['keystone_project'],
                              'project_domain_name': self.module.params['keystone_project_domain'],
                              'user_domain_name': self.module.params['keystone_user_domain'],
                              'verify': verify_flag}

        if self.module.params['keystone_token'] is not None:
            keystone_auth_args['token'] = self.module.params['keystone_token']
        else:
            keystone_auth_args['username'] = self.module.params['keystone_user']
            keystone_auth_args['password'] = self.module.params['keystone_password']

        return keystone_auth_args


class MonascaAlarmCleanup(MonascaAnsible):
    def run(self):
        alarm_definition_name = self.module.params['alarm_definition_name']
        metric_dimensions = self.module.params['metric_dimensions']

        deleted_alarms = False
        # Find alarms that match the dimensions
        alarms = self.monasca.alarms.list(metric_dimensions=metric_dimensions)

        for alarm in alarms:
            if alarm_definition_name and alarm_definition_name != alarm['alarm_definition']['name']:
                continue

            self.monasca.alarms.delete(alarm_id=alarm['id'])
            deleted_alarms = True
        self._exit_json(changed=deleted_alarms)


def main():
    module = AnsibleModule(
        argument_spec=dict(
            alarm_definition_name=dict(required=False, type='str'),
            api_version=dict(required=False, default='2_0', type='str'),
            keystone_password=dict(required=False, type='str'),
            keystone_token=dict(required=False, type='str'),
            keystone_url=dict(required=False, type='str'),
            keystone_user=dict(required=False, type='str'),
            keystone_project=dict(required=False, type='str'),
            keystone_user_domain=dict(required=False, type='str'),
            keystone_project_domain=dict(required=False, type='str'),
            keystone_verify=dict(required=False, type='str'),
            metric_dimensions=dict(default=['hostname'], type='dict'),
            monasca_api_url=dict(required=False, type='str')
        ),
        supports_check_mode=True,
        no_log=True
    )

    if not monascaclient_found:
        module.fail_json(msg="python-monascaclient >= 1.0.9 is required")

    cleanup = MonascaAlarmCleanup(module)
    try:
        cleanup.run()
    except Exception, e:
        cleanup.module.fail_json(msg='Monascaclient Exception: %s' % e)

if __name__ == "__main__":
    main()
07070100000094000081A40000000000000000000000015EBC1828000034DA000000000000000000000000000000000000006D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition/library/monasca_alarm_definition.py#!/usr/bin/python
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
DOCUMENTATION = '''
---
module: monasca_alarm_definition
short_description: crud operations on Monasca alarm definitions
description:
    - Performs crud operations (create/update/delete) on monasca alarm definitions
    - Monasca project homepage - https://wiki.openstack.org/wiki/Monasca
    - When relevant the alarm_definition_id is in the output and can be used with the register action
author: Tim Kuhlman <tim@backgroundprocess.com>
requirements: [ python-monascaclient ]
options:
    alarm_actions:
        required: false
        description:
            -  Array of notification method IDs that are invoked for the transition to the ALARM state. Will not overwrite for existing definitions
    api_version:
        required: false
        default: '2_0'
        description:
            - The monasca api version.
    description:
        required: false
        description:
            - The description associated with the alarm definition
    expression:
        required: false
        description:
            - The alarm definition expression, required for create/update operations.
    keystone_password:
        required: false
        description:
            - Keystone password to use for authentication, required unless a keystone_token is specified.
    keystone_url:
        required: false
        description:
            - Keystone url to authenticate against, required unless keystone_token is defined.
              Example http://192.168.10.5:5000/v3
    keystone_token:
        required: false
        description:
            - Keystone token to use with the monasca api. If this is specified the monasca_api_url is required but
              the keystone_user and keystone_password aren't.
    keystone_user:
        required: false
        description:
            - Keystone user to log in as, required unless a keystone_token is specified.
    keystone_project:
        required: false
        description:
            - Keystone project name to obtain a token for, defaults to the user's default project
    keystone_project_domain:
        required: false
        description:
            - Keystone project domain to obtain a token for, defaults to the default project domain
    keystone_user_domain:
        required: false
        description:
            - Keystone project domain to obtain a token for, defaults to the default user domain
    keystone_verify:
        required: false
        description:
            - See 'verify' parameter in
              https://github.com/openstack/keystoneauth/blob/master/keystoneauth1/session.py
              The verification arguments to pass to requests. These are of
              the same form as requests expects, so True or False to
              verify (or not) against system certificates or a path to a
              bundle or CA certs to check against or None for requests to
              attempt to locate and use certificates. (optional, defaults to True)
    match_by:
        required: false
        default: "[hostname]"
        description:
            - Alarm definition match by, see the monasca api documentation for more detail.
    monasca_api_url:
        required: false
        description:
            - If unset the service endpoint registered with keystone will be used.
    name:
        required: true
        description:
            - The alarm definition name
    ok_actions:
        required: false
        description:
            -  Array of notification method IDs that are invoked for the transition to the OK state. Will not overwrite for existing definitions
    severity:
        required: false
        default: "LOW"
        description:
            - The severity set for the alarm definition must be LOW, MEDIUM, HIGH or CRITICAL
    state:
        required: false
        default: "present"
        choices: [ present, absent ]
        description:
            - Whether the alarm definition should exist.  When C(absent), removes the alarm definition. The name
              is used to determine the alarm definition to remove
    undetermined_actions:
        required: false
        description:
            -  Array of notification method IDs that are invoked for the transition to the UNDETERMINED state. Will not overwrite for existing definitions
'''

EXAMPLES = '''
- name: Host Alive Alarm
  monasca_alarm_definition:
    name: "Host Alive Alarm"
    expression: "host_alive_status > 0"
    keystone_url: "{{monasca_keystone_url}}"
    keystone_user: "{{monasca_keystone_user}}"
    keystone_password: "{{monasca_keystone_password}}"
  tags:
    - alarms
    - system_alarms
  register: out
- name: Create System Alarm Definitions
  monasca_alarm_definition:
    name: "{{item.name}}"
    expression: "{{item.expression}}"
    keystone_token: "{{out.keystone_token}}"
    monasca_api_url: "{{out.monasca_api_url}}"
  with_items:
    - { name: "High CPU usage", expression: "avg(cpu.idle_perc) < 10 times 3" }
    - { name: "Disk Inode Usage", expression: "disk.inode_used_perc > 90" }
'''

from ansible.module_utils.basic import *
import os

try:
    from monascaclient import client
except ImportError:
    paths = ["/opt/stack/service/monascaclient/venv", "/opt/monasca"]
    for path in paths:
        activate_this = os.path.realpath(path + '/bin/activate_this.py')
        if not os.path.exists(activate_this):
            continue
        try:
            execfile(activate_this, dict(__file__=activate_this))
            from monascaclient import client
        except ImportError:
            monascaclient_found = False
        else:
            monascaclient_found = True
            break
else:
    monascaclient_found = True


# With Ansible modules including other files presents difficulties otherwise this would be in its own module
class MonascaAnsible(object):
    """ A base class used to build Monasca Client based Ansible Modules
        As input an ansible.module_utils.basic.AnsibleModule object is expected. It should have at least
        these params defined:
        - api_version
        - keystone_token and monasca_api_url or keystone_url, keystone_user and keystone_password and optionally
          monasca_api_url
    """
    def __init__(self, module):
        self.module = module
        self.api_url = self.module.params['monasca_api_url']
        auth_args = self._get_keystone_auth_args()
        auth_args["endpoint"] = self.api_url
        self.monasca = client.Client(self.module.params['api_version'],
                                     **auth_args)
        self.exit_data = {'monasca_api_url': self.api_url}

    def _exit_json(self, **kwargs):
        """ Exit with supplied kwargs combined with the self.exit_data
        """
        kwargs.update(self.exit_data)
        self.module.exit_json(**kwargs)

    def _get_keystone_auth_args(self):
        """get arguments that should be passed on to monascaclient. """

        if self.module.params['monasca_api_url'] is None:
            self.module.fail_json(msg='Error: monasca_api_url is required')

        keystone_verify = self.module.params.get('keystone_verify', None)
        if keystone_verify and keystone_verify == "True":
            verify_flag = True
        elif keystone_verify and keystone_verify == "False":
            verify_flag = False
        else:
            # path to ca cert
            verify_flag = keystone_verify

        keystone_auth_args = {'auth_url': self.module.params['keystone_url'],
                              'project_name': self.module.params['keystone_project'],
                              'project_domain_name': self.module.params['keystone_project_domain'],
                              'user_domain_name': self.module.params['keystone_user_domain'],
                              'verify': verify_flag}

        if self.module.params['keystone_token'] is not None:
            keystone_auth_args['token'] = self.module.params['keystone_token']
        else:
            keystone_auth_args['username'] = self.module.params['keystone_user']
            keystone_auth_args['password'] = self.module.params['keystone_password']

        return keystone_auth_args


class MonascaDefinition(MonascaAnsible):
    def run(self):
        name = self.module.params['name']
        expression = self.module.params['expression']

        # Find existing definitions
        definitions = {definition['name']: definition for definition in self.monasca.alarm_definitions.list()}

        if self.module.params['state'] == 'absent':
            if name not in definitions.keys():
                self._exit_json(changed=False)

            if self.module.check_mode:
                self._exit_json(changed=True)
            resp = self.monasca.alarm_definitions.delete(alarm_id=definitions[name]['id'])
            if resp.status_code == 204:
                self._exit_json(changed=True)
            else:
                self.module.fail_json(msg=str(resp.status_code) + resp.text)
        else:  # Only other option is state=present
            def_kwargs = {"name": name, "description": self.module.params['description'], "expression": expression,
                          "match_by": self.module.params['match_by'], "severity": self.module.params['severity'],
                          "alarm_actions": self.module.params['alarm_actions'],
                          "ok_actions": self.module.params['ok_actions'],
                          "undetermined_actions": self.module.params['undetermined_actions']}

            if name in definitions.keys():
                if definitions[name]['expression'] == expression and \
                   definitions[name]['severity'] == def_kwargs['severity']:
                    self._exit_json(changed=False, alarm_definition_id=definitions[name]['id'])
                def_kwargs['alarm_id'] = definitions[name]['id']
                del def_kwargs['alarm_actions']
                del def_kwargs['ok_actions']
                del def_kwargs['undetermined_actions']

                if self.module.check_mode:
                    self._exit_json(changed=True, alarm_definition_id=definitions[name]['id'])

                do_recreate = False
                try:
                    body = self.monasca.alarm_definitions.patch(**def_kwargs)
                except Exception, e:
                    do_recreate = True

                if do_recreate:
                    resp = self.monasca.alarm_definitions.delete(alarm_id=definitions[name]['id'])
                    if resp.status_code == 204:
                        body = self.monasca.alarm_definitions.create(**def_kwargs)
                    else:
                        self.module.fail_json(msg="Recreate alarm delete failed: " + str(resp.status_code) + resp.text)
                        self._exit_json(changed=False)
            else:
                if self.module.check_mode:
                    self._exit_json(changed=True)
                body = self.monasca.alarm_definitions.create(**def_kwargs)

            if 'id' in body:
                self._exit_json(changed=True, alarm_definition_id=body['id'])
            else:
                self.module.fail_json(msg=body)


def main():
    module = AnsibleModule(
        argument_spec=dict(
            alarm_actions=dict(required=False, default=[], type='list'),
            api_version=dict(required=False, default='2_0', type='str'),
            description=dict(required=False, type='str'),
            expression=dict(required=False, type='str'),
            keystone_password=dict(required=False, type='str'),
            keystone_token=dict(required=False, type='str'),
            keystone_url=dict(required=False, type='str'),
            keystone_user=dict(required=False, type='str'),
            keystone_project=dict(required=False, type='str'),
            keystone_user_domain=dict(required=False, type='str'),
            keystone_project_domain=dict(required=False, type='str'),
            keystone_verify=dict(required=False, type='str'),
            match_by=dict(default=['hostname'], type='list'),
            monasca_api_url=dict(required=False, type='str'),
            name=dict(required=True, type='str'),
            ok_actions=dict(required=False, default=[], type='list'),
            severity=dict(default='LOW', type='str'),
            state=dict(default='present', choices=['present', 'absent'], type='str'),
            undetermined_actions=dict(required=False, default=[], type='list')
        ),
        supports_check_mode=True,
        no_log=True
    )

    if not monascaclient_found:
        module.fail_json(msg="python-monascaclient >= 1.0.9 is required")

    definition = MonascaDefinition(module)
    try:
        definition.run()
    except Exception, e:
        definition.module.fail_json(msg='Monascaclient Exception: %s' % e)

if __name__ == "__main__":
    main()
07070100000095000081A40000000000000000000000015EBC182800002B03000000000000000000000000000000000000007000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-alarm-definition/library/monasca_notification_method.py#!/usr/bin/python
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
DOCUMENTATION = '''
---
module: monasca_notification_method
short_description: crud operations for Monasca notifications methods
description:
    - Performs crud operations (create/update/delete) on monasca notification methods
    - Monasca project homepage - https://wiki.openstack.org/wiki/Monasca
    - When relevant the notification_id is in the output and can be used with the register action
author: Tim Kuhlman <tim@backgroundprocess.com>
requirements: [ python-monascaclient ]
options:
    address:
        required: true
        description:
            - The notification method address corresponding to the type.
    api_version:
        required: false
        default: '2_0'
        description:
            - The monasca api version.
    keystone_password:
        required: false
        description:
            - Keystone password to use for authentication, required unless a keystone_token is specified.
    keystone_url:
        required: false
        description:
            - Keystone url to authenticate against, required unless keystone_token isdefined.
              Example http://192.168.10.5:5000/v3
    keystone_token:
        required: false
        description:
            - Keystone token to use with the monasca api. If this is specified the monasca_api_url is required but
              the keystone_user and keystone_password aren't.
    keystone_user:
        required: false
        description:
            - Keystone user to log in as, required unless a keystone_token is specified.
    keystone_project:
        required: false
        description:
            - Keystone project name to obtain a token for, defaults to the user's default project
    keystone_project_domain:
        required: false
        description:
            - Keystone project domain to obtain a token for, defaults to the default project domain
    keystone_user_domain:
        required: false
        description:
            - Keystone project domain to obtain a token for, defaults to the default user domain
    keystone_verify:
        required: false
        description:
            - See 'verify' parameter in
              https://github.com/openstack/keystoneauth/blob/master/keystoneauth1/session.py
              The verification arguments to pass to requests. These are of
              the same form as requests expects, so True or False to
              verify (or not) against system certificates or a path to a
              bundle or CA certs to check against or None for requests to
              attempt to locate and use certificates. (optional, defaults to True)
    monasca_api_url:
        required: false
        description:
            - If unset the service endpoing registered with keystone will be used.
    name:
        required: true
        description:
            - The notification method name
    state:
        required: false
        default: "present"
        choices: [ present, absent ]
        description:
            - Whether the notification should exist.  When C(absent), removes the user notification.
    type:
        required: true
        description:
            - The notification type. This must be one of the types supported by the Monasca API.
    overwrite:
        required: false
        default: false
        choices: [ true, false ]
        description:
            - If true and notification exists, overwrite the address and type with given values,
              If false and notification exists, do nothing,
              If notification does not exist, create notification with given values

'''

EXAMPLES = '''
- name: Setup root email notification method
  monasca_notification_method:
    name: "Email Root"
    type: 'EMAIL'
    address: 'root@localhost'
    keystone_url: "{{keystone_url}}"
    keystone_user: "{{keystone_user}}"
    keystone_password: "{{keystone_password}}"
  register: out
- name: Create System Alarm Definitions
  monasca_alarm_definition:
    name: "Host Alive Alarm"
    expression: "host_alive_status > 0"
    keystone_token: "{{out.keystone_token}}"
    monasca_api_url: "{{out.monasca_api_url}}"
    alarm_actions:
      - "{{out.notification_method_id}}"
    ok_actions:
      - "{{out.notification_method_id}}"
    undetermined_actions:
      - "{{out.notification_method_id}}"
'''

from ansible.module_utils.basic import *
import os

try:
    from monascaclient import client
except ImportError:
    paths = ["/opt/stack/service/monascaclient/venv", "/opt/monasca"]
    for path in paths:
        activate_this = os.path.realpath(path + '/bin/activate_this.py')
        if not os.path.exists(activate_this):
            continue
        try:
            execfile(activate_this, dict(__file__=activate_this))
            from monascaclient import client
        except ImportError:
            monascaclient_found = False
        else:
            monascaclient_found = True
            break
else:
    monascaclient_found = True


# With Ansible modules including other files presents difficulties otherwise this would be in its own module
class MonascaAnsible(object):
    """ A base class used to build Monasca Client based Ansible Modules
        As input an ansible.module_utils.basic.AnsibleModule object is expected. It should have at least
        these params defined:
        - api_version
        - keystone_token and monasca_api_url or keystone_url, keystone_user and keystone_password and optionally
          monasca_api_url
    """
    def __init__(self, module):
        self.module = module
        self.api_url = self.module.params['monasca_api_url']
        auth_args = self._get_keystone_auth_args()
        auth_args["endpoint"] = self.api_url
        self.monasca = client.Client(self.module.params['api_version'],
                                     **auth_args)
        self.exit_data = {'monasca_api_url': self.api_url}

    def _exit_json(self, **kwargs):
        """ Exit with supplied kwargs combined with the self.exit_data
        """
        kwargs.update(self.exit_data)
        self.module.exit_json(**kwargs)

    def _get_keystone_auth_args(self):
        """get arguments that should be passed on to monascaclient. """

        if self.module.params['monasca_api_url'] is None:
            self.module.fail_json(msg='Error: monasca_api_url is required')

        keystone_verify = self.module.params.get('keystone_verify', None)
        if keystone_verify and keystone_verify == "True":
            verify_flag = True
        elif keystone_verify and keystone_verify == "False":
            verify_flag = False
        else:
            # path to ca cert
            verify_flag = keystone_verify

        keystone_auth_args = {'auth_url': self.module.params['keystone_url'],
                              'project_name': self.module.params['keystone_project'],
                              'project_domain_name': self.module.params['keystone_project_domain'],
                              'user_domain_name': self.module.params['keystone_user_domain'],
                              'verify': verify_flag}

        if self.module.params['keystone_token'] is not None:
            keystone_auth_args['token'] = self.module.params['keystone_token']
        else:
            keystone_auth_args['username'] = self.module.params['keystone_user']
            keystone_auth_args['password'] = self.module.params['keystone_password']

        return keystone_auth_args


class MonascaNotification(MonascaAnsible):
    def run(self):
        name = self.module.params['name']
        type = self.module.params['type']
        address = self.module.params['address']
        notifications = {notif['name']: notif for notif in self.monasca.notifications.list()}
        if name in notifications.keys():
            notification = notifications[name]
        else:
            notification = None

        if self.module.params['state'] == 'absent':
            if notification is None:
                self._exit_json(changed=False)
            else:
                self.monasca.notifications.delete(notification_id=notification['id'])
                self._exit_json(changed=True)
        else:  # Only other option is present
            if notification is None:
                body = self.monasca.notifications.create(name=name, type=type, address=address)
                self._exit_json(changed=True, notification_method_id=body['id'])
            else:
                changed = False
                if self.module.params['overwrite'] and (
                   notification['type'] != type or
                   notification['address'] != address):
                    self.monasca.notifications.update(notification_id=notification['id'],
                                                      name=name, type=type, address=address)
                    changed = True
                self._exit_json(changed=changed, notification_method_id=notification['id'])


def main():
    module = AnsibleModule(
        argument_spec=dict(
            address=dict(required=True, type='str'),
            api_version=dict(required=False, default='2_0', type='str'),
            keystone_password=dict(required=False, type='str'),
            keystone_token=dict(required=False, type='str'),
            keystone_url=dict(required=False, type='str'),
            keystone_user=dict(required=False, type='str'),
            keystone_project=dict(required=False, type='str'),
            keystone_user_domain=dict(required=False, type='str'),
            keystone_project_domain=dict(required=False, type='str'),
            keystone_verify=dict(required=False, type='str'),
            monasca_api_url=dict(required=False, type='str'),
            name=dict(required=True, type='str'),
            state=dict(default='present', choices=['present', 'absent'], type='str'),
            overwrite=dict(required=False, default=False, type='bool'),
            type=dict(required=True, type='str')
        ),
        supports_check_mode=True,
        no_log=True
    )

    if not monascaclient_found:
        module.fail_json(msg="python-monascaclient >= 1.0.9 is required")

    notification = MonascaNotification(module)
    try:
        notification.run()
    except Exception, e:
        notification.module.fail_json(msg='Monascaclient Exception: %s' % e)


if __name__ == "__main__":
    main()
07070100000096000041ED0000000000000000000000035EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-ansible-library07070100000097000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-ansible-library/noop07070100000098000081A40000000000000000000000015EBC182800000023000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-ansible-library/noop/README.mdNo-op ansible modules for Monasca.
07070100000099000081A40000000000000000000000015EBC182800000294000000000000000000000000000000000000006200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-ansible-library/noop/monasca_agent_plugin#!/bin/sh
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

echo "{}"
0707010000009A000081A40000000000000000000000015EBC182800000294000000000000000000000000000000000000006600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-ansible-library/noop/monasca_alarm_definition#!/bin/sh
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

echo "{}"
0707010000009B000081A40000000000000000000000015EBC182800000294000000000000000000000000000000000000006900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-ansible-library/noop/monasca_notification_method#!/bin/sh
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#

echo "{}"
0707010000009C000041ED0000000000000000000000085EBC182800000000000000000000000000000000000000000000003C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api0707010000009D000081A40000000000000000000000015EBC182800000C48000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/README.md#monasca-api
Installs the [monasca-api](https://github.com/stackforge/monasca-api) part of the [Monasca](https://wiki.openstack.org/wiki/Monasca) project.

##Requirements
- api_region
- influxdb_url
- influxdb_user
- influxdb_password
- kafka_hosts - comma separated list of host:port combinations
- keystone_host
- keystone_admin
- keystone_admin_password
- mysql_host - SSL will be used if available
- monasca_api_mysql_user
- monasca_api_mysql_password
- zookeeper_hosts - comma separated list of host:port combinations

##Optional parameters
- keystone_admin_project - defaults to empty value
- monasca_api_client_port - the port the API listens on, default is 8080
- monasca_api_bind_host - if set, the port the API listens on is bound to this host or ip address
- monasca_admin_client_port - the port the admin connector listens on, default is 8081
- monasca_api_admin_bind_host - if set, the port the admin connector listens on is bound to this host or ip address
- monasca_log_level - Log level for the API log. Default to WARN
- monasca_wait_for_period - The time in seconds for how long to wait for API's port to be available after starting it. Default is 10 seconds.
- run_mode - One of Deploy, Stop, Install, Start, or Use. The default is Deploy which will do Install, Configure, then Start.

There is a truststore used by the application for any certificate authorities that must be trusted. Additionally there is a client
keystore for any ssl keys needed for client authentication. Most importantly there is a standard keystore used for serving the api
via ssl.

- monasca_api_keystore - The remote location to place the keystore. If this is defined SSL will be enabled for the API.
- monasca_api_keystore_src - The local location to copy the keystore from.
- monasca_api_keystore_password
- monasca_api_truststore - The remote location to place the truststore. Generally a truststore is needed for the keystone SSL CA.
- monasca_api_truststore_src - The local location to copy the truststore from.
- monasca_api_truststore_password
- monasca_api_client_keystore - The remote location to place the client keystore.
- monasca_api_client_keystore_src - The local location to copy the client keystore from.
- monasca_api_client_keystore_password

The keystore and truststore's are jks files and created by command such as these examples:

    # Change from pem to pkcs12 format
    openssl pkcs12 -export -in orig.pem -inkey orig.key -out new.p12 -name fqdn -chain -CAfile cacert.pem -password pass:password
    # Create the jks keystore
    keytool -importkeystore -deststorepass password -destkeystore ./keystore.jks -srckeystore new.p12 -srcstoretype PKCS12 -srcstorepass password

##Example Playbook

    hosts: monasca
    become: yes
    roles:
      - {role: tkuhlman.monasca-api,
         influxdb_user: "{{api_influxdb_user}}",
         influxdb_password: "{{api_influxdb_password}}",
         monasca_api_mysql_user: "{{api_mysql_user}}",
         monasca_api_mysql_password: "{{api_mysql_password}}",
         tags: [api]}

##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
0707010000009E000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/defaults0707010000009F000081A40000000000000000000000015EBC1828000011D7000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/defaults/main.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
influxdb_db: mon
keystone_auth_method: password
keystone_client_auth: false
monasca_keystone_user: "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_user }}"
monasca_keystone_password: "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_password | quote }}"
monasca_admin_client_port: "{{ host.bind.MON_API.metrics.port }}"
monasca_api_admin_bind_host: localhost
monasca_api_client_keystore:
monasca_api_client_keystore_password:
monasca_api_keystore_password:
monasca_api_version: 1.1.0-SNAPSHOT
monasca_wait_for_period: 120
monasca_api_home: /var/lib/mon-api
monasca_log_dir: /var/log/monasca
monasca_log_level: WARN
monasca_log_rotation_backup_count: 5
monasca_mysql_db: "{{ MON_API.consumes_FND_MDB.vars.databases.monasca.dbname }}"
monasca_api_jar: "{{ monasca_jars_virtualenv_dir }}/lib/monasca-api-{{ monasca_api_version }}-shaded.jar"
monasca_api_jar_saved_md5: /opt/monasca/md5sums/monasca-api.md5

old_api_jar: False
run_mode: Deploy
skip_install: False
verify: True

monasca_api_region: "unset"
monasca_api_shell: /sbin/nologin

influxdb_url: "{% if database_type == 'influxdb' %}{{ MON_API.consumes_FND_IDB.vips.private[0].url }}{% endif %}"
influxdb_user: "{% if database_type == 'influxdb' %}{{ MON_API.consumes_FND_IDB.vars.influxdb_monasca_api_user }}{% endif %}"
influxdb_password: "{% if database_type == 'influxdb' %}{{ MON_API.consumes_FND_IDB.vars.influxdb_monasca_api_password | quote }}{% endif %}"

# cassandra
cassandra_contact_points: "{% for node in MON_PST.consumes_FND_CDB.members.inter_node_cluster %}{{ node.host }}{% if not loop.last %},{% endif %}{% endfor %}"
cassandra_port: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.members.client[0].port }}{% endif %}"
cassandra_user: "{% if database_type == 'cassandra' %}{{ MON_API.consumes_FND_CDB.vars.cassandra_monasca_api_user }}{% endif %}"
cassandra_password: "{% if database_type == 'cassandra' %}{{ MON_API.consumes_FND_CDB.vars.cassandra_monasca_api_password }}{% endif %}"
cassandra_datacenter_identifier: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_datacenter_identifier }}{% endif %}"

kafka_nodes: "{{ MON_API.consumes_FND_KFK.members.private }}"
kafka_hosts: "{% for node in kafka_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

keystone_host: "{{MON_API.consumes_KEY_API.vips.private[0].host}}"
keystone_port: "{{MON_API.consumes_KEY_API.vips.private[0].port}}"
keystone_use_https: "{{MON_API.consumes_KEY_API.vips.private[0].use_tls}}"
keystone_admin_project: "{{KEY_API.vars.keystone_admin_tenant}}"
keystone_url: "{{MON_API.consumes_KEY_API.vips.private[0].url}}"

monasca_api_bind_host: "{{ host.bind.MON_API.internal.ip_address }}"
monasca_api_client_port: "{{MON_API.advertises.vips.private[0]['port']}}"
monasca_api_protocol_https: "{% if MON_API.advertises.vips.private[0].protocol == 'https' %}true{% else %}false{% endif %}"

mysql_host: "{{MON_API.consumes_FND_MDB.vips.private[0].host}}"
mysql_port: "{{ MON_API.consumes_FND_MDB.vips.private[0].port }}"
mysql_https_arg: "{% if MON_API.consumes_FND_MDB.vips.private[0].use_tls %}&useSSL=true{% endif %}"
monasca_api_mysql_user: "{{ MON_API.consumes_FND_MDB.vars.accounts.monasca_api.username }}"
monasca_api_mysql_password: "{{ MON_API.consumes_FND_MDB.vars.accounts.monasca_api.password | quote }}"

zookeeper_nodes: "{{ MON_API.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"
# TODO: Get the connector port and set it

# monasca global conf
monasca_global_conf_dir: "/etc/monasca/"

# [keystone_authtoken]
memcached_servers: "{% for x in MON.consumes_FND_MEM.members.private %}{{ x.host }}:{{ x.port }}{%if
 not loop.last %},{% endif %}{% endfor %}"
memcache_secret_key: "{{ MON.consumes_FND_MEM.vars.memcached.monasca.secret_key | quote }}"
070701000000A0000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/handlers070701000000A1000081A40000000000000000000000015EBC1828000002A5000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/handlers/main.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: ardana_notify_monasca_api_apache_restart
  set_fact:
    monasca_api_restart_required: true
070701000000A2000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/meta070701000000A3000081A40000000000000000000000015EBC182800000401000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs the monasca-api part of the Monasca project.
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - monitoring
dependencies:
  - role: FND-AP2
  - role: tls-vars
  - role: monasca-common
070701000000A4000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks070701000000A5000081A40000000000000000000000015EBC1828000003CB000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Monasca API | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in Monasca API package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: monasca_api_package_dependencies
  register: ardana_notify_monasca_api_restart_required
070701000000A6000081A40000000000000000000000015EBC18280000031D000000000000000000000000000000000000005800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: monasca-api | _schedule_restart | Schedule a restart for monasca-api
  debug:
    msg: "Trigger a change notification in monasca-api"
  changed_when: true
  register: ardana_notify_monasca_api_restart_required070701000000A7000081A40000000000000000000000015EBC182800000596000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/_set_directories.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2018 SUSE LLC
#
# 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: monasca-api | _set_directories | set service etc directory - configure
  set_fact:
    monasca_api_venv_dir:
      "{{ 'monasca-api' | venv_dir(install_package_result.version) }}"
    monasca_api_conf_dir:
      "{{ 'monasca-api' | config_dir(install_package_result.version) }}"
    monasca_api_bin_dir:
      "{{ 'monasca-api' | bin_dir(install_package_result.version) }}"
  when: install_package_result.version is defined

- name: monasca-api | _set_directories | set service etc directory - reconfigure
  set_fact:
    monasca_api_venv_dir:
      "{{ 'monasca-api' | venv_dir() }}"
    monasca_api_conf_dir:
      "{{ 'monasca-api' | config_dir() }}"
    monasca_api_bin_dir:
      "{{ 'monasca-api' | bin_dir() }}"
  when: install_package_result.version is undefined
070701000000A8000081A40000000000000000000000015EBC1828000013A5000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/configure-pythonimpl.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---

- include: ./_set_directories.yml
  vars:
    install_package_result: "{{ ardana_notify_monasca_api_install_result }}"

- name: setup group
  group: name={{monasca_group}} system=yes
  notify: ardana_notify_monasca_api_apache_restart

- name: Setup user
  user:
    name: "{{ monasca_api_user }}"
    system: yes
    group: "{{ monasca_group }}"
    shell: "{{ monasca_api_shell }}"
    move_home: yes
    home: "{{ monasca_api_home }}"
  notify: ardana_notify_monasca_api_apache_restart

- name: monasca-api | configure-pythonimpl | configure api config ini file
  become: yes
  template:
    src: api-config.ini.j2
    dest: "{{ monasca_api_conf_dir }}/api-config.ini"
    owner: "{{ monasca_api_user }}"
    group: "{{ monasca_group }}"
    mode: 0600
  notify: ardana_notify_monasca_api_apache_restart

- name: monasca-api | configure-pythonimpl | configure api config conf file
  become: yes
  template:
    src: api-config.conf.j2
    dest: "{{ monasca_api_conf_dir }}/api-config.conf"
    owner: "{{ monasca_api_user }}"
    group: "{{ monasca_group }}"
    mode: 0600
  notify: ardana_notify_monasca_api_apache_restart

- name: monasca-api | configure-pythonimpl | configure api logging conf file
  become: yes
  template:
    src: api-logging.conf.j2
    dest: "{{ monasca_api_conf_dir }}/api-logging.conf"
    owner: "{{ monasca_api_user }}"
    group: "{{ monasca_group }}"
    mode: 0600
  notify: ardana_notify_monasca_api_apache_restart

#
# create modwsgi file for monasca-api
#

- name: "monasca-api | install-pythonimpl | Create {{ www_root }}/monasca directory"
  become: yes
  file:
    path: "{{ www_root }}/monasca"
    owner: root
    group: "{{ monasca_group }}"
    mode: 0755
    state: directory
    recurse: yes

- name: monasca-api | configure-pythonimpl | configure monasca-api wsgi file
  become: yes
  template:
    src: monasca-api.wsgi.j2
    dest: "{{ monasca_api_bin_dir }}/../lib/python2.7/site-packages/monasca_api/monasca-api.wsgi"
    owner: "{{ monasca_api_user }}"
    group: "{{ monasca_group }}"
    mode: 0755
  notify: ardana_notify_monasca_api_apache_restart

- name: monasca-api | configure-pythonimpl | configure monasca-api apache virtualhost
  become: yes
  template:
    src: monasca-api-apache2.conf.j2
    dest: "{{ apache2_vhost_dir }}/monasca-api-apache2.vhost"
    mode: 0755
  notify: ardana_notify_monasca_api_apache_restart

- name: create monasca log dir
  file: path={{monasca_log_dir}} state=directory owner=root group=root mode=0775
  notify: ardana_notify_monasca_api_apache_restart

- name: create api log dir
  file: path={{api_log_dir}} state=directory owner=mon-api group=adm mode=0775
  notify: ardana_notify_monasca_api_apache_restart

- name: monasca-api | configure-pythonimpl | set monasca-api log file ownership
  file:
    path: "{{ item }}"
    state: touch
    owner: "{{ monasca_api_user }}"
    group: "adm"
    mode: 0640
  with_items:
    - "{{ api_log_dir }}/monasca-api.log"
    - "{{ api_log_dir }}/request.log"

- name: monasca-api | configure-pythonimpl | set monasca-api apache log file ownership
  file:
    path: "{{ item }}"
    state: touch
    owner: "{{ monasca_api_user }}"
    group: "adm"
    mode: 0640
  with_items:
    - "{{ monasca_log_dir }}/api/monasca_api_wsgi.log"
    - "{{ monasca_log_dir }}/api/monasca_api_wsgi-access.log"

- name: monasca-api | configure-pythonimpl | Create Symlinks for other config files from install
  file:
    src: "{{ monasca_api_conf_dir }}/{{ item }}"
    dest: "{{ monasca_global_conf_dir }}/{{ item }}"
    owner: "{{ monasca_api_user }}"
    group: "{{ monasca_group }}"
    state: link
    mode: 0750
  with_items:
    - api-config.conf
    - api-config.ini
    - api-logging.conf
  become: yes

- name: monasca-api | configure-pythonimpl | Create symbolic link for startup file
  become: yes
  file:
    src: "{{ monasca_api_venv_dir }}/lib/python2.7/site-packages\
          /monasca_api/monasca-api.wsgi"
    dest: "{{ www_root }}/monasca/monasca-api"
    owner: root
    group: "{{ monasca_group }}"
    state: link

- include: pre_upgrade.yml
  when:
    - inventory_hostname in groups['MON-API--first-member']

# Attempt to run this task on the first node
- name: monasca-api | configure-pythonimpl | Create the database scheme using monasca_db
  shell: "{{ monasca_api_bin_dir }}/monasca_db upgrade"
  run_once_per: verb_hosts.MON_API
070701000000A9000081A40000000000000000000000015EBC1828000017C6000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/configure.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: setup group
  group: name={{monasca_group}} system=yes
  register: ardana_notify_monasca_api_restart_required

- name: Setup user
  user:
    name: "{{ monasca_api_user }}"
    system: yes
    group: "{{ monasca_group }}"
    shell: "{{ monasca_api_shell }}"
    move_home: yes
    home: "{{ monasca_api_home }}"
  register: ardana_notify_monasca_api_restart_required

- name: Detect if this is a systemd based system
  command: cat /proc/1/comm
  register: init
- set_fact: use_systemd=True
  when: init.stdout == 'systemd'
- set_fact: use_systemd=False
  when: init.stdout != 'systemd'

- name: create systemd config
  template: dest={{api_systemd_service}} owner=root group=root mode=0644 src=monasca-api.service.j2
  register: ardana_notify_monasca_api_restart_required
  when: use_systemd

- command: systemctl daemon-reload
  when: use_systemd

- name: create upstart script from template
  template: dest=/etc/init/monasca-api.conf owner=root group=root mode=0744 src=monasca-api.conf.j2
  register: ardana_notify_monasca_api_restart_required
  when: not use_systemd

- name: create monasca log dir
  file: path={{monasca_log_dir}} state=directory owner=root group=root mode=0775
  register: ardana_notify_monasca_api_restart_required

- name: create api log dir
  file: path={{api_log_dir}} state=directory owner=mon-api group=adm mode=0775
  register: ardana_notify_monasca_api_restart_required

- name: set monasca-api log file ownership
  file:
    path: "{{ item }}"
    state: touch
    owner: "{{ monasca_api_user }}"
    group: "adm"
    mode: 0640
  with_items:
    - "{{ api_log_dir }}/monasca-api.log"
    - "{{ api_log_dir }}/request.log"

- name: stat /etc/monasca/api-config.yml file
  stat: path=/etc/monasca/api-config.yml
  register: api_conf_file_result

- name: move api-config.yml to api-config.yml.old if not a symlink
  command: mv /etc/monasca/api-config.yml /etc/monasca/api-config.yml.old
  when: api_conf_file_result.stat.exists and api_conf_file_result.stat.isreg

- name: stat old api jar
  stat: path=/opt/stack/service/monasca/venv/lib/monasca-api-1.1.0.9-SNAPSHOT-shaded.jar
  register: old_api_jar_result

- name: use old config if old api jar
  set_fact:
    old_api_jar: True
  when: old_api_jar_result.stat.exists

- name: create conf_file from template
  template: dest={{ monasca_api_conf_file }} owner={{monasca_api_user}} group={{monasca_group}} mode=0640 src=api-config.yml.j2
  register: ardana_notify_monasca_api_restart_required

- name: link /etc/monasca/api-config.yml to service config dir
  file:
    path: /etc/monasca/api-config.yml
    src: "{{ 'monasca' | config_dir() }}/api-config.yml"
    state: link
    owner: "{{monasca_api_user}}"
    group: "{{monasca_group}}"
    mode: 0640

# Attempt to run this task on the first node
- name: Create the database scheme using monasca_db
  shell: "{{ monasca_api_bin_dir }}/monasca_db upgrade"
  run_once_per: verb_hosts.MON_API
  register: ardana_notify_monasca_api_restart_required

- name: Copy Truststore
  copy: dest={{monasca_api_truststore}} src={{monasca_api_truststore_src}}
  when: monasca_api_truststore_src is defined
  register: ardana_notify_monasca_api_restart_required

- name: monasca-api | configure | register restart to load changed truststore
  debug: msg="ardana_notifiy_monasca_api_restart_required changed status"
  register: ardana_notify_monasca_api_restart_required
  changed_when: True
  when: ( ardana_notify_certs_updated is defined )
    and ( run_mode == 'Configure' or run_mode == 'Upgrade' )

- name: Copy Client Keystore
  copy: dest={{monasca_api_client_keystore}} src={{monasca_api_client_keystore_src}}
  when: monasca_api_client_keystore_src is defined
  register: ardana_notify_monasca_api_restart_required

- name: Copy Keystore
  copy: dest={{monasca_api_keystore}} src={{monasca_api_keystore_src}}
  when: monasca_api_keystore_src is defined
  register: ardana_notify_monasca_api_restart_required

- name: Create directory for storing md5sums
  file:
    path: "{{ monasca_api_jar_saved_md5 | dirname }}"
    state: directory
    owner: root
    group: root
    mode: 0755

- name: Determine md5 of monasca-api jar
  stat:
    path: "{{ monasca_api_jar }}"
    follow: yes
  register: monasca_api_jar_result

- name: Check if current md5 exists
  stat:
    path: "{{ monasca_api_jar_saved_md5 }}"
  register: monasca_api_jar_old_md5_file_result

- name: Get the current md5 if it exists
  slurp:
    src: "{{ monasca_api_jar_saved_md5 }}"
  when: monasca_api_jar_old_md5_file_result.stat.exists
  register: monasca_api_jar_old_md5_result

- name: Mark Monasca API for restart if new monasca-api jar
  debug: msg="restart monasca-api because monasca-api jar changed"
  changed_when: True
  when: not monasca_api_jar_old_md5_file_result.stat.exists or
        ( monasca_api_jar_old_md5_file_result.stat.exists and
          ( monasca_api_jar_result.stat.md5 !=
            ( monasca_api_jar_old_md5_result.content | b64decode ) ) )
  register: ardana_notify_monasca_api_restart_required

- name: Write md5sum if changed or not written yet
  copy:
    dest: "{{ monasca_api_jar_saved_md5 }}"
    content: "{{ monasca_api_jar_result.stat.md5 }}"
  when: not monasca_api_jar_old_md5_file_result.stat.exists or
        ( monasca_api_jar_old_md5_file_result.stat.exists and
          ( monasca_api_jar_result.stat.md5 !=
            ( monasca_api_jar_old_md5_result.content | b64decode ) ) )
070701000000AA000081A40000000000000000000000015EBC1828000007DE000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/install-pythonimpl.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-api| install-pythonimpl | Update venv cache
  become: yes
  install_package:
    cache: update

- name: monasca-api | install-pythonimpl | Installing Monasca API python code
  become: yes
  install_package:
    name: "monasca"
    service: monasca-api
    state: present
    activate: act_off
  register: ardana_notify_monasca_api_install_result

- name: monasca-api | install-pythonimpl | Register restart required
  command: echo "monasca api restart required"
  register: ardana_notify_monasca_api_venv_changed_result
  when: ardana_notify_monasca_api_install_result.changed

- name: monasca-api | install-pythonimpl | Register restart required
  command: echo "monasca api restart required"
  notify: ardana_notify_monasca_api_apache_restart
  when: ardana_notify_monasca_api_install_result.changed

- name: monasca-api | install-pythonimpl | Set service conf directories
  set_fact:
    monasca_api_conf_dir: "{{ 'monasca-api' |
      config_dir(ardana_notify_monasca_api_install_result.version) }}"
    monasca_api_venv_dir: "{{ 'monasca-api' |
      venv_dir(ardana_notify_monasca_api_install_result.version) }}"
    monasca_api_bin_dir: "{{ 'monasca-api' |
      bin_dir(ardana_notify_monasca_api_install_result.version) }}"

- name: monasca-api | install-pythonimpl | Install modwsgi dependencies
  become: yes
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_api_dependencies
070701000000AB000081A40000000000000000000000015EBC1828000004E5000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/install.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-api | install | Install OS specific required packages
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_api_package_dependencies

- name: Install | Update venv cache
  install_package:
    cache: update

- name: Install | Install the monasca venv
  install_package:
    name: monasca
    service: monasca
    state: present
  register: ardana_notify_monasca_api_restart_required

- name: Install | Set service directories
  set_fact:
    monasca_api_conf_file: "{{ 'monasca' | config_dir(ardana_notify_monasca_api_restart_required.version) }}/api-config.yml"
070701000000AC000081A40000000000000000000000015EBC182800000881000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-api | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

#
# monasca-api java
#
- include: stop.yml
  when: (run_mode == 'Stop' or run_mode == 'Upgrade') and monasca_api_implementation_lang == 'java'

- include: _check_upgraded_pkgs.yml
  when: run_mode == 'Upgrade'

- include: install.yml
  when: not skip_install and ( run_mode == 'Install' or run_mode == 'Deploy' or run_mode == 'Upgrade' ) and monasca_api_implementation_lang == 'java'

- include: configure.yml
  when: (run_mode == 'Configure' or run_mode == 'Deploy' or run_mode == 'Upgrade') and monasca_api_implementation_lang == 'java'

- include: start.yml
  when: (run_mode == 'Configure' or run_mode == 'Start' or run_mode == 'Deploy' or run_mode == 'Upgrade') and monasca_api_implementation_lang == 'java'

#
# monasca-api python
#
- include: stop-pythonimpl.yml
  when: (run_mode == 'Stop' or run_mode == 'Upgrade') and monasca_api_implementation_lang == 'python'

- include: install-pythonimpl.yml
  when: not skip_install and ( run_mode == 'Install' or run_mode == 'Deploy' or run_mode == 'Upgrade' ) and monasca_api_implementation_lang == 'python'

- include: configure-pythonimpl.yml
  when: (run_mode == 'Configure' or run_mode == 'Deploy' or run_mode == 'Upgrade') and monasca_api_implementation_lang == 'python'

- include: start-pythonimpl.yml
  when: (run_mode == 'Configure' or run_mode == 'Start' or run_mode == 'Deploy' or run_mode == 'Upgrade') and monasca_api_implementation_lang == 'python'
070701000000AD000081A40000000000000000000000015EBC182800000A0D000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/pre_upgrade.yml#
# (c) Copyright 2019 SUSE LLC
#
# 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.
#
---

# This task list should be run only on the MON-API--first-member
# nodes as per the when condition where it is included in the
# configure-pythonimpl.yml task list.
- name: monasca-api | pre_upgrade | Confirm running on MON-API first member
  fail:
    msg: >-
      This task list should only be being run on the first member of
      the MON-API group for a given control plane cluster.
  when:
    - inventory_hostname not in groups['MON-API--first-member']

# The alignment script will only be generated if we are running as part
# of an upgrade, so check for it's existence
- name: monasca-api | pre_upgrade | Check if schema alignment script exists?
  stat:
    path: "{{ monasca_mysql_schema_sync_script_file }}"
  register: schema_align_script_exists_result

# NOTE(gyee): prior to stable/rocky, Monasca DB schema was a wild, wild, west.
# In other words, there was no "official version" of the schema. It was
# left up to the vendors. In stable/rocky, Monasca established an
# official version of the schema, and it was stamp (or fingerprinted) with
# each migration step. 'f69cb3152a76' was the last known fingerprint in
# stable/rocky so we'll fix up our schema to align with the official
# stable/rocky version prior to the migration and then stamp the resulting
# database with that fingerprint marker.
- name: monasca-api | pre_upgrade | Align schema with upstream
  command: /usr/bin/python {{ monasca_mysql_schema_sync_script_file }}
  when:
    - schema_align_script_exists_result.stat.exists

- name: monasca-api | pre_upgrade | Stamp database with a known fingerprint
  command: >
    {{ monasca_api_bin_dir }}/monasca_db stamp
     'f69cb3152a76'
  register: ardana_notify_monasca_api_restart_required
  when:
    - schema_align_script_exists_result.stat.exists

- name: monasca-api | pre_upgrade | remove schema alignment script
  file:
    dest: "{{ monasca_mysql_schema_sync_script_file }}"
    state: absent
  when:
    - schema_align_script_exists_result.stat.exists
070701000000AE000081A40000000000000000000000015EBC1828000006D1000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/start-pythonimpl.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-api | start-pythonimpl | Activate the latest install
  become: yes
  install_package:
    name: monasca_api
    service: monasca-api
    activate: act_on
    version: "{{ ardana_notify_monasca_api_install_result.version }}"
  when: not ardana_notify_monasca_api_install_result is undefined
    and not ardana_notify_monasca_api_install_result.version is undefined

- name: monasca-api | start-pythonimpl | Enable monasca-api vhost
  become: yes
  file:
    src: "{{ apache2_vhost_dir }}/monasca-api-apache2.vhost"
    dest: "{{ apache2_vhost_dir }}/monasca-api-apache2.conf"
    state: link
  notify: ardana_notify_monasca_api_apache_restart

# Set the fact for restart-pythonimpl based on ardana_notify
- name: monasca-api | start-pythonimpl | Set fact monasca api to start on ardana_notify_fact
  meta: flush_handlers

- include: "{{ playbook_dir }}/roles/FND-AP2/tasks/start_reload.yml"
  vars:
    apache_reload_requested: "{{ monasca_api_restart_required }}"
    apache_restart_requested: "{{ monasca_api_restart_required }}"

- name: monasca-api | start-pythonimpl | Unset notify fact
  set_fact:
    monasca_api_restart_required: false
070701000000AF000081A40000000000000000000000015EBC182800000577000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: start | restart monasca-api
  service: name=monasca-api state=restarted enabled=yes
  when: ardana_notify_monasca_api_restart_required is defined and
        ardana_notify_monasca_api_restart_required.changed

- name: start | Start monasca-api
  service: name=monasca-api state=started enabled=yes

- name: start | wait for api port
  wait_for:
    port={{monasca_api_client_port}}
    host={{monasca_api_bind_host | default('127.0.0.1') }}
    state=started timeout={{ monasca_wait_for_period }}
  when: verify

- name: start | wait for api healthcheck metrics port
  wait_for:
    port={{ monasca_admin_client_port }}
    host={{ monasca_api_admin_bind_host }}
    state=started
    timeout={{ monasca_wait_for_period }}
  when: verify
070701000000B0000081A40000000000000000000000015EBC1828000003EE000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/stop-pythonimpl.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-api | stop-pythonimpl | Disable apache site
  become: yes
  file:
    dest: "{{ apache2_vhost_dir }}/monasca-api-apache2.conf"
    state: absent

# Reload Apache, ignore errors, if reload fails in stop as apache not
# running, keep going
- name: monasca-api | stop-pythonimpl | Reload apache after disabling monasca-api
  become: yes
  service:
    name: apache2
    state: reloaded
  ignore_errors: yes
070701000000B1000081A40000000000000000000000015EBC1828000002C6000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/tasks/stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop Monasca-Api
  service: name=monasca-api state=stopped
070701000000B2000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates070701000000B3000081A40000000000000000000000015EBC182800000F1F000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/api-config.conf.j2[DEFAULT]
log_config_append = /etc/monasca/api-logging.conf
region = region1

# Dispatchers to be loaded to serve restful APIs
[dispatcher]
versions = monasca_api.v2.reference.versions:Versions
version_2_0 = monasca_api.v2.reference.version_2_0:Version2
metrics = monasca_api.v2.reference.metrics:Metrics
metrics_measurements = monasca_api.v2.reference.metrics:MetricsMeasurements
metrics_statistics = monasca_api.v2.reference.metrics:MetricsStatistics
metrics_names = monasca_api.v2.reference.metrics:MetricsNames
alarm_definitions = monasca_api.v2.reference.alarm_definitions:AlarmDefinitions
alarms = monasca_api.v2.reference.alarms:Alarms
alarms_count = monasca_api.v2.reference.alarms:AlarmsCount
alarms_state_history = monasca_api.v2.reference.alarms:AlarmsStateHistory
notification_methods = monasca_api.v2.reference.notifications:Notifications
dimension_values = monasca_api.v2.reference.metrics:DimensionValues
dimension_names = monasca_api.v2.reference.metrics:DimensionNames
notification_method_types = monasca_api.v2.reference.notificationstype:NotificationsType
healthchecks = monasca_api.healthchecks:HealthChecks

[cassandra]
contact_points = {{ cassandra_contact_points }}
keyspace = monasca
user = {{ cassandra_user }}
password = {{ cassandra_password }}

[database]
connection = mysql+pymysql://{{monasca_api_mysql_user}}:{{monasca_api_mysql_password| quote }}@{{mysql_host}}/{{monasca_mysql_db}}?charset=utf8

[kafka]
uri = {{ kafka_hosts }}
partitions = 0

# The topic that metrics will be published too
metrics_topic = metrics

# consumer group name
group = api

# how many times to try when error occurs
max_retry = 1

# wait time between tries when kafka goes down
wait_time = 1

# use synchronous or asynchronous connection to kafka
async = False

# send messages in bulk or send messages one by one.
compact = False


[messaging]
driver = monasca_api.common.messaging.kafka_publisher:KafkaPublisher

[repositories]
# The driver to use for the metrics repository
# Switches depending on backend database in use. Influxdb or Cassandra.

## metrics_driver = monasca_api.common.repositories.influxdb.metrics_repository:MetricsRepository
metrics_driver = monasca_api.common.repositories.cassandra.metrics_repository:MetricsRepository

# The driver to use for the alarm definitions repository
alarm_definitions_driver = monasca_api.common.repositories.sqla.alarm_definitions_repository:AlarmDefinitionsRepository

# The driver to use for the alarms repository
alarms_driver = monasca_api.common.repositories.sqla.alarms_repository:AlarmsRepository

# The driver to use for the notifications repository
notifications_driver = monasca_api.common.repositories.sqla.notifications_repository:NotificationsRepository

# The driver to use for the notification  method type repository
notification_method_type_driver = monasca_api.common.repositories.sqla.notification_method_type_repository:NotificationMethodTypeRepository

[security]
delegate_authorized_roles = monitoring-delegate
read_only_authorized_roles = monasca-read-only-user
agent_authorized_roles = monasca-agent
default_authorized_roles = user, domainuser, domainadmin, monasca-user, admin

[keystone_authtoken]
www_authenticate_uri = {{ keystone_url }}
identity_uri = {{ keystone_url | replace(keystone_port, '35357') }}
region_name = region1
# memcached_servers = localhost:11211
# signing_dir =
memcached_servers = {{ memcached_servers }}
memcache_security_strategy = ENCRYPT
memcache_secret_key = {{ memcache_secret_key }}
memcache_pool_socket_timeout = 1
service_token_roles_required = true
cafile = {{ trusted_ca_bundle }}
project_domain_name = Default
project_name = {{keystone_admin_project}}
user_domain_name = Default
password = {{monasca_keystone_password}}
username = {{monasca_keystone_user}}
auth_url = {{ keystone_url | replace(keystone_port, '35357') }}/v3
auth_type = v3password
070701000000B4000081A40000000000000000000000015EBC182800000287000000000000000000000000000000000000005800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/api-config.ini.j2[DEFAULT]

name = monasca_api

[pipeline:main]
pipeline = request_id auth api

[app:api]
paste.app_factory = monasca_api.api.server:launch

[filter:auth]
paste.filter_factory = monasca_api.healthcheck.keystone_protocol:filter_factory

[filter:request_id]
paste.filter_factory = oslo_middleware.request_id:RequestId.factory

[server:main]
use = egg:gunicorn#main
host = {{ monasca_api_bind_host }}
port = {{ monasca_api_client_port }}
workers = 9
worker-connections = 2000
worker-class = eventlet
timeout = 300
backlog = 2048
keepalive = 2
proc_name = monasca-api
loglevel = INFO

log_config_append = /etc/monasca/api-logging.conf
region = region1
070701000000B5000081A40000000000000000000000015EBC182800001559000000000000000000000000000000000000005800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/api-config.yml.j2{#
#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
# The region for which all metrics passing through this server will be persisted
region: "{{monasca_api_region}}"

maxQueryLimit: 10000

# Whether this server is running on a secure port
accessedViaHttps: {{ monasca_api_protocol_https }}

# Topic for publishing metrics to
metricsTopic: metrics

# Topic for publishing domain events to
eventsTopic: events

{% if not old_api_jar %}
validNotificationPeriods:
  - 60

{% endif %}
kafka:
  brokerUris:
{% for host in kafka_hosts.split(',') %}
    - "{{host}}"
{% endfor %}
  zookeeperUris:
{% for host in zookeeper_hosts.split(',') %}
    - "{{host}}"
{% endfor %}
  healthCheckTopic: healthcheck

mysql:
  driverClass: org.drizzle.jdbc.DrizzleDriver
  url: "jdbc:drizzle://{{mysql_host}}:{{ mysql_port }}/{{monasca_mysql_db}}?connectTimeout=5000&autoReconnect=true&useLegacyDatetimeCode=false&serverTimezone=UTC{{ mysql_https_arg }}"
  user: "{{monasca_api_mysql_user}}"
  password: "{{monasca_api_mysql_password| quote }}"
  maxWaitForConnection: 1s
  validationQuery: "/* MyService Health Check */ SELECT 1"
  minSize: 8
  maxSize: 32
  checkConnectionWhileIdle: false
  checkConnectionOnBorrow: true

databaseConfiguration:
  databaseType: "{{ database_type }}"

# Uncomment if databaseType is influxDB
influxDB:
  # Retention policy may be left blank to indicate default policy.
  retentionPolicy:
  maxHttpConnections: 100
  gzip: true
  name: "{{influxdb_db}}"
  url: "{% if influxdb_url is defined %}{{influxdb_url}}{% endif %}"
  user: "{% if influxdb_user is defined %}{{influxdb_user}}{% endif %}"
  password: "{% if influxdb_password is defined %}{{influxdb_password| quote }}{% endif %}"

middleware:
  enabled: true
  serverVIP: "{{keystone_host}}"
  serverPort: {{keystone_port}}
  useHttps: {{keystone_use_https}}
  truststore: "{{monasca_api_truststore}}"
  truststorePassword: "{{monasca_api_truststore_password}}"
  connTimeout: {{ monasca_api_conn_timeout }}
  connSSLClientAuth: {{keystone_client_auth}}
  keystore: "{{monasca_api_client_keystore}}"
  keystorePassword: "{{monasca_api_client_keystore_password}}"
  connPoolMaxActive: 3
  connPoolMaxIdle: 3
  connPoolEvictPeriod: 600000
  connPoolMinIdleTime: 600000
  connRetryTimes: 2
  connRetryInterval: 50
  defaultAuthorizedRoles: [user, domainuser, domainadmin, monasca-user, admin]
  agentAuthorizedRoles: [monasca-agent]
  delegateAuthorizedRole: monitoring-delegate
  adminAuthMethod: {{keystone_auth_method}}
  adminUser: "{{monasca_keystone_user}}"
  adminPassword: "{{monasca_keystone_password}}"
  adminProjectId:
{% if keystone_admin_project is defined %}
  adminProjectName: "{{keystone_admin_project}}"
{% else %}
  adminProjectName:
{% endif %}
  adminToken:
  timeToCacheToken: 600
  maxTokenCacheSize: 1048576

server:
{% if ansible_processor_vcpus > 32 %}
# Dropwizard 0.7.0 includes a version of Jetty with admin thread issues on large machines, this works around it
  adminMaxThreads: {{ ansible_processor_vcpus * 2 }}
{% endif %}
  applicationConnectors:
{% if monasca_api_keystore is defined %}
    - type: https
      keyStorePath: "{{ monasca_api_keystore }}"
      keyStorePassword: "{{ monasca_api_keystore_password }}"
      validateCerts: false
{% else %}
    - type: http
{% endif %}
{% if monasca_api_bind_host is defined %}
      bindHost: "{{ monasca_api_bind_host }}"
{% endif %}
      port: {{ monasca_api_client_port }}
      maxRequestHeaderSize: 16KiB  # Allow large headers used by keystone tokens
  adminConnectors:
    - type: http
      port: {{ monasca_admin_client_port }}
{% if monasca_api_admin_bind_host is defined %}
      bindHost: "{{ monasca_api_admin_bind_host }}"
{% endif %}
  requestLog:
   timeZone: UTC
   appenders:
    - type: file
      currentLogFilename: "{{api_log_dir}}/request.log"
      threshold: ALL
      archive: false
      archivedLogFilenamePattern: "{{api_log_dir}}/request-%d.log.gz"
      archivedFileCount: 5

# Logging settings.
logging:

  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
  level: {{ monasca_log_level }}

  # Explicitly sets the log level for certain individual loggers
  loggers:

    # If these two loggers are set to DEBUG or below it will cause CPU to raise to levels that could cause problems on
    # the node and could lead to the api running out of memory.
    kafka.producer.async.DefaultEventHandler: WARN
    kafka.producer.BrokerPartitionInfo: WARN

    org.apache.http.headers: WARN
    org.apache.http.wire: WARN

  appenders:
    - type: file
      currentLogFilename: "{{api_log_dir}}/monasca-api.log"
      threshold: ALL
      archive: false
      archivedLogFilenamePattern: "{{api_log_dir}}/monasca-api-%d{yyyy-MM-dd-hh}.log.gz"
      archivedFileCount: {{ monasca_log_rotation_backup_count }}
      timeZone: UTC
      logFormat: # TODO
070701000000B6000081A40000000000000000000000015EBC182800000356000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/api-logging.conf.j2[loggers]
keys = root, sqlalchemy, kafka

[handlers]
keys = console, file

[formatters]
keys = context

[logger_root]
level = WARN
handlers = console, file

[logger_sqlalchemy]
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither.  (Recommended for production systems.)
level = WARN
handlers = console, file
propagate=0

[logger_kafka]
qualname = kafka
level = WARN
handlers = console, file
propagate = 0

[handler_console]
class = logging.StreamHandler
args = (sys.stderr,)
level = WARN
formatter = context

[handler_file]
class = logging.handlers.RotatingFileHandler
level = WARN
formatter = context
# store up to 5*100MB of logs
args = ('/var/log/monasca/api/monasca-api.log', 'a', 104857600, 5)

[formatter_context]
class = oslo_log.formatters.ContextFormatter
070701000000B7000081A40000000000000000000000015EBC182800000603000000000000000000000000000000000000006200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/monasca-api-apache2.conf.j2{#
#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
Listen {{ monasca_api_bind_host }}:{{ monasca_api_client_port }}

<VirtualHost *:{{ monasca_api_client_port }}>
    WSGIDaemonProcess monasca-api processes=4 threads=5 socket-timeout=600  user={{ monasca_api_user }} group={{ monasca_group }} python-path={{ monasca_api_bin_dir }}/../:{{ monasca_api_bin_dir }}/../lib/python2.7/site-packages display-name=monasca-api
    WSGIProcessGroup monasca-api
    WSGIApplicationGroup monasca-api
    WSGIScriptAlias / {{ www_root }}/monasca/monasca-api

    ErrorLog /var/log/monasca/api/monasca_api_wsgi.log
    LogLevel info
    CustomLog /var/log/monasca/api/monasca_api_wsgi-access.log combined

    <Directory {{ monasca_api_bin_dir }}/../lib/python2.7/site-packages/monasca_api>
      Options Indexes FollowSymLinks MultiViews
      Require all granted
      AllowOverride None
      Order allow,deny
      allow from all
      LimitRequestBody 409600
    </Directory>

    SetEnv no-gzip 1
</VirtualHost>
070701000000B8000081A40000000000000000000000015EBC182800000416000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/monasca-api.conf.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
# Startup script for the Monasca API

description "Monasca API java app"
start on runlevel [2345]

console log
respawn

setgid {{ monasca_group }}
setuid {{ monasca_api_user }}
exec /usr/bin/java {{ monasca_api_java_opts }} -cp {{ monasca_jars_virtualenv_dir }}/lib/monasca-api-{{monasca_api_version}}-shaded.jar monasca.api.MonApiApplication server {{ 'monasca' | config_dir() }}/api-config.yml
070701000000B9000081A40000000000000000000000015EBC18280000041A000000000000000000000000000000000000005D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/monasca-api.service.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Monasca Api
After=kafka.service influxdb.service mysql.service

[Service]
Type=simple
User={{ monasca_api_user }}
Group={{ monasca_group }}
LimitNOFILE=32768
Restart=on-failure
ExecStart=/usr/bin/java {{ monasca_api_java_opts }} -cp {{ monasca_api_jar }} monasca.api.MonApiApplication server {{ 'monasca' | config_dir() }}/api-config.yml

[Install]
WantedBy=multi-user.target
070701000000BA000081A40000000000000000000000015EBC182800000066000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/templates/monasca-api.wsgi.j2from monasca_api.api import server
application = server.get_wsgi_app(config_base_path='/etc/monasca')
070701000000BB000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/vars070701000000BC000081A40000000000000000000000015EBC1828000003B3000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/vars/debian.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_api_package_dependencies:
  - default-jre-headless

monasca_api_dependencies:
  - libapache2-mod-wsgi
  - libssl-dev
  - libapache2-mod-shib2
  - libffi-dev
  - libmysqlclient18
  - python-httplib2 # Required for ansible url plugin

monasca_api_truststore: "/usr/lib/jvm/default-java/jre/lib/security/cacerts"
monasca_api_truststore_password: "changeit"
070701000000BD000081A40000000000000000000000015EBC182800000366000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/vars/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_api_user: mon-api
monasca_group: monasca
api_log_dir: "{{ monasca_log_dir }}/api"
monasca_api_conf_file: "{{ 'monasca' | config_dir() }}/api-config.yml"
api_systemd_service: /etc/systemd/system/monasca-api.service
070701000000BE000081A40000000000000000000000015EBC1828000003A7000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-api/vars/suse.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_api_package_dependencies:
  - java-1_8_0-openjdk-headless

monasca_api_dependencies:
  - apache2-mod_wsgi
  - libopenssl1_0_0
  - shibboleth-sp
  - libffi4
  - libmysqlclient18
  - python-httplib2 # Required for ansible url plugin

monasca_api_truststore: "/usr/lib64/jvm/jre/lib/security/cacerts"
monasca_api_truststore_password: "changeit"
070701000000BF000041ED0000000000000000000000035EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-common070701000000C0000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-common/defaults070701000000C1000081A40000000000000000000000015EBC1828000002B1000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-common/defaults/main.yml#
# (c) Copyright 2019 SUSE LLC
#
# 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.
#
---
mysql_schema_dir: /root
monasca_mysql_schema_sync_script_file: "{{ mysql_schema_dir }}/mysql_schema_sync.py"
070701000000C2000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms070701000000C3000081A40000000000000000000000015EBC1828000009D2000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/README.md# monasca-default-alarms

This role will setup a default alarm definition configuration for Monasca. It also provides an Ansible module for creation
of Monasca alarm definitions and notifications. More details on alarm definitions can be found at the
[Monasca API documentation](https://github.com/stackforge/monasca-api/blob/master/docs/monasca-api-spec.md#alarm-definitions-and-alarms)

##Requirements
It is assumed the service endpoint for Monasca is properly registered in keystone.

##Role Variables

These variables must be defined.

- keystone_url
- monasca_keystone_user
- monasca_keystone_password

By default the configured alarm definitions will be setup with a notification to root@localhost change the `default_email` variable to modify.

## Example Playbook

    - name: Define default alarm definitions
      hosts: mini-mon
      gather_facts: no
      vars:
        keystone_url: http://192.168.10.5:35357/v3/
        monasca_keystone_user: mini-mon
        monasca_keystone_password: password
      roles:
        - {role: monasca-default-alarms, tags: [alarms]}

## Monasca Modules Usage
There are two modules available in the library subdirectory, one for Monasca notifications and the other for alarm definitions. For example:

    - name: Setup default email notification method
      monasca_notification_method:
        name: "Default Email"
        type: 'EMAIL'
        address: "root@localhost"
        keystone_url: "{{ keystone_url }}"
        keystone_user: "{{ monasca_keystone_user }}"
        keystone_password: "{{ monasca_keystone_password }}"
        keystone_project: "{{ monasca_keystone_project }}"
      register: default_notification_result
    - name: Host Alive Alarm
      monasca_alarm_definition:
        name: "Host Alive Alarm"
        description: "Trigger when a host alive check fails"
        expression: "host_alive_status > 0"
        monasca_keystone_token: "{{ default_notification_result.keystone_token }}"
        monasca_api_url: "{{ default_notification_result.monasca_api_url }}"
        severity: "HIGH"
        alarm_actions:
          - "{{ default_notification_result.notification_method_id }}"
        ok_actions:
          - "{{ default_notification_result.notification_method_id }}"
        undetermined_actions:
          - "{{ default_notification_result.notification_method_id }}"

Refer to the documentation within the module for full detail


##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
070701000000C4000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/defaults070701000000C5000081A40000000000000000000000015EBC1828000005FD000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
notification_address: root@localhost
notification_name: 'Default Email'
notification_type: EMAIL

monasca_keystone_url: "{{ KEY_API.advertises.vips.private[0].url }}/v3"
monasca_api_url: "{{ MON_AGN.consumes_MON_API.vips.private[0].url }}/v2.0"
monasca_keystone_user: "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_user }}"
monasca_keystone_password: "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_password | quote }}"
monasca_keystone_project: "{{ KEY_API.vars.keystone_admin_tenant }}"
monasca_keystone_project_domain: "Default"
monasca_keystone_user_domain: "Default"
system_cacert_file: "{{ trusted_ca_bundle }}"

monasca_client_venv: "{{ monasca_agent_virtualenv_dir }}"

monasca_create_definitions: False

monasca_client_retries: 3
monasca_client_retry_delay: 2

monasca_warn_cert_expire_days: 14
monasca_critical_cert_expire_days: 1
monasca_cert_check_period: 3600
070701000000C6000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/meta070701000000C7000081A40000000000000000000000015EBC182800000420000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Sets up default alarm definitions for Monasca
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: GenericLinux
    versions:
    - all
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - monitoring
dependencies:
  - role: monasca-alarm-definition
  - role: tls-vars
070701000000C8000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/tasks070701000000C9000081A40000000000000000000000015EBC182800000875000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/tasks/cleanup.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-default-alarms | cleanup | Install Nova Client (rpm)
  zypper:
    name: python-novaclient
    state: present
  become: yes
  when: service_topology.services.nova is defined and
        service_topology.services.nova.components['nova-compute']['control_planes'] is defined

- name: monasca-default-alarms | cleanup | Set path for vm_alarm_cleanup.py
  set_fact:
    vm_alarm_cleanup: "/usr/local/bin/vm_alarm_cleanup.py"

- name: monasca-default-alarms | cleanup | Add VM alarm cleanup cron job
  template:
    src: vm_alarm_cleanup.py.j2
    dest: "{{ vm_alarm_cleanup }}"
    owner: root
    group: root
    mode: 0700
  become: yes
  when: service_topology.services.nova is defined and
        service_topology.services.nova.components['nova-compute']['control_planes'] is defined
- name: monasca-default-alarms | cleanup | Remove obsolete file
  file:
    path: "/opt/monasca/bin/vm_alarm_cleanup"
    state: absent
  become: yes
  when: service_topology.services.nova is defined and
        service_topology.services.nova.components['nova-compute']['control_planes'] is defined
- name: monasca-default-alarms | cleanup | Add VM alarm cleanup to crontab
  cron:
    name: "Alarm cleanup for deleted VMs"
    minute: "*/5"
    job: "{{vm_alarm_cleanup}} 2>&1 | /usr/bin/logger -t vm_alarm_cleanup"
    state: present
  become: yes
  run_once: True
  when: service_topology.services.nova is defined and
        service_topology.services.nova.components['nova-compute']['control_planes'] is defined
070701000000CA000081A40000000000000000000000015EBC182800000C38000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/tasks/main.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-default-alarms | main | Setup default notification method
  monasca_notification_method:
    name: "{{ notification_name }}"
    type: "{{ notification_type }}"
    address: "{{ notification_address }}"
    keystone_url: "{{ monasca_keystone_url }}"
    keystone_user: "{{ monasca_keystone_user }}"
    keystone_password: "{{ monasca_keystone_password }}"
    keystone_project: "{{ monasca_keystone_project }}"
    keystone_project_domain: "{{ monasca_keystone_project_domain }}"
    keystone_user_domain: "{{ monasca_keystone_user_domain }}"
    keystone_verify: "{{ system_cacert_file }}"
    monasca_api_url: "{{ monasca_api_url }}"
  no_log: True
  tags:
    - system_alarms
    - monasca_alarms
    - openstack_alarms
  register: default_notification_result
  until: not default_notification_result | failed
  retries: "{{ monasca_client_retries }}"
  delay: "{{ monasca_client_retry_delay }}"

- name: monasca-default-alarms | main | Create Alarm Definitions
  monasca_alarm_definition:
    name: "{{ item.name }}"
    description: "{{ item.description | default('') }}"
    expression: "{{ item.expression }}"
    keystone_url: "{{ monasca_keystone_url }}"
    keystone_user: "{{ monasca_keystone_user }}"
    keystone_password: "{{ monasca_keystone_password }}"
    keystone_project: "{{ monasca_keystone_project }}"
    keystone_project_domain: "{{ monasca_keystone_project_domain }}"
    keystone_user_domain: "{{ monasca_keystone_user_domain }}"
    keystone_verify: "{{ system_cacert_file }}"
    match_by: "{{ item.match_by | default(['hostname']) }}"
    monasca_api_url: "{{ default_notification_result.monasca_api_url }}"
    severity: "{{ item.severity | default('LOW') }}"
    alarm_actions:
      - "{{ default_notification_result.notification_method_id }}"
    ok_actions:
      - "{{ default_notification_result.notification_method_id }}"
    undetermined_actions:
      - "{{ default_notification_result.notification_method_id }}"
  register: monasca_system_alarms_result
  until: not monasca_system_alarms_result | failed
  retries: "{{ monasca_client_retries }}"
  delay: "{{ monasca_client_retry_delay }}"
  with_flattened:
    - monasca_alarm_definitions_system
    - monasca_alarm_definitions_monasca
    - monasca_alarm_definitions_openstack
    - monasca_alarm_definitions_misc_services
  when: monasca_create_definitions

# Add alarm cleanup tasks
- include: cleanup.yml tags=openstack_alarms
  when: monasca_create_definitions
070701000000CB000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/templates070701000000CC000081A40000000000000000000000015EBC182800001580000000000000000000000000000000000000006800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/templates/vm_alarm_cleanup.py.j2#!/usr/bin/env python
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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 fcntl
from sys import exit, path, stdout

from keystoneauth1.identity import v3
from keystoneauth1 import session, exceptions as ksexceptions
from monascaclient import client as mnclient
from novaclient import client as nvclient, exceptions as nvexceptions
from requests import exceptions as rqexceptions


# Goes through all metrics in an alarm
# Returns true if there is one VM that exists
# Returns false if there are no existing VMs in the alarm
def checkAlarm(existing_resource_ids, alarm):
    for metric in alarm['metrics']:
        resource_id = metric.get('dimensions').get('resource_id')
        if resource_id is not None:
            if resource_id in existing_resource_ids:
                return True
            try:
                control_plane = metric.get('dimensions').get('control_plane')
                # If the control plane defined in the metric no longer exists
                # We can safely delete the alarm
                if control_plane not in nova_clients:
                    continue
                nova_clients[control_plane].servers.get(resource_id)
                existing_resource_ids.add(resource_id)
                return True
            except nvexceptions.NotFound:
                pass
            except ksexceptions.connection.ConnectFailure as e:
                print ('Nova could not connect to Keystone. '
                       'ConnectFailure message={}'.format(e.message))
                exit (1)
            except rqexceptions.ConnectionError as e:
                print ('Nova is down. Exiting now '
                       'with ConnectionError message={}'.format(e.message))
                exit (1)
    return False

# Ensure only one instance is running
# This lock will be deleted when the process exits
pid_file = '/var/tmp/pid_vm_alarm_cleanup'
fp = open(pid_file, 'w')
try:
    fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
    print 'vm_alarm_cleanup was already running. Exiting now.'
    exit(0)

# Start a monasca client
username = "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_user }}"
password = "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_password }}"
auth_url = "{{ KEY_API.advertises.vips.private[0].url }}/v3"
monasca_URL =  "{{ MON_AGN.consumes_MON_API.vips.private[0].url }}/v2.0"
project_name = "{{ KEY_API.vars.keystone_admin_tenant }}"
project_domain_name = "{{ KEY_API.vars.keystone_default_domain }}"
user_domain_name = "{{ KEY_API.vars.keystone_default_domain }}"
endpoint_type = 'internalURL'
monasca_version = '2_0'
ks_kwargs = {'username': username,
             'password': password,
             'project_name': project_name,
             'project_domain_name': project_domain_name,
             'user_domain_name': user_domain_name,
             'auth_url': auth_url}
monasca_client = mnclient.Client(monasca_version, monasca_URL, **ks_kwargs)

# Build a list of unique undetermined VM alarm IDs
dimension_args = {'component': 'vm'}
list_args = {'state' : 'UNDETERMINED',
             'metric_dimensions' : dimension_args}
try:
    alarm_list = monasca_client.alarms.list(**list_args)
except Exception as e:
    print ('monasca alarm-list failed with Monascaclient Exception: '
           '{}'.format(e.message))
    exit (1)

# Exit if no action is necessary
if not alarm_list:
    print 'Nothing to delete. Exiting now.'
    exit(0)

# Start a nova client for every region
control_planes = {{ service_topology.services.nova.components['nova-compute']['control_planes'] }}
auth_kwargs = v3.Password(auth_url=auth_url,
                          username=username,
                          password=password,
                          project_name=project_name,
                          user_domain_name=user_domain_name,
                          project_domain_name=project_domain_name)
sess = session.Session(auth=auth_kwargs)
nova_clients = dict()
for control_plane in control_planes:
    region = control_planes[control_plane]['regions'][0]
    nova_client = nvclient.Client('2.1',
                                  endpoint_type=endpoint_type,
                                  region_name=region,
                                  session=sess)
    nova_clients[control_plane] = nova_client

existing_resource_ids = set()
# Delete alarm IDs for VMs that no longer exist
for alarm in alarm_list:
    if not checkAlarm(existing_resource_ids, alarm):
        # Delete alarm, only output status if run from command line (not cron)
        if stdout.isatty():
            print 'Deleting alarm {} for non-existent VM'.format(alarm['id'])
        try:
            delete_args = {'alarm_id': alarm['id']}
            monasca_client.alarms.delete(**delete_args)
        except Exception as e:
            print ('Failed to delete alarm. Exception '
                   'message={}'.format(e.message))
exit(0)
070701000000CD000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/vars070701000000CE000081A40000000000000000000000015EBC182800001D1A000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-default-alarms/vars/main.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
monasca_alarm_definitions_system:
  - name: "Host Status"
    description: "Alarms when the specified host is down or not reachable"
    severity: "HIGH"
    expression: "host_alive_status > 0"
    match_by:
      - "target_host"
      - "hostname"
  - name: "HTTP Status"
    description: >
      "Alarms when the specified HTTP endpoint is down or not reachable"
    severity: "HIGH"
    expression: "http_status > 0"
    match_by:
      - "service"
      - "component"
      - "hostname"
      - "url"
  - name: "CPU Usage"
    description: "Alarms when CPU usage is high"
    expression: "avg(cpu.idle_perc) < 10 times 3"
  - name: "High CPU IOWait"
    description: "Alarms when CPU IOWait is high, possible slow disk issue"
    expression: "avg(cpu.wait_perc) > 40 times 3"
    match_by:
      - "hostname"
  - name: "Disk Inode Usage"
    description: "Alarms when disk inode usage is high"
    expression: "disk.inode_used_perc > 90"
    match_by:
      - "hostname"
      - "device"
    severity: "HIGH"
  - name: "Disk Usage"
    description: "Alarms when disk usage is high"
    expression: "disk.space_used_perc > 90"
    match_by:
      - "hostname"
      - "device"
    severity: "HIGH"
  - name: "Memory Usage"
    description: "Alarms when memory usage is high"
    severity: "HIGH"
    expression: "avg(mem.usable_perc) < 10 times 3"
  - name: "Network Errors"
    description: >
      "Alarms when either incoming or outgoing network errors are high"
    severity: "MEDIUM"
    expression: "net.in_errors_sec > 5 or net.out_errors_sec > 5"
  - name: "Process Check"
    description: "Alarms when the specified process is not running"
    severity: "HIGH"
    expression: "process.pid_count < 1"
    match_by:
      - "process_name"
      - "hostname"
  - name: "Crash Dump Count"
    description: "Alarms when a crash directory is found"
    severity: "MEDIUM"
    expression: "crash.dump_count > 0"
    match_by:
      - "hostname"

monasca_alarm_definitions_monasca:
  - name: "Kafka Persister Metric Consumer Lag"
    description: "Alarms when the Persister consumer group is not keeping \
                  up with the incoming messages on the metric topic"
    severity: "MEDIUM"
    expression:
      "avg(kafka.consumer_lag{consumer_group=1_metrics}) > \
      {{ monasca_kafka_persister_metrics_max_lag }} times 3"
    match_by:
      - "hostname"
  - name: "Kafka Alarm Transition Consumer Lag"
    description: "Alarms when the specified consumer group is not keeping \
                  up with the incoming messages on the \
                  alarm state transistion topic"
    severity: "MEDIUM"
    expression:
      "avg(kafka.consumer_lag{topic=alarm-state-transitions}) > \
      {{ monasca_kafka_alarms_max_lag }} times 3"
    match_by:
      - "consumer_group"
      - "hostname"
  - name: "Monasca Agent Collection Time"
    description: "Alarms when the elapsed time the Monasca Agent takes to \
                    collect metrics is high"
    expression: >
      avg(monasca.collection_time_sec) > {{ monasca_agent_check_frequency }}
      times 3
  - name: "Cassandra Commit Log Over Recommended Disk Usage"
    description: "Alarms when cassandra commit log exceeds the recommended disk utilization"
    severity: "LOW"
    expression: "max(disk.space_used_perc{mount_point={{ FND_CDB.vars.cassandra_commit_log_dir }}}) > 75"
    match_by:
      - "hostname"
  - name: "Cassandra Commit Log Very High Disk Usage"
    description: "Alarms when Cassandra commit log exceeds 90% disk utilization"
    severity: "HIGH"
    expression: "max(disk.space_used_perc{mount_point={{ FND_CDB.vars.cassandra_commit_log_dir }}}) > 90"
    match_by:
      - "hostname"
  - name: "Cassandra Data Over Recommended Disk Usage"
    description: "Alarms when cassandra data exceeds the recommended disk utilization"
    severity: "LOW"
    expression: "max(disk.space_used_perc{mount_point={{ FND_CDB.vars.cassandra_data_dir }}}) > 75"
    match_by:
      - "hostname"
  - name: "Cassandra Data Very High Disk Usage"
    description: "Alarms when Cassandra data exceeds 90% disk utilization"
    severity: "HIGH"
    expression: "max(disk.space_used_perc{mount_point={{ FND_CDB.vars.cassandra_data_dir }}}) > 90"
    match_by:
      - "hostname"
  - name: "ZooKeeper Latency"
    description: "Alarms when the ZooKeeper latency is high"
    expression: "avg(zookeeper.avg_latency_sec) > 1 times 3"

monasca_alarm_definitions_openstack:
  - name: "Instance CPU Usage"
    description: >
      "Alarms when the CPU usage of the specified instance is high"
    expression: "avg(cpu.utilization_perc) > 90 times 3"
    match_by:
      - resource_id
monasca_alarm_definitions_misc_services:
  - name: "MySQL Slow Query Rate"
    description: "Alarms when the slow query rate is high"
    expression: "avg(mysql.performance.slow_queries) > 10 times 3"
  - name: "Apache Status"
    description: "Alarms on failure to reach the Apache status endpoint"
    expression: "apache.status > 0"
    severity: "HIGH"
  - name: "Apache Idle Worker Count"
    description: >
      "Alarms when there are no idle workers in the Apache server"
    expression: "avg(apache.performance.idle_worker_count) < 1 times 3"
    severity: "MEDIUM"
  - name: "NTP Time Sync"
    description: "Alarms when the NTP time offset is high"
    expression: "ntp.offset > 5 or ntp.offset < -5"
  - name: "NTP Connection Status"
    description: "Alarms when the connection failed to the NTP server"
    expression: "ntp.connection_status > 0"
  - name: "Certificate Expiration Warning"
    description: >
      Alarms when the certificate for an URL is close to expiring
    expression: >
      MIN(https.cert_expire_days, {{ monasca_cert_check_period }}) <
      {{ monasca_warn_cert_expire_days }}
    match_by: "url"
  - name: "Certificate Expiration Critical"
    description: >
      Alarms when the certificate for an URL is extremely close to expiring
    expression: >
      MIN(https.cert_expire_days, {{ monasca_cert_check_period }}) <
      {{ monasca_critical_cert_expire_days }}
    match_by: "url"
    severity: "HIGH"
  - name: "Certificate File Expiration Warning"
    description: >
      Alarms when the certificate file is close to expiring
    expression: >
      MIN(cert_file.cert_expire_days, {{ monasca_cert_check_period }}) <
      {{ monasca_warn_cert_expire_days }}
    match_by:
      - hostname
      - cert_file
      - service
  - name: "Certificate File Expiration Critical"
    description: >
      Alarms when the certificate file is extremely close to expiring
    expression: >
      MIN(cert_file.cert_expire_days, {{ monasca_cert_check_period }}) <
      {{ monasca_critical_cert_expire_days }}
    match_by: 
      - hostname
      - cert_file
      - service
    severity: "HIGH"
070701000000CF000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification070701000000D0000081A40000000000000000000000015EBC182800000649000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/README.md#monasca-notification
Installs the [monasca-notification](https://github.com/stackforge/monasca-notification) in a virtualenv.
Monasca Notification is part of the [Monasca](https://wiki.openstack.org/wiki/Monasca) project.

##Requirements
virtualenv must be installed.

- kafka_hosts - comma seperate list of kafka hosts
- mysql_host
- monasca_notification_mysql_user
- monasca_notification_mysql_password
- smtp_host
- zookeeper_hosts - comma seperate list of zookeeper hosts

Optionally if needed
- pip_index_url: Index URL to use instead of the default for installing pip packages
- smtp_user
- smtp_password
- notification_enable_email: Set to false to disable email notifications
- notification_enable_webhook: Set to false to disable webhook notifications
- notification_enable_pagerduty: Set to false to disable pagerduty notifications
- monasca_log_level: Log level for the Notification log, default to WARN
- mysql_ssl
  - This is a dictionary corresponding to the options in http://dev.mysql.com/doc/refman/5.0/en/mysql-ssl-set.html
  - For Example - {'ca':'/path/to/ca'}
- run_mode: One of Deploy, Stop, Install, Configure or Start. The default is Deploy which will do Install, Configure, then Start.

##Example Playbook

    hosts: monasca
    become: yes
    roles:
      - {role: tkuhlman.monasca-notification,
         monasca_notification_mysql_user: "{{notification_mysql_user}}",
         monasca_notification_mysql_password: "{{notification_mysql_password}}",
         tags: [notification]}

##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
070701000000D1000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/defaults070701000000D2000081A40000000000000000000000015EBC182800000B07000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
alarm_topic: alarm-state-transitions
email_from_address: notification@exampleCloud.com
notification_kafka_group: monasca-notification
notification_topic: alarm-notifications
notification_retry_topic: retry-notifications
notification_enable_email: true
notification_enable_webhook: true
notification_enable_pagerduty: true
notification_enable_hipchat: true
notification_enable_slack: true
retry_interval: 30
retry_max_attempts: 5
zookeeper_notification_path: /notification/alarms
zookeeper_notification_retry_path: /notification/retry
monasca_notification_conf_dir: "{{ 'monasca-notification' | config_dir }}"
monasca_notification_virtualenv_dir: /opt/stack/service/monasca-notification/venv
monasca_log_dir: /var/log/monasca
monasca_log_level: WARN
# In MB
notification_log_max_size: 10
monasca_log_rotation_backup_count: 5
monasca_mysql_db: "{{ MON_NTF.consumes_FND_MDB.vars.databases.monasca.dbname }}"
monasca_notification_shell: /sbin/nologin

run_mode: Deploy
skip_install: False

kafka_nodes: "{{ MON_NTF.consumes_FND_KFK.members.private }}"
kafka_hosts: "{% for node in kafka_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

mysql_host: "{{MON_NTF.consumes_FND_MDB.vips.private[0].host}}"
mysql_ssl: "{% if MON_NTF.consumes_FND_MDB.vips.private[0].use_tls %}{'ca': '{{ trusted_ca_bundle }}'}{% endif %}"
monasca_notification_mysql_user: "{{ MON_NTF.consumes_FND_MDB.vars.accounts.monasca_notifier.username }}"
monasca_notification_mysql_password: "{{ MON_NTF.consumes_FND_MDB.vars.accounts.monasca_notifier.password | quote }}"

notification_enable_email: "{% if smtp.server is defined and smtp.server %}True{% else %}False{% endif %}"

zookeeper_nodes: "{{ MON_NTF.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

# notification_environment can be used to configure proxies if needed.
# Below is an example configuration. Note that all of the quotes are required.
# notification_environment: '"http_proxy=http://<your_proxy>:<port>" "https_proxy=http://<your_proxy>:<port>"'
notification_environment: ''
070701000000D3000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/meta070701000000D4000081A40000000000000000000000015EBC1828000003DF000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs the monasca-notification part of the Monasca project.
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - monitoring
dependencies:
  - role: tls-vars
070701000000D5000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks070701000000D6000081A40000000000000000000000015EBC1828000003C3000000000000000000000000000000000000006400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Monasca Notification | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in Kafka package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: dependencies
  register: ardana_notify_monasca_notification_restart_required
070701000000D7000081A40000000000000000000000015EBC182800000345000000000000000000000000000000000000006100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: monasca-notification | _schedule_restart |
    Schedule a restart for monasca-notification
  debug:
    msg: "Trigger a change notification in monasca-notification"
  changed_when: true
  register: ardana_notify_monasca_notification_restart_required070701000000D8000081A40000000000000000000000015EBC182800000DE9000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/configure.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: setup group
  group: name={{monasca_group}} system=yes
  register: ardana_notify_monasca_notification_restart_required

- name: Setup user
  user:
    name: "{{ notification_user }}"
    system: yes
    group: "{{ monasca_group }}"
    shell: "{{ monasca_notification_shell }}"
    createhome: no
    home: /var/nonexistent
  register: ardana_notify_monasca_notification_restart_required
  failed_when: ardana_notify_monasca_notification_restart_required|failed and
                "user {{ notification_user }} is currently used by process"
                not in ardana_notify_monasca_notification_restart_required.msg

- name: create monasca log dir
  file: path={{monasca_log_dir}} state=directory owner=root group=root mode=0775
  register: ardana_notify_monasca_notification_restart_required

- name: create notification log dir
  file: path={{notification_log_dir}} state=directory owner=mon-notification group=adm mode=0775
  register: ardana_notify_monasca_notification_restart_required

- name: set monasca-notification log file ownership
  file:
    path: "{{ item }}"
    state: touch
    owner: "{{ notification_user }}"
    group: "adm"
    mode: 0640
  with_items:
    - "{{ notification_log_dir }}/notification.log"

- name: stat /etc/monasca/notification.yaml file
  stat: path=/etc/monasca/notification.yaml
  register: notification_conf_file_result

- name: move notification.yaml to notification.yaml.old if not a symlink
  command: mv /etc/monasca/notification.yaml /etc/monasca/notification.yaml.old
  when: notification_conf_file_result.stat.exists and notification_conf_file_result.stat.isreg

- name: create conf file from template
  template: dest="{{ monasca_notification_conf_dir }}/notification.yaml" owner={{ notification_user }} group={{ monasca_group }} mode=0640 src=notification.yaml.j2
  register: ardana_notify_monasca_notification_restart_required

- name: link /etc/monasca/notification.yaml to venv config
  file:
    path: /etc/monasca/notification.yaml
    src: "{{ monasca_notification_conf_dir }}/notification.yaml"
    state: link
    owner: "{{ notification_user }}"
    group: "{{ monasca_group }}"
    mode: 0640

- name: Detect if this is a systemd based system
  command: cat /proc/1/comm
  register: init
- set_fact: use_systemd=True
  when: init.stdout == 'systemd'
- set_fact: use_systemd=False
  when: init.stdout != 'systemd'

- name: create upstart script
  template: dest={{notification_upstart_conf}} owner=root group=root mode=0644 src=monasca-notification.conf.j2
  register: ardana_notify_monasca_notification_restart_required
  when: not use_systemd

- name: create systemd config
  template: dest={{notification_systemd_service}} owner=root group=root mode=0644 src=monasca-notification.service.j2
  register: ardana_notify_monasca_notification_restart_required
  when: use_systemd

- command: systemctl daemon-reload
  when: use_systemd
070701000000D9000081A40000000000000000000000015EBC1828000005BE000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/install.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-notification | install | Install OS specific required packages
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_notification_package_dependencies

- name: Install | Update the venv cache
  install_package:
    cache: update

- name: Install | Install monasca-notification service from venv
  install_package:
    name: "monasca"
    service: monasca-notification
    state: present
  register: ardana_notify_monasca_notification_restart_required

- name: Install | set install results
  set_fact:
    monasca_notification_install_result: "{{ardana_notify_monasca_notification_restart_required}}"

- name: Install | set service directories
  set_fact:
    monasca_notification_conf_dir: "{{ 'monasca-notification' | config_dir(monasca_notification_install_result.version) }}"
070701000000DA000081A40000000000000000000000015EBC1828000004E8000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-notification | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: stop.yml
  when: run_mode == 'Stop'

- include: _check_upgraded_pkgs.yml
  when: run_mode == 'Upgrade'

- include: install.yml
  when: not skip_install and
    (run_mode == 'Install' or run_mode == 'Deploy' or run_mode == 'Upgrade')

- include: configure.yml
  when: run_mode == 'Configure' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'

- include: start.yml
  when: run_mode == 'Configure' or run_mode == 'Start' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'
070701000000DB000081A40000000000000000000000015EBC182800000472000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: monasca-notification | start | restart monasca-notification service
  service: name=monasca-notification state=restarted enabled=yes
  when: ardana_notify_monasca_notification_restart_required is defined and
        ardana_notify_monasca_notification_restart_required.changed

- name: monasca-notification | start | Start monasca-notification service
  service: name=monasca-notification state=started enabled=yes

- name: pause for monasca-notification to start
  pause: seconds=2
070701000000DC000081A40000000000000000000000015EBC1828000002D8000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/tasks/stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop Monasca-notification
  service: name=monasca-notification state=stopped
070701000000DD000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/templates070701000000DE000081A40000000000000000000000015EBC1828000003B4000000000000000000000000000000000000006C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/templates/monasca-notification.conf.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
# Startup script for the monasca_notification

description "Monasca Notification daemon"
start on runlevel [2345]

console log
respawn

kill timeout 240
respawn limit 25 5

setgid {{ monasca_group }}
setuid {{ notification_user }}
exec {{ monasca_notification_virtualenv_dir }}/bin/monasca-notification
070701000000DF000081A40000000000000000000000015EBC182800000418000000000000000000000000000000000000006F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/templates/monasca-notification.service.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Monasca Notification
After=kafka.service postfix.service

[Service]
Environment={{ notification_environment }}
Type=simple
User={{ notification_user }}
Group={{ monasca_group }}
Restart=always
RestartSec=10
ExecStart={{ monasca_notification_virtualenv_dir }}/bin/monasca-notification {{ 'monasca-notification' | config_dir() }}/notification.yaml

[Install]
WantedBy=multi-user.target
070701000000E0000081A40000000000000000000000015EBC182800000E8D000000000000000000000000000000000000006400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/templates/notification.yaml.j2{#
#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
kafka:
    url: "{{kafka_hosts}}"
    group: "{{notification_kafka_group}}"
    alarm_topic: "{{alarm_topic}}"
    notification_topic: "{{notification_topic}}"
    notification_retry_topic: "{{notification_retry_topic}}"
    periodic:
        60: 60-seconds-notifications
    max_offset_lag: 600  # In seconds, undefined for none

mysql:
    host: "{{mysql_host}}"
    user: "{{monasca_notification_mysql_user}}"
    passwd: "{{monasca_notification_mysql_password| quote }}"
    db: "{{monasca_mysql_db}}"
{% if mysql_ssl is defined %}
    ssl: {{mysql_ssl}}
{% endif %}

notification_types:

    plugins:
{% if notification_enable_hipchat | bool %}
     - monasca_notification.plugins.hipchat_notifier:HipChatNotifier
{% endif %}
{% if notification_enable_slack | bool %}
     - monasca_notification.plugins.slack_notifier:SlackNotifier
{% endif %}

{% if notification_enable_email | bool %}
    email:
        server: "{{ smtp.server }}"
        port: {% if smtp.port is defined %}{{ smtp.port }}{% else %}25{% endif %}

        user: "{% if smtp.user is defined %}{{ smtp.user }}{% endif %}"
        password: "{% if smtp.password is defined %}{{ smtp.password }}{% endif %}"
        timeout: {% if smtp.timeout is defined %}{{ smtp.timeout }}{% else %}15{% endif %}

        from_addr: "{{ email_from_address }}"
{% endif %}

{% if notification_enable_webhook | bool %}
    webhook:
        timeout: 5
{% endif %}

{% if notification_enable_pagerduty | bool %}
    pagerduty:
        timeout: 5
        url: "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
{% endif %}

{% if notification_enable_hipchat | bool %}
    hipchat:
        timeout: 5
{% endif %}

{% if notification_enable_slack | bool %}
    slack:
        timeout: 5
{% endif %}

processors:
    alarm:
        number: {{ monasca_notification_alarm_processors }}
        ttl: 14400  # In seconds, undefined for none. Alarms older than this are not processed
    notification:
        number: {{ monasca_notification_notification_processors }}

retry:
    interval: {{retry_interval}}
    max_attempts: {{retry_max_attempts}}

queues:
    alarms_size: 256
    finished_size: 256
    notifications_size: 256
    sent_notifications_size: 50  # limiting this size reduces potential # of re-sent notifications after a failure

zookeeper:
    url: "{{zookeeper_hosts}}"
    notification_path: "{{zookeeper_notification_path}}"
    notification_retry_path: "{{zookeeper_notification_retry_path}}"
    periodic_path:
        60: /notification/60_seconds

logging: # Used in logging.dictConfig
    version: 1
    disable_existing_loggers: False
    formatters:
        default:
            format: "%(asctime)s %(levelname)s %(name)s %(message)s"
    handlers:
        file:
            class: logging.FileHandler
            filename: "{{notification_log_dir}}/notification.log"
    loggers:
        kazoo:
            level: WARN
        kafka:
            level: WARN
        statsd:
            level: WARN
    root:
        handlers:
            - file
        level: {{ monasca_log_level }}
070701000000E1000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/vars070701000000E2000081A40000000000000000000000015EBC182800000297000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/vars/debian.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_notification_package_dependencies:
  - python-mysqldb
  - libmysqlclient18
070701000000E3000081A40000000000000000000000015EBC182800000387000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/vars/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
notification_log_dir: "{{ monasca_log_dir }}/notification"
notification_systemd_service: /etc/systemd/system/monasca-notification.service
notification_upstart_conf: /etc/init/monasca-notification.conf
notification_user: mon-notification
monasca_group: monasca
070701000000E4000081A40000000000000000000000015EBC182800000295000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-notification/vars/suse.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_notification_package_dependencies:
  - python-mysql
  - libmysqlclient18
070701000000E5000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister070701000000E6000081A40000000000000000000000015EBC18280000279E000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/LICENSE
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.
070701000000E7000081A40000000000000000000000015EBC182800000630000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/README.md#monasca-persister
Installs the [monasca-persister](https://github.com/stackforge/monasca-persister) part of the [Monasca](https://wiki.openstack.org/wiki/Monasca) project.
There are two implementations of the persister, one Java based and one Python based. This will install the Java based one by default. To install
the python persister rather than the java version set the variable `monasca_persister_java` to False.

##Java Requirements

Requires Variables be defined for:
- zookeeper_hosts - A comma seperated list of kafka hosts with optional port
- kafka_hosts - A comma seperated list of kafka hosts with optional port
- influxdb_url
- influxdb_user
- influxdb_password

##Python Requirements

Requires Variables be defined for:
- zookeeper_hosts - A comma seperated list of kafka hosts with optional port
- kafka_hosts - A comma seperated list of kafka hosts with optional port
- influxdb_host
- influxdb_user
- influxdb_password

## Optional

- run_mode: One of Deploy, Stop, Install, Configure or Start. The default is Deploy which will do Install, Configure, then Start.

##Example Playbook

    hosts: monasca
    become: yes
    roles:
      - {role: tkuhlman.monasca-persister,
         kafka_hosts: "{{kafka_hosts}}",
         zookeeper_hosts: "{{zookeeper_hosts}}",
         influxdb_url: "http://{{mini_mon_host}}:8086",
         influxdb_user: "{{persister_influxdb_user}}",
         influxdb_password: "{{persister_influxdb_password}}",
         tags: [persister]}

##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
070701000000E8000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/defaults070701000000E9000081A40000000000000000000000015EBC182800000BDB000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
influxdb_db: mon
persister_conf_file: "{{ 'monasca' | config_dir() }}/persister-config.yml"
monasca_log_dir: /var/log/monasca
monasca_log_level: WARN
monasca_log_rotation_backup_count: 5
monasca_persister_version: 1.3.0-SNAPSHOT
run_mode: Deploy
skip_install: False
monasca_wait_for_period: 60
monasca_virtualenv_dir: /opt/monasca
monasca_persister_alarm_max_batch_time: 15
monasca_persister_metric_max_batch_time: 15
monasca_persister_shell: /sbin/nologin

influxdb_url: "{% if database_type == 'influxdb' %}{{ MON_PST.consumes_FND_IDB.vips.private[0].url }}{% endif %}"
influxdb_user: "{% if database_type == 'influxdb' %}{{ MON_PST.consumes_FND_IDB.vars.influxdb_monasca_persister_user }}{% endif %}"
influxdb_password: "{% if database_type == 'influxdb' %}{{ MON_PST.consumes_FND_IDB.vars.influxdb_monasca_persister_password | quote }}{% endif %}"

cassandra_contact_points: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.members.client }}{% endif %}"
cassandra_port: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.members.client[0].port }}{% endif %}"
cassandra_user: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_user }}{% endif %}"
cassandra_password: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_password }}{% endif %}"
cassandra_datacenter_identifier: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_datacenter_identifier }}{% endif %}"

kafka_nodes: "{{ MON_PST.consumes_FND_KFK.members.private }}"
kafka_hosts: "{% for node in kafka_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

persister_admin_connector_port: "{{ host.bind.MON_PST.metrics.port }}"
persister_admin_connector_host: localhost
persister_app_connector_port:  "{{ host.bind.MON_PST.internal.port }}"
persister_app_connector_host:  localhost
monasca_persister_hostname: "{{ host.my_dimensions.hostname }}"

zookeeper_nodes: "{{ MON_PST.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

monasca_persister_jar: "{{ monasca_jars_virtualenv_dir }}/usr/share/monasca-persister/monasca-persister.jar"
monasca_persister_jar_saved_md5: /opt/monasca/md5sums/monasca-persister.md5
070701000000EA000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/meta070701000000EB000081A40000000000000000000000015EBC18280000048C000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs the monasca-persister part of the Monasca project.
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - monitoring
dependencies: []
  # List your role dependencies here, one per line. Only
  # dependencies available via galaxy should be listed here.
  # Be sure to remove the '[]' above if you add dependencies
  # to this list.
070701000000EC000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks070701000000ED000081A40000000000000000000000015EBC1828000003E3000000000000000000000000000000000000006100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Monasca Persister | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in Monasca Persister package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: monasca_persister_package_dependencies
  register: ardana_notify_monasca_persister_restart_required
070701000000EE000081A40000000000000000000000015EBC182800000339000000000000000000000000000000000000005E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: monasca-persister | _schedule_restart |
    Schedule a restart for monasca-persister
  debug:
    msg: "Trigger a change notification in monasca-persister"
  changed_when: true
  register: ardana_notify_monasca_persister_restart_required070701000000EF000081A40000000000000000000000015EBC1828000009CE000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/configure.yml#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: setup group
  group: name={{monasca_group}} system=yes
  register: ardana_notify_monasca_persister_restart_required

- name: Setup user
  user:
    name: "{{ persister_user }}"
    system: yes
    group: "{{ monasca_group }}"
    shell: "{{ monasca_persister_shell }}"
    createhome: no
    home: /var/nonexistent
  register: ardana_notify_monasca_persister_restart_required
  failed_when: ardana_notify_monasca_persister_restart_required|failed and
                "user {{ persister_user }} is currently used by process"
                not in ardana_notify_monasca_persister_restart_required.msg

- name: create monasca log directory
  file: path={{monasca_log_dir}} state=directory owner=root group=root mode=0775
  register: ardana_notify_monasca_persister_restart_required

- name: create persister log directory
  file: path={{persister_log_dir}} state=directory owner=mon-persister group=adm mode=0775
  register: ardana_notify_monasca_persister_restart_required

- name: set monasca-persister log file ownership
  file:
    path: "{{ item }}"
    state: touch
    owner: "{{ persister_user }}"
    group: "adm"
    mode: 0640
  with_items:
    - "{{ persister_log_dir }}/monasca-persister.log"

- name: stat /etc/monasca/persister-config.yml file
  stat: path=/etc/monasca/persister-config.yml
  register: persister_conf_file_result

- name: move persister-config.yml to persister-config.yml.old if not a symlink
  command: mv /etc/monasca/persister-config.yml /etc/monasca/persister-config.yml.old
  when: persister_conf_file_result.stat.exists and persister_conf_file_result.stat.isreg

- name: Detect if this is a systemd based system
  command: cat /proc/1/comm
  register: init
- set_fact: use_systemd=True
  when: init.stdout == 'systemd'
- set_fact: use_systemd=False
  when: init.stdout != 'systemd'

- include: java_configure.yml
070701000000F0000081A40000000000000000000000015EBC1828000002A4000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/install.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
- include: java_install.yml
070701000000F1000081A40000000000000000000000015EBC182800000CF8000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/java_configure.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: create conf_file from template
  template: dest={{persister_java_conf_file}} owner={{persister_user}} group={{monasca_group}} mode=0640 src=persister-config.yml.j2
  register: ardana_notify_monasca_persister_restart_required

- name: create symlink to persister config
  file:
    path: /etc/monasca/persister-config.yml
    src: "{{ 'monasca' | config_dir() }}/persister-config.yml"
    state: link
    owner: "{{persister_user}}"
    group: "{{monasca_group}}"
    mode: 0640

- name: create systemd startup script from template
  template: dest={{persister_systemd_service}} owner=root group=root mode=0644 src=monasca-persister-java.service.j2
  register: ardana_notify_monasca_persister_restart_required
  when: use_systemd

- command: systemctl daemon-reload
  when: use_systemd

- name: create upstart script from template
  template: dest=/etc/init/monasca-persister.conf owner=root group=root mode=0744 src=monasca-persister-java.conf.j2
  register: ardana_notify_monasca_persister_restart_required
  when: not use_systemd

- name: Create directory for storing md5sums
  file:
    path: "{{ monasca_persister_jar_saved_md5 | dirname }}"
    state: directory
    owner: root
    group: root
    mode: 0755

- name: Determine md5 of monasca-persister jar
  stat:
    path: "{{ monasca_persister_jar }}"
    follow: yes
  register: monasca_persister_jar_result

- name: Check if current md5 exists
  stat:
    path: "{{ monasca_persister_jar_saved_md5 }}"
  register: monasca_persister_jar_old_md5_file_result

- name: Get the current md5 if it exists
  slurp:
    src: "{{ monasca_persister_jar_saved_md5 }}"
  when: monasca_persister_jar_old_md5_file_result.stat.exists
  register: monasca_persister_jar_old_md5_result

- name: Mark Monasca Persister for restart if new monasca-persister jar
  debug: msg="restart monasca-persister because monasca-persister jar changed"
  changed_when: True
  when: not monasca_persister_jar_old_md5_file_result.stat.exists or
        ( monasca_persister_jar_old_md5_file_result.stat.exists and
          ( monasca_persister_jar_result.stat.md5 !=
            ( monasca_persister_jar_old_md5_result.content | b64decode ) ) )
  register: ardana_notify_monasca_persister_restart_required

- name: Write md5sum if changed or not written yet
  copy:
    dest: "{{ monasca_persister_jar_saved_md5 }}"
    content: "{{ monasca_persister_jar_result.stat.md5 }}"
  when: not monasca_persister_jar_old_md5_file_result.stat.exists or
        ( monasca_persister_jar_old_md5_file_result.stat.exists and
          ( monasca_persister_jar_result.stat.md5 !=
            ( monasca_persister_jar_old_md5_result.content | b64decode ) ) )
070701000000F2000081A40000000000000000000000015EBC182800000576000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/java_install.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-persister | java_install | Install OS specific required packages
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_persister_package_dependencies

- name: Update venv cache
  become: yes
  install_package:
    cache: update

- name: Install the monasca venv
  install_package:
    name: monasca
    service: monasca
    state: present
  register: ardana_notify_monasca_persister_restart_required

- name: Install | Set service directories
  set_fact:
    persister_conf_dir: "{{ 'monasca' | config_dir(ardana_notify_monasca_persister_restart_required.version) }}"
    persister_java_conf_file: "{{ 'monasca' | config_dir(ardana_notify_monasca_persister_restart_required.version) }}/persister-config.yml"
070701000000F3000081A40000000000000000000000015EBC1828000004E5000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-persister | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: stop.yml
  when: run_mode == 'Stop'

- include: _check_upgraded_pkgs.yml
  when: run_mode == 'Upgrade'

- include: install.yml
  when: not skip_install and
    (run_mode == 'Install' or run_mode == 'Deploy' or run_mode == 'Upgrade')

- include: configure.yml
  when: run_mode == 'Configure' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'

- include: start.yml
  when: run_mode == 'Configure' or run_mode == 'Start' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'
070701000000F4000081A40000000000000000000000015EBC1828000005CE000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-persister | start | restart monasca-persister service
  service: name=monasca-persister state=restarted enabled=yes
  when: ( ardana_notify_monasca_persister_restart_required is defined and
        ardana_notify_monasca_persister_restart_required.changed ) or
        ( hostvars[groups['MON-API--first-member'] | first ]
        ['ardana_notify_tsdb_restarted'] is defined and
        hostvars[groups['MON-API--first-member'] | first]
        ['ardana_notify_tsdb_restarted'].changed )

- name: start | Start monasca-persister service
  service: name=monasca-persister state=started enabled=yes

- name: start | wait for the persister healthcheck port
  wait_for:
    port={{ persister_admin_connector_port }}
    host={{ persister_admin_connector_host }}
    state=started
    timeout={{ monasca_wait_for_period }}

070701000000F5000081A40000000000000000000000015EBC1828000002D2000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/tasks/stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop Monasca-Persister
  service: name=monasca-persister state=stopped
070701000000F6000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/templates070701000000F7000081A40000000000000000000000015EBC182800000457000000000000000000000000000000000000006B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/templates/monasca-persister-java.conf.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
# Startup script for the monasca-persister

description "Monasca Persister java app"
start on runlevel [2345]

console log
respawn

setgid {{ monasca_group }}
setuid {{ persister_user }}
exec /usr/bin/java -Dfile.encoding=UTF-8 {{ monasca_persister_java_opts }} -cp {{ monasca_jars_virtualenv_dir }}/lib/monasca-persister-{{monasca_persister_version}}-shaded.jar monasca.persister.PersisterApplication server {{ 'monasca' | config_dir() }}/persister-config.yml
070701000000F8000081A40000000000000000000000015EBC18280000042F000000000000000000000000000000000000006E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/templates/monasca-persister-java.service.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Monasca Persister
After=kafka.service influxdb.service

[Service]
Type=simple
User={{ persister_user }}
Group={{ monasca_group }}
Restart=on-failure
ExecStart=/usr/bin/java -Dfile.encoding=UTF-8 {{ monasca_persister_java_opts }} -cp {{ monasca_persister_jar }} monasca.persister.PersisterApplication server {{ 'monasca' | config_dir() }}/persister-config.yml

[Install]
WantedBy=multi-user.target
070701000000F9000081A40000000000000000000000015EBC18280000161A000000000000000000000000000000000000006400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/templates/persister-config.yml.j2
{#
#
# (c) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-persister

alarmHistoryConfiguration:
  batchSize: {{ monasca_persister_alarm_batch_size }}
  numThreads: {{ monasca_persister_alarm_threads }}
  maxBatchTime: {{ monasca_persister_alarm_max_batch_time }}
# See http://kafka.apache.org/documentation.html#api for semantics and defaults.
  topic: alarm-state-transitions
  groupId: 1_alarm-state-transitions
  consumerId: "{{ monasca_persister_hostname }}"
  clientId : 1
  commitBatchTime: 10000

metricConfiguration:
  batchSize: {{ monasca_persister_metric_batch_size }}
  numThreads: {{ monasca_persister_metric_threads }}
  maxBatchTime: {{ monasca_persister_metric_max_batch_time }}
# See http://kafka.apache.org/documentation.html#api for semantics and defaults.
  topic: metrics
  groupId: 1_metrics
  consumerId: "{{ monasca_persister_hostname }}"
  clientId : 1
  commitBatchTime: 10000

#Kafka settings.
kafkaConfig:
# See http://kafka.apache.org/documentation.html#api for semantics and defaults.
  zookeeperConnect: "{{ zookeeper_hosts }}"
  socketTimeoutMs: 30000
  socketReceiveBufferBytes : 65536
  fetchMessageMaxBytes: 1048576
  queuedMaxMessageChunks: 10
  rebalanceMaxRetries: 4
  fetchMinBytes:  1
  fetchWaitMaxMs:  100
  rebalanceBackoffMs: 2000
  refreshLeaderBackoffMs: 200
  autoOffsetReset: largest
  consumerTimeoutMs:  1000
  zookeeperSessionTimeoutMs : 6000
  zookeeperConnectionTimeoutMs : 6000
  zookeeperSyncTimeMs: 2000

databaseConfiguration:
# influxdb | cassandra
  databaseType: {{ database_type }}

# Uncomment if databaseType is influxdb
influxDbConfiguration:
  # Retention policy may be left blank to indicate default policy.
  retentionPolicy:
  maxHttpConnections: 100
  gzip: true
  name: "{{influxdb_db}}"
  url: "{% if influxdb_url is defined %}{{influxdb_url}}{% endif %}"
  user: "{% if influxdb_user is defined %}{{influxdb_user}}{% endif %}"
  password: "{% if influxdb_password is defined %}{{influxdb_password| quote }}{% endif %}"

dataSourceFactory:
  url:
  user:
  password:
  properties:
      ssl: false
  # the maximum amount of time to wait on an empty pool before throwing an exception
  maxWaitForConnection: 1s
  # the SQL query to run when validating a connection's liveness
  validationQuery: "/* MyService Health Check */ SELECT 1"
  # the minimum number of connections to keep open
  minSize: 8
  # the maximum number of connections to keep open
  maxSize: 41
  # whether or not idle connections should be validated
  checkConnectionWhileIdle: true
  # the maximum lifetime of an idle connection
  maxConnectionAge: 1 minute

# uncomment if database type is cassandra
cassandraDbConfiguration:
  contactPoints:
    {% for vip_private in cassandra_contact_points %}
     - '{{  vip_private.host }}'
    {% endfor %}

  port: {{ cassandra_port }}
  user: {{ cassandra_persister_user }}
  password: {{ cassandra_persister_password }}
  keyspace: monasca
  maxConnections: 5
  maxRequests: 2048
  maxBatches: 500
  localDataCenter: {{ cassandra_datacenter_identifier }}
  # socket time out in milli seconds when creating a new connection
  connectionTimeout: 5000
  # number of retries in upsert query. The retry interval is exponential,
  # i.e., 1, 2, 4, 8 ... seconds. Retry is blocking.
  maxWriteRetries: 8
  maxDefinitionCacheSize: 20000000
  #    ANY(0),
  #    ONE(1),
  #    TWO(2),
  #    THREE(3),
  #    QUORUM(4),
  #    ALL(5),
  #    LOCAL_QUORUM(6),
  #    EACH_QUORUM(7),
  #    SERIAL(8),
  #    LOCAL_SERIAL(9),
  #    LOCAL_ONE(10);
  consistencyLevel: ONE
  # number of days metric retention
  retentionPolicy: 45

metrics:
  frequency: 1 second

# Logging settings.
logging:

  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO,
  # DEBUG, TRACE, or ALL.
  level: {{ monasca_log_level }}

  # Logger-specific levels.
  loggers:

    # Sets the level for 'com.example.app' to DEBUG.
      com.example.app: DEBUG
    # com.example.app.mon.persister.repository: DEBUG

  appenders:
    - type: file
      threshold: INFO
      archive: false
      currentLogFilename: "{{ persister_log_dir }}/monasca-persister.log"
      archivedLogFilenamePattern: "{{ persister_log_dir }}/monasca-persister.log-%d{yyyy-MM-dd-hh}.log.gz"
      archivedFileCount: {{ monasca_log_rotation_backup_count }}
      # The timezone used to format dates. HINT: USE THE DEFAULT, UTC.
      timeZone: UTC

server:
{% if ansible_processor_vcpus > 32 %}
# Dropwizard 0.7.0 includes a version of Jetty with admin thread issues on large machines, this works around it
  adminMaxThreads: {{ ansible_processor_vcpus * 2 }}
{% endif %}
  applicationConnectors:
    - type: http
      port: {{ persister_app_connector_port }}
{% if persister_app_connector_host is defined %}
      bindHost: "{{ persister_app_connector_host }}"
{% endif %}
  adminConnectors:
    - type: http
      port: {{ persister_admin_connector_port }}
{% if persister_admin_connector_host is defined %}
      bindHost: "{{ persister_admin_connector_host }}"
{% endif %}
  requestLog:
    appenders: []
070701000000FA000081A40000000000000000000000015EBC182800000892000000000000000000000000000000000000005E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/templates/persister.conf.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
[DEFAULT]
log_file = persister.log
log_dir = "{{persister_log_dir}}"
# Default log level is WARNING
# Show debugging output in logs (sets DEBUG log level output)
debug = false
# Show more verbose log output (sets INFO log level output) if debug is False
verbose = true

[zookeeper]
# Comma separated list of host:port
uri = "{{zookeeper_hosts}}"
partition_interval_recheck_seconds = 15

[kafka_alarm_history]
# Comma separated list of Kafka broker host:port.
uri = "{{kafka_hosts}}"
group_id = 1_alarm-state-transitions
topic = alarm-state-transitions
consumer_id = 1
client_id = 1
database_batch_size = 1000
max_wait_time_seconds = 30
# The following 3 values are set to the kafka-python defaults
fetch_size_bytes = 4096
buffer_size = 4096
# 8 times buffer size
max_buffer_size = 32768
# Path in zookeeper for kafka consumer group partitioning algo
zookeeper_path = /persister_partitions/alarm-state-transitions

[kafka_metrics]
# Comma separated list of Kafka broker host:port.
uri = "{{kafka_hosts}}"
group_id = 1_metrics
topic = metrics
consumer_id = 1
client_id = 1
database_batch_size = 1000
max_wait_time_seconds = 30
# The following 3 values are set to the kafka-python defaults
fetch_size_bytes = 4096
buffer_size = 4096
# 8 times buffer size
max_buffer_size = 32768
# Path in zookeeper for kafka consumer group partitioning algo
zookeeper_path = /persister_partitions/metrics

[influxdb]
database_name = "{{influxdb_db}}"
ip_address = "{{influxdb_host}}"
port = 8086
user = "{{influxdb_user}}"
password = "{{influxdb_password| quote }}"


070701000000FB000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/vars070701000000FC000081A40000000000000000000000015EBC182800000285000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/vars/debian.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_persister_package_dependencies:
  - default-jre-headless
070701000000FD000081A40000000000000000000000015EBC1828000003C4000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/vars/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
persister_java_conf_file: "{{ 'monasca' | config_dir() }}/persister-config.yml"
persister_log_dir: "{{ monasca_log_dir }}/persister"
persister_systemd_service: /etc/systemd/system/monasca-persister.service
persister_upstart_conf: /etc/init/monasca-persister.conf
persister_user: mon-persister
monasca_group: monasca
070701000000FE000081A40000000000000000000000015EBC18280000028C000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-persister/vars/suse.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_persister_package_dependencies:
  - java-1_8_0-openjdk-headless
070701000000FF000041ED0000000000000000000000085EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema07070100000100000081A40000000000000000000000015EBC1828000006D5000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/README.md#Monasca-Schema
Adds schema to mysql and influxdb, creates db users and creates kafka topics.

## Tags
These tags can be used to specify just sections of the role
- kafka_topics
- mysql_schema
- influxdb_schema
- winchester_schema

##Requirements
The monasca services for mysql, influxdb and kafka must be up and running. Influxdb must be version 0.9+.
- zookeeper_hosts - comma separated list of host:port pairs.
- influxdb_url - URL of the influxdb server
- mon_influxdb_users - dictionary of user/password pairs
```
    mon_influxdb_users:
      - username: monasca-api
        password: some-password
```

By default, the creation of the kafka topics assume multiple kafka servers. If there is only one, then
kafka_replicas should be set to 1. The default is 3.

The number of partitions for the kafka topics can be controlled with:
- kafka_events_partitions - number of partitions for the various events topics, the default is 12
- kafka_metrics_partitions - number of partitions for the metrics topic, the default is 64
- kafka_retry_notifications_partitions - This should be the number of systems running the Notification Engine, the default is 3

If the kafka topics have been created, neither the number of partitions nor the number of replicas will not be
changed even if the above parameters are changed and the role run again.

## TODO
- The notification engine user could be given readonly access to the db but in the current setup there is no way
  to specify that so it gets full access like the rest of the users.

##Example Playbook

    hosts: group
    become: yes
    roles:
      - {role: monasca-schema, tags: [monasca-schema]}

##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
07070100000101000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/defaults07070100000102000081A40000000000000000000000015EBC182800001686000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
influxdb_schema_enabled: true
kafka_topics_enabled: true
mysql_schema_enabled: true
influxdb_admin: "{{ FND_IDB.vars.influxdb_admin_user_name }}"
influxdb_admin_password: "{{ FND_IDB.vars.influxdb_admin_user_password }}"
influxdb_admin_old_password: "{% if FND_IDB.old_vars is defined and FND_IDB.old_vars.influxdb_admin_user_password is defined %}{{ FND_IDB.old_vars.influxdb_admin_user_password }}{% else %}{{ influxdb_admin_password }}{% endif %}"
influxdb_dbname: mon
influxdb_retention_policy: "90d"
influxdb_shard_duration: "7d"
influxdb_script_dir: /root
mysql_admin: root
monasca_mysql_db: "{{ MON_API.consumes_FND_MDB.vars.databases.monasca.dbname }}"
# enable cassandra schema
cassandra_conf_dir: "{{ '/etc/cassandra/conf' if ansible_os_family == 'Suse' else '/etc/cassandra' }}"
cassandra_schema_enabled: true
cassandra_hosts: "{{ FND_CDB.members.inter_node_cluster }}"

cassandra_local_hostname: >
  {{ (cassandra_hosts |
      selectattr('ardana_ansible_host','equalto', inventory_hostname) |
      first).host }}

cassandra_contact_points: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.members.client }}{% endif %}"
cassandra_port: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.members.client[0].port }}{% endif %}"
cassandra_user: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_user }}{% endif %}"
cassandra_password: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_password }}{% endif %}"
cassandra_datacenter_identifier: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_datacenter_identifier }}{% endif %}"
cassandra_replication_factor: >
  {% if database_type == 'cassandra' %}{{ [MON_PST.consumes_FND_CDB.vars.cassandra_max_replication_factor, cassandra_node_count | int] | min }}{% endif %}
cassandra_client_connect_timeout: 120
cassandra_client_request_timeout: 120
cassandra_admin_user: "{% if database_type == 'cassandra' %}{{ FND_CDB.vars.cassandra_admin_user }}{% endif %}"
cassandra_admin_password: "{% if database_type == 'cassandra' %}{{ FND_CDB.vars.cassandra_admin_password }}{% endif %}"

mysql_root_dir: /var/lib/mysql
monasca_schema_version: 4
monasca_schema_file: "{{ mysql_schema_dir }}/mon.sql"
monasca_script_file: "{{ mysql_schema_dir }}/mysql_schema.py"

kafka_events_partitions: 12
kafka_metrics_partitions: 64
# This should be the number of systems running the Notification Engine
kafka_retry_periodic_notifications_partitions: 3
kafka_node_count: "{{ FND_KFK.members.private | length }}"
kafka_replicas: "{% if kafka_node_count | int > 3 %}3{% else %}{{ kafka_node_count }}{% endif %}"
kafka_segment_minutes: 15

kafka_topics:
  metrics: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_metrics_partitions }}" }
  events: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  raw-events: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  transformed-events: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  stream-definitions: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  transform-definitions: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  alarm-state-transitions: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  alarm-notifications: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  stream-notifications: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_events_partitions }}" }
  retry-notifications: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_retry_periodic_notifications_partitions }}" }
  60-seconds-notifications: { replicas: "{{ kafka_replicas }}", partitions: "{{ kafka_retry_periodic_notifications_partitions }}" }


zookeeper_nodes: "{{ FND_KFK.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

influxdb_node_count: "{{ FND_IDB.members.private | length }}"
influxdb_replication_factor: "{% if influxdb_node_count | int > 3 %}3{% else %}{{ influxdb_node_count }}{% endif %}"
influxdb_url: "{% if database_type == 'influxdb' %}{{ MON_API.consumes_FND_IDB.vips.private[0].url }}{% endif %}"
mon_influxdb_users:
  - username: "{{ MON_API.consumes_FND_IDB.vars.influxdb_monasca_api_user }}"
    password: "{{ MON_API.consumes_FND_IDB.vars.influxdb_monasca_api_password | quote }}"
  - username: "{{ MON_PST.consumes_FND_IDB.vars.influxdb_monasca_persister_user }}"
    password: "{{ MON_PST.consumes_FND_IDB.vars.influxdb_monasca_persister_password | quote }}"

rebuild: False

monasca_api_mysql_user: "{{ MON.consumes_FND_MDB.vars.accounts.monasca_api.username }}"
monasca_api_mysql_password: "{{ MON.consumes_FND_MDB.vars.accounts.monasca_api.password | quote }}"
mysql_host: "{{ MON_API.consumes_FND_MDB.vips.private[0].host }}"

monasca_schema_system_cacert_file: "{{ trusted_ca_bundle }}"
07070100000103000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/files07070100000104000081A40000000000000000000000015EBC182800000454000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/files/mon_alarms_schema.sql/*
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
*/

CREATE SCHEMA MonAlarms;

CREATE TABLE MonAlarms.StateHistory(
    id AUTO_INCREMENT,
    tenant_id VARCHAR,
    alarm_id VARCHAR,
    metrics VARCHAR (65000),
    old_state VARCHAR,
    new_state VARCHAR,
    sub_alarms VARCHAR (65000),
    reason VARCHAR(65000),
    reason_data VARCHAR(65000),
    time_stamp TIMESTAMP NOT NULL
) PARTITION BY EXTRACT('year' FROM time_stamp)*10000 + EXTRACT('month' FROM time_stamp)*100 + EXTRACT('day' FROM time_stamp);
07070100000105000081A40000000000000000000000015EBC182800000D85000000000000000000000000000000000000006000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/files/mon_metrics_multi_node.sql/*
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
*/

CREATE PROJECTION MonMetrics.Measurements_DBD_1_seg_monmetrics_design_b0 /*+basename(Measurements_DBD_1_seg_monmetrics_design),createtype(D)*/
(
 definition_dimensions_id ENCODING AUTO,
 time_stamp ENCODING RLE,
 value ENCODING AUTO,
 value_meta ENCODING RLE
)
AS
 SELECT definition_dimensions_id,
        time_stamp,
        value,
        value_meta
 FROM MonMetrics.Measurements
 ORDER BY time_stamp,
          definition_dimensions_id
SEGMENTED BY MODULARHASH (definition_dimensions_id) ALL NODES OFFSET 0;

CREATE PROJECTION MonMetrics.Measurements_DBD_1_seg_monmetrics_design_b1 /*+basename(Measurements_DBD_1_seg_monmetrics_design),createtype(D)*/
(
 definition_dimensions_id ENCODING AUTO,
 time_stamp ENCODING RLE,
 value ENCODING AUTO,
 value_meta ENCODING RLE
)
AS
 SELECT definition_dimensions_id,
        time_stamp,
        value,
        value_meta
 FROM MonMetrics.Measurements
 ORDER BY time_stamp,
          definition_dimensions_id
SEGMENTED BY MODULARHASH (definition_dimensions_id) ALL NODES OFFSET 1;



CREATE PROJECTION MonMetrics.DefinitionDimensions_DBD_3_seg_monmetrics_design_b0 /*+basename(DefinitionDimensions_DBD_3_seg_monmetrics_design),createtype(D)*/
(
 id ENCODING AUTO,
 definition_id ENCODING AUTO,
 dimension_set_id ENCODING RLE
)
AS
 SELECT id,
        definition_id,
        dimension_set_id
 FROM MonMetrics.DefinitionDimensions
 ORDER BY dimension_set_id,
          definition_id
SEGMENTED BY MODULARHASH (id) ALL NODES OFFSET 0;

CREATE PROJECTION MonMetrics.DefinitionDimensions_DBD_3_seg_monmetrics_design_b1 /*+basename(DefinitionDimensions_DBD_3_seg_monmetrics_design),createtype(D)*/
(
 id ENCODING AUTO,
 definition_id ENCODING AUTO,
 dimension_set_id ENCODING RLE
)
AS
 SELECT id,
        definition_id,
        dimension_set_id
 FROM MonMetrics.DefinitionDimensions
 ORDER BY dimension_set_id,
          definition_id
SEGMENTED BY MODULARHASH (id) ALL NODES OFFSET 1;



CREATE PROJECTION MonMetrics.Dimensions_seg_set_id_b0 /*+basename(Dimensions_seg_set_id),createtype(D)*/
(
 dimension_set_id,
 name ENCODING RLE,
 value
)
AS
 SELECT Dimensions.dimension_set_id,
        Dimensions.name,
        Dimensions.value
 FROM MonMetrics.Dimensions
 ORDER BY Dimensions.dimension_set_id,
          Dimensions.name,
          Dimensions.value
SEGMENTED BY hash(Dimensions.dimension_set_id) ALL NODES OFFSET 0;

CREATE PROJECTION MonMetrics.Dimensions_seg_set_id_b1 /*+basename(Dimensions_seg_set_id),createtype(D)*/
(
 dimension_set_id,
 name ENCODING RLE,
 value
)
AS
 SELECT Dimensions.dimension_set_id,
        Dimensions.name,
        Dimensions.value
 FROM MonMetrics.Dimensions
 ORDER BY Dimensions.dimension_set_id,
          Dimensions.name,
          Dimensions.value
SEGMENTED BY hash(Dimensions.dimension_set_id) ALL NODES OFFSET 1;

select start_refresh();

07070100000106000081A40000000000000000000000015EBC182800000D08000000000000000000000000000000000000005C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/files/mon_metrics_schema.sql/*
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
*/

CREATE SCHEMA MonMetrics;

CREATE TABLE MonMetrics.Measurements (
    definition_dimensions_id BINARY(20) NOT NULL,
    time_stamp TIMESTAMP NOT NULL,
    value FLOAT NOT NULL,
    value_meta VARCHAR(2048)
) PARTITION BY EXTRACT('year' FROM time_stamp)*10000 + EXTRACT('month' FROM time_stamp)*100 + EXTRACT('day' FROM time_stamp);

CREATE TABLE MonMetrics.Definitions(
    id BINARY(20) NOT NULL,
    name VARCHAR(255) NOT NULL,
    tenant_id VARCHAR(255) NOT NULL,
    region VARCHAR(255) NOT NULL,
    PRIMARY KEY(id),
    CONSTRAINT MetricsDefinitionsConstraint UNIQUE(name, tenant_id, region)
);

CREATE TABLE MonMetrics.Dimensions (
    dimension_set_id BINARY(20) NOT NULL,
    name VARCHAR(255) NOT NULL,
    value VARCHAR(255) NOT NULL,
    CONSTRAINT MetricsDimensionsConstraint UNIQUE(dimension_set_id, name, value)
);

CREATE TABLE MonMetrics.DefinitionDimensions (
    id BINARY(20) NOT NULL,
    definition_id BINARY(20) NOT NULL,
    dimension_set_id BINARY(20) NOT NULL,
    CONSTRAINT MetricsDefinitionDimensionsConstraint UNIQUE(definition_id, dimension_set_id)
 );

-- Projections
-- ** These are for a single node system with no k safety

CREATE PROJECTION Measurements_DBD_1_rep_MonMetrics /*+createtype(D)*/
(
 definition_dimensions_id ENCODING RLE,
 time_stamp ENCODING DELTAVAL,
 value ENCODING AUTO,
 value_meta ENCODING RLE
)
AS
 SELECT definition_dimensions_id,
        time_stamp,
        value,
        value_meta
 FROM MonMetrics.Measurements
 ORDER BY definition_dimensions_id,
          time_stamp,
          value_meta
UNSEGMENTED ALL NODES;

CREATE PROJECTION Definitions_DBD_2_rep_MonMetrics /*+createtype(D)*/
(
 id ENCODING AUTO,
 name ENCODING AUTO,
 tenant_id ENCODING RLE,
 region ENCODING RLE
)
AS
 SELECT id,
        name,
        tenant_id,
        region
 FROM MonMetrics.Definitions
 ORDER BY region,
          tenant_id,
          name
UNSEGMENTED ALL NODES;

CREATE PROJECTION Dimensions_DBD_3_rep_MonMetrics /*+createtype(D)*/
(
 dimension_set_id ENCODING AUTO,
 name ENCODING RLE,
 value ENCODING AUTO
)
AS
 SELECT dimension_set_id,
        name,
        value
 FROM MonMetrics.Dimensions
 ORDER BY name,
          value,
          dimension_set_id
UNSEGMENTED ALL NODES;

CREATE PROJECTION DefinitionDimensions_DBD_4_rep_MonMetrics /*+createtype(D)*/
(
 id ENCODING AUTO,
 definition_id ENCODING RLE,
 dimension_set_id ENCODING AUTO
)
AS
 SELECT id,
        definition_id,
        dimension_set_id
 FROM MonMetrics.DefinitionDimensions
 ORDER BY definition_id,
          dimension_set_id
UNSEGMENTED ALL NODES;

select refresh('MonMetrics.Measurements, MonMetrics.Definitions, MonMetrics.Dimensions, MonMetrics.DefinitionDimensions');
07070100000107000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/meta07070100000108000081A40000000000000000000000015EBC1828000003DF000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Applies Monasca schema to influxdb and mysql
    and creates kafka topics
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - all
  categories:
  - clustering
  - system
dependencies:
  - role: tls-vars
  - role: monasca-common
07070100000109000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks0707010000010A000081A40000000000000000000000015EBC182800000579000000000000000000000000000000000000006400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/cassandra-change-passwords.yml#
#  (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-schema | cassandra-change-password | Copy over cassandra user cql file
  template:
    src: mon_users_and_limits.cql.j2
    dest: "{{ cassandra_conf_dir }}/mon_users_and_limits.cql"
    mode: 0600
  register: cql_user_status

- name: monasca-schema | cassandra-change-password | Configure roles in cassandra
  become: yes
  shell: >
    /usr/bin/cqlsh -u {{ cassandra_admin_user }}
    -p {{ cassandra_admin_password }}
    -f {{ cassandra_conf_dir }}/mon_users_and_limits.cql
    --connect-timeout {{ cassandra_client_connect_timeout }}
    --request-timeout {{ cassandra_client_request_timeout }}
    {{ cassandra_local_hostname }}
  no_log: True
  when: ( cql_user_status | changed and not rebuild ) or
        (cql_schema_status is defined and ( cql_schema_status | changed ))
  run_once: True
0707010000010B000081A40000000000000000000000015EBC182800000693000000000000000000000000000000000000005A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/cassandra-schema.yml#
#  (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-schema | cassandra | Copy over cassandra schema cql file
  template:
    src: mon_cassandra_schema.cql.j2
    dest: "{{ cassandra_conf_dir }}/mon_cassandra_schema.cql"
    mode: 0660
  register: cql_schema_status

- name: monasca-schema | cassandra | Write schema to cassandra
  become: yes
  shell: >
    /usr/bin/cqlsh -u {{ cassandra_admin_user }}
    -p {{ cassandra_admin_password }}
    -f {{ cassandra_conf_dir }}/mon_cassandra_schema.cql
    --connect-timeout {{ cassandra_client_connect_timeout }}
    --request-timeout {{ cassandra_client_request_timeout }}
    {{ cassandra_local_hostname }}
  no_log: True
  when: cql_schema_status | changed
  run_once: True
  ignore_errors: True
  register: schema_result

- name: monasca-schema | clear schema if failed
  become: yes
  file:
    path: "{{ cassandra_conf_dir }}/mon_cassandra_schema.cql"
    state: absent
  when: schema_result is defined and schema_result.rc != 0

- name: monasca-schema | check schema fail
  fail:
    msg: failed to create monasca schema
  when: schema_result is defined and schema_result.rc != 00707010000010C000081A40000000000000000000000015EBC18280000044E000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/cassandra-start.yml#
#  (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-schema | cassandra-start | Restart cassandra
  service: name=cassandra state=restarted
  when: >
    (hostvars[groups['MON-API--first-member'] | first ]['cql_schema_status'] is defined
    and (hostvars[groups['MON-API--first-member'] | first ]['cql_schema_status'] | changed)) or
    (hostvars[groups['MON-API--first-member'] | first ]['cql_user_status'] is defined
    and (hostvars[groups['MON-API--first-member'] | first ]['cql_user_status'] | changed))
  register: ardana_notify_tsdb_restarted
0707010000010D000081A40000000000000000000000015EBC1828000004AF000000000000000000000000000000000000006300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/influxdb-change-passwords.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: monasca-schema | influxdb-change-passwords | Write out password change script
  template:
    dest: "{{ influxdb_script_dir }}/influxdb_change_passwords.py"
    owner: root
    group: root
    mode: 0750
    src: influxdb_change_passwords.py.j2
  register: influxb_change_file_result

- name: monasca-schema | influxdb-change-passwords | Run password change script
  command: "{{ influxdb_script_dir }}/influxdb_change_passwords.py"
  register: result
  until: result | success
  retries: 5
  delay: 2
  when: influxb_change_file_result | changed
0707010000010E000081A40000000000000000000000015EBC182800000498000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/influxdb.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
# TODO I should create a module for the db/user operations, I tried using uri and even shell with curl directly but between the j2 and yaml
# parsing I could never get it to escape the json correctly

- name: Write out the influxdb setup script
  template: dest={{ influxdb_script_dir }}/influxdb_setup.py owner=root group=root mode=0750 src=influxdb_setup.py.j2

- name: Run the influxdb setup script
  command: "{{ influxdb_script_dir }}/influxdb_setup.py"
  register: result
  until: result | success
  retries: 5
  delay: 2
0707010000010F000081A40000000000000000000000015EBC1828000005E1000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/kafka_topics.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: include kafka vars
  include_vars: ../../kafka/vars/main.yml

- name: check topics
  shell: "{{ kafka_bin_dir}}/kafka-topics.sh --list --zookeeper {{ zookeeper_hosts }} --topic {{ item.key }} | grep {{ item.key }}"
  with_dict: kafka_topics
  ignore_errors: yes
  register: check_result

- name: create topics
  command: "{{ kafka_bin_dir}}/kafka-topics.sh --create --zookeeper {{ zookeeper_hosts }} --replication-factor {{ item.value.replicas }} --partitions {{ item.value.partitions }} --topic {{ item.key }}"
  with_dict: kafka_topics
  when: check_result|failed

- name: configure per topic segment rotation
  command: "{{ kafka_bin_dir}}/kafka-configs.sh  --alter --zookeeper {{ zookeeper_hosts }} --entity-type topics --entity-name {{ item.key }} --add-config segment.ms={{ kafka_segment_minutes * 60 * 1000 }}"
  with_dict: kafka_topics
07070100000110000081A40000000000000000000000015EBC1828000005BD000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/main.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: monasca-schema | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"


- include: influxdb.yml tags=influxdb_schema
  when: influxdb_schema_enabled and database_type == 'influxdb'
- include: mysql.yml tags=mysql_schema
  when: mysql_schema_enabled
- include: kafka_topics.yml tags=kafka_topics
  when: kafka_topics_enabled
- include: cassandra-schema.yml tags=cassandra_schema
  when: cassandra_schema_enabled and database_type == 'cassandra'
- include: cassandra-change-passwords.yml tags=cassandra_schema
  when: cassandra_schema_enabled and database_type == 'cassandra'
- include: cassandra-start.yml tags=cassandra_schema
  when: cassandra_schema_enabled and database_type == 'cassandra'
- include: mysql_pre_upgrade.yml
  when: run_mode | default('') == 'Upgrade'
07070100000111000081A40000000000000000000000015EBC182800000373000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/mysql.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
# Install python mysql client library on all nodes
- name: monasca-schema | mysql | Install OS specific required packages in Debian
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_schema_package_dependencies
07070100000112000081A40000000000000000000000015EBC1828000004C5000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/tasks/mysql_pre_upgrade.yml#
# (c) Copyright 2019 SUSE LLC
#
# 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.
#
---

# NOTE(gyee): prior to stable/rocky, Monasca DB schema was a wild, wild, west.
# In other words, there was no "official version" of the schema. It was
# left up to the vendors. In stable/rocky, Monasca established an
# official version of the schema, and it was stamp (or fingerprinted) with
# each migration step. We need to update our scheam to align with the
# official stamp prior to the upgrade

- name: monasca-schema | mysql_pre_upgrade |
        Copy mysql_schema_sync script to host
  template:
    dest: "{{ monasca_mysql_schema_sync_script_file }}"
    owner: root
    group: root
    mode: 0640
    src: mysql_schema_sync.py.j2
07070100000113000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates07070100000114000081A40000000000000000000000015EBC182800000BC5000000000000000000000000000000000000006900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/influxdb_change_passwords.py.j2#!/usr/bin/env python
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
"""A simple script to change influxdb passwords. At some point this should
   become a more full featured module.  Also this assumes that none of the
   python based influxdb clients are available on this system.
"""

ADMIN = '{{ influxdb_admin }}'
NEW_ADMIN_PASS = '{{ influxdb_admin_password }}'
OLD_ADMIN_PASS = '{{ influxdb_admin_old_password }}'
DBNAME = '{{ influxdb_dbname }}'
USERS = {}
{% for user in mon_influxdb_users %}
USERS['{{ user.username }}'] = '{{ user.password }}'
{% endfor %}

URL = '{{ influxdb_url }}'

import json
import sys
import time
import urllib
import urllib2


def influxdb_get(uri, query, db=None):
    """Runs a query via HTTP GET and returns the response as a Python list."""

    getparams = {"q": query}
    if db:
        getparams['db'] = db

    try:
        params = urllib.urlencode(getparams)
        uri = "{}&{}".format(uri,params)
        req = urllib2.urlopen(uri)
        json_value = json.loads(req.read())

        if (len(json_value['results'][0]) > 0 and
           'values' in json_value['results'][0]['series'][0]):
            return json_value['results'][0]['series'][0]['values']
        else:
            return []

    except KeyError:
        print "Query returned a non-successful result: {0}".format(json_value['results'])
        sys.exit(1)


def main(argv=None):
    """If necessary, change passwords """

    admin_password_to_use  = NEW_ADMIN_PASS
    auth_str = '?u=%s&p=%s' % (ADMIN, admin_password_to_use)
    api_uri = "{0}/query{1}".format(URL, auth_str)
    try:
#       List Users, if it fails, switch to the old admin password
        users = influxdb_get(uri=api_uri, query="SHOW USERS", db=DBNAME)
    except Exception as e:
        print e
        print 'Using old password'
        admin_password_to_use  = OLD_ADMIN_PASS
        auth_str = '?u=%s&p=%s' % (ADMIN, admin_password_to_use)
        api_uri = "{0}/query{1}".format(URL, auth_str)

    change = "SET PASSWORD FOR {0} = '{1}'"
    if OLD_ADMIN_PASS != NEW_ADMIN_PASS:
        query = change.format(ADMIN, NEW_ADMIN_PASS)
        influxdb_get(uri=api_uri, query=unicode(query))

#   Change the database user passwords
    for name, password in USERS.iteritems():
        query = change.format(name, password)
        influxdb_get(uri=api_uri, query=unicode(query))

if __name__ == "__main__":
    sys.exit(main())
07070100000115000081A40000000000000000000000015EBC18280000121F000000000000000000000000000000000000005E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/influxdb_setup.py.j2#!/usr/bin/env python
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
"""A simple script to setup influxdb user and roles. At some point this should
   become a more full featured module.  Also this assumes that none of the
   python based influxdb clients are available on this system.
"""

ADMIN = '{{influxdb_admin}}'
ADMIN_PASS = '{{influxdb_admin_password}}'
DBNAME = '{{influxdb_dbname}}'
{% if influxdb_users is defined %}
USERS = {{influxdb_users}}
{% endif %}
{% if mon_influxdb_users is defined %}
USERS = {}
{% for user in mon_influxdb_users %}
USERS['{{user.username}}'] = '{{user.password}}'
{% endfor %}
{% endif %}

URL = '{{influxdb_url}}'

SHARDSPACE_NAME = 'persister_all'
REPLICATION = {{influxdb_replication_factor}}
RETENTION = '{{influxdb_retention_policy}}'

import json
import sys
import time
import urllib
import urllib2


def influxdb_get(uri, query, db=None):
    """Runs a query via HTTP GET and returns the response as a Python list."""

    getparams = {"q": query}
    if db:
        getparams['db'] = db

    try:
        params = urllib.urlencode(getparams)
        uri = "{}&{}".format(uri,params)
        req = urllib2.urlopen(uri)
        json_value = json.loads(req.read())

        if (len(json_value['results'][0]) > 0 and
           'values' in json_value['results'][0]['series'][0]):
            return json_value['results'][0]['series'][0]['values']
        else:
            return []

    except KeyError:
        print "Query returned a non-successful result: {0}".format(json_value['results'])
        sys.exit(1)


def main(argv=None):
    """If necessary, create the database, retention policy, and users"""
    auth_str = '?u=%s&p=%s' % (ADMIN, ADMIN_PASS)
    api_uri = "{0}/query{1}".format(URL, auth_str)

    create_admin_user = False
    try:
#       List Users, if there are none or it fails, then we need to create
#       the Admin User
        users = influxdb_get(uri=api_uri, query="SHOW USERS", db=DBNAME)
        if not users:
            create_admin_user = True
    except Exception as e:
        print e
        create_admin_user = True

    if create_admin_user:
        create = "CREATE USER {0} WITH PASSWORD '{1}' WITH ALL PRIVILEGES"
        influxdb_get(uri=api_uri, query=create.format(ADMIN, ADMIN_PASS))

#    List current databases
    dbs = influxdb_get(uri=api_uri, query="SHOW DATABASES")
    if [DBNAME] not in dbs:
        print "Creating database '{}'".format(DBNAME)
        influxdb_get(uri=api_uri, query="CREATE DATABASE {0}".format(DBNAME))
        print "...created!"

#   Check retention policy
    policies = influxdb_get(uri=api_uri,
                            query="SHOW RETENTION POLICIES ON {0}".format(DBNAME))
    if not any(pol[0] == SHARDSPACE_NAME for pol in policies):
        # Set retention policy
        policy = "CREATE RETENTION POLICY {0} ON {1} DURATION {2} REPLICATION {3} DEFAULT".format(SHARDSPACE_NAME,
                                                                                          DBNAME,
                                                                                          RETENTION,
                                                                                          REPLICATION)
        influxdb_get(uri=api_uri, db=DBNAME, query=policy)

#   Create the database users and allow them to access the database
    for name, password in USERS.iteritems():
        if not any(user[0] == name for user in users):
            user_create = "CREATE USER {0} WITH PASSWORD '{1}'".format(name, password)
            influxdb_get(uri=api_uri, query=unicode(user_create))
            should_grant = True
        else:
            check_grants = "SHOW GRANTS FOR {0}".format(name)
            grants = influxdb_get(uri=api_uri, query=unicode(check_grants))
            should_grant = not DBNAME in grants

        if should_grant:
            user_grant = "GRANT ALL ON {0} TO {1}".format(DBNAME, name)
            influxdb_get(uri=api_uri, query=unicode(user_grant))

if __name__ == "__main__":
    sys.exit(main())
07070100000116000081A40000000000000000000000015EBC182800000A8F000000000000000000000000000000000000006500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/mon_cassandra_schema.cql.j2
// (C) Copyright 2018 SUSE LLC
//
// 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.


drop schema if exists monasca;

create schema monasca with replication = { 'class' : 'NetworkTopologyStrategy', 'dc1' : {{ cassandra_replication_factor }} };

create table monasca.measurements (
    metric_id blob,
    region text static,
    tenant_id text static,
    metric_name text static,
    dimensions frozen<list<text>> static,
    time_stamp timestamp,
    value double,
    value_meta text,
    primary key (metric_id, time_stamp)
)
WITH CLUSTERING ORDER BY (time_stamp ASC);

create table monasca.metrics (
    region text,
    tenant_id text,
    metric_name text,
    dimensions frozen<list<text>>,
    dimension_names frozen<list<text>>,
    metric_id blob,
    created_at timestamp,
    updated_at timestamp,
    primary key ((region, tenant_id, metric_name), dimensions, dimension_names)
);

CREATE CUSTOM INDEX metrics_created_at_index ON monasca.metrics (created_at)
USING 'org.apache.cassandra.index.sasi.SASIIndex';

CREATE CUSTOM INDEX metrics_updated_at_index ON monasca.metrics (updated_at)
USING 'org.apache.cassandra.index.sasi.SASIIndex';

create table monasca.dimensions (
    region text,
    tenant_id text,
    name text,
    value text,
    primary key ((region, tenant_id, name), value)
);

create table monasca.dimensions_metrics (
    region text,
    tenant_id text,
    dimension_name text,
    dimension_value text,
    metric_name text,
    primary key ((region, tenant_id, dimension_name, dimension_value), metric_name)
);

create table monasca.metrics_dimensions (
    region text,
    tenant_id text,
    dimension_name text,
    dimension_value text,
    metric_name text,
    primary key ((region, tenant_id, metric_name), dimension_name, dimension_value)
);

create table monasca.alarm_state_history (
        tenant_id text,
        alarm_id text,
        time_stamp timestamp,
        metric text,
        old_state text,
        new_state text,
        reason text,
        reason_data text,
        sub_alarms text,
primary key ((tenant_id, alarm_id), time_stamp)
);

07070100000117000081A40000000000000000000000015EBC18280000047D000000000000000000000000000000000000006500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/mon_users_and_limits.cql.j2
{#
#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}

CREATE ROLE IF NOT EXISTS monasca_persister_role;
CREATE ROLE IF NOT EXISTS monasca_api_role;
GRANT SELECT ON KEYSPACE monasca TO monasca_persister_role;
GRANT MODIFY ON KEYSPACE monasca TO monasca_persister_role;
GRANT SELECT ON KEYSPACE monasca TO monasca_api_role;

{% for item in cassandra_users %}
DROP ROLE IF EXISTS {{ item.username }};
CREATE ROLE IF NOT EXISTS {{ item.username }};
GRANT {{ item.role }} TO {{ item.username }};
ALTER ROLE {{ item.username }} WITH PASSWORD = '{{ item.password }}' AND LOGIN = true AND SUPERUSER = false;
{% endfor %}

07070100000118000081A40000000000000000000000015EBC182800000612000000000000000000000000000000000000006500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/mon_users_and_limits.sql.j2{#
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
CREATE ROLE monasca_persister;
CREATE ROLE monasca_api;

GRANT USAGE ON SCHEMA MonMetrics TO monasca_persister;
GRANT USAGE ON SCHEMA MonAlarms TO monasca_persister;
GRANT ALL ON TABLE MonMetrics.Measurements TO monasca_persister;
GRANT ALL ON TABLE MonMetrics.Definitions TO monasca_persister;
GRANT ALL ON TABLE MonMetrics.Dimensions TO monasca_persister;
GRANT ALL ON TABLE MonMetrics.DefinitionDimensions TO monasca_persister;
GRANT ALL ON TABLE MonAlarms.StateHistory TO monasca_persister;

GRANT USAGE ON SCHEMA MonMetrics TO monasca_api;
GRANT USAGE ON SCHEMA MonAlarms TO monasca_api;
GRANT SELECT ON TABLE MonMetrics.Measurements TO monasca_api;
GRANT SELECT ON TABLE MonMetrics.Definitions TO monasca_api;
GRANT SELECT ON TABLE MonMetrics.Dimensions TO monasca_api;
GRANT SELECT ON TABLE MonMetrics.DefinitionDimensions TO monasca_api;
GRANT ALL ON TABLE MonAlarms.StateHistory TO monasca_api;
07070100000119000081A40000000000000000000000015EBC1828000035B3000000000000000000000000000000000000006100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/mysql_schema_sync.py.j2#!/usr/bin/env python
#
# (c) Copyright 2019 SUSE LLC
#
# 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 datetime
import sys

import MySQLdb


def execute_query(con, query):
    try:
        cursor = con.cursor()
        cursor.execute(query)
    finally:
        if cursor:
            cursor.close()


def execute_fetchone_query(con, query):
    try:
        cursor = con.cursor()
        cursor.execute(query)
        return cursor.fetchone()
    finally:
        if cursor:
            cursor.close()


def create_table(con, table_name, create_table_query):
    result = execute_fetchone_query(con, "SHOW TABLES like '%s'" % (table_name))
    if not result:
        execute_fetchone_query(con, create_table_query)


def drop_table(con, table_name):
    result = execute_fetchone_query(con, "SHOW TABLES like '%s'" % (table_name))
    if result:
        query = """
            DROP TABLE %s;
        """ % (table_name)
        execute_query(con, query)


def add_table_column(con, table_name, column_name, add_column_query):
    query = """
        select column_name from information_schema.columns where table_schema = 'mon' and table_name = '%s' and column_name = '%s';
    """ % (table_name, column_name)
    result = execute_fetchone_query(con, query)
    if not result:
        execute_query(con, add_column_query)


def create_alarm_state_table(con):
    create_table_query = """
        CREATE TABLE `alarm_state` (
          `name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
          PRIMARY KEY (`name`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    """
    create_table(con, 'alarm_state', create_table_query)


def create_alarm_definition_severity_table(con):
    create_table_query = """
        CREATE TABLE `alarm_definition_severity` (
          `name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
          PRIMARY KEY (`name`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    """
    create_table(con, 'alarm_definition_severity', create_table_query)


def create_stream_actions_action_type_table(con):
    create_table_query = """
        CREATE TABLE `stream_actions_action_type` (
          `name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
          PRIMARY KEY (`name`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    """
    create_table(con, 'stream_actions_action_type', create_table_query)


def create_schema_migration_table(con):
    create_table_query = """
        CREATE TABLE `schema_migration` (
          `version` varchar(255) NOT NULL,
          CONSTRAINT `unique_schema_migrations` UNIQUE (`version`)
        ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    """
    create_table(con, 'schema_migration', create_table_query)


def create_stream_definition_table(con):
    create_table_query = """
        CREATE TABLE `stream_definition` (
          `id` varchar(36) NOT NULL,
          `tenant_id` varchar(36) NOT NULL,
          `name` varchar(190) NOT NULL DEFAULT '',
          `description` varchar(255) DEFAULT NULL,
          `select_by` longtext DEFAULT NULL,
          `group_by` longtext DEFAULT NULL,
          `fire_criteria` longtext DEFAULT NULL,
          `expiration` int(10) DEFAULT '0',
          `action_enabled` tinyint(1) NOT NULL DEFAULT '1',
          `created_at` datetime NOT NULL,
          `updated_at` datetime NOT NULL,
          `deleted_at` datetime NOT NULL,
          PRIMARY KEY (`id`),
          CONSTRAINT `tenant_name` UNIQUE (`tenant_id`, `name`),
          INDEX `name` (`name`),
          INDEX `tenant_id` (`tenant_id`),
          INDEX `deleted_at` (`deleted_at`),
          INDEX `created_at` (`created_at`),
          INDEX `updated_at` (`updated_at`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    """
    create_table(con, 'stream_definition', create_table_query)


def create_stream_actions_table(con):
    create_table_query = """
        CREATE TABLE `stream_actions` (
          `stream_definition_id` varchar(36) NOT NULL,
          `action_id` varchar(36) NOT NULL,
          `action_type` varchar(20) NOT NULL,
          CONSTRAINT `fk_stream_action_stream_definition_id` FOREIGN KEY (`stream_definition_id`) REFERENCES `stream_definition` (`id`) ON DELETE CASCADE,
          CONSTRAINT `fk_stream_action_notification_method_id` FOREIGN KEY (`action_id`) REFERENCES `notification_method` (`id`) ON DELETE CASCADE,
          FOREIGN KEY (`action_type`) REFERENCES `stream_actions_action_type` (`name`),
          PRIMARY KEY (`stream_definition_id`, `action_id`, `action_type`),

          INDEX `stream_definition_id` (`stream_definition_id`),
          INDEX `action_type` (`action_type`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    """
    create_table(con, 'stream_actions', create_table_query)


def create_event_transform_table(con):
    create_table_query = """
        CREATE TABLE `event_transform` (
          `id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
          `tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
          `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
          `description` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
          `specification` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
          `enabled` tinyint(1) DEFAULT NULL,
          `created_at` datetime NOT NULL,
          `updated_at` datetime NOT NULL,
          `deleted_at` datetime NOT NULL,
          PRIMARY KEY (`id`),
          INDEX `name` (`name`),
          INDEX `tenant_id` (`tenant_id`),
          INDEX `deleted_at` (`deleted_at`),
          INDEX `created_at` (`created_at`),
          INDEX `updated_at` (`updated_at`),
          CONSTRAINT `tenant_name` UNIQUE (`tenant_id`, `name`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    """
    create_table(con, 'event_transform', create_table_query)


def populate_table_column_with_value(con, table_name, column_name, value):
    query = """
        select * from `%s` where %s = '%s';
    """ % (table_name, column_name, value)
    result = execute_fetchone_query(con, query)
    if not result:
        query = """
            insert into `%s` (%s) values ('%s');
        """ % (table_name, column_name, value)
        execute_query(con, query)


def populate_alarm_state_table(con):
    populate_table_column_with_value(con, 'alarm_state', 'name', 'UNDETERMINED')
    populate_table_column_with_value(con, 'alarm_state', 'name', 'OK')
    populate_table_column_with_value(con, 'alarm_state', 'name', 'ALARM')


def populate_alarm_definition_severity_table(con):
    populate_table_column_with_value(con, 'alarm_definition_severity', 'name', 'LOW')
    populate_table_column_with_value(con, 'alarm_definition_severity', 'name', 'MEDIUM')
    populate_table_column_with_value(con, 'alarm_definition_severity', 'name', 'HIGH')
    populate_table_column_with_value(con, 'alarm_definition_severity', 'name', 'CRITICAL')


def populate_notification_method_type_table(con):
    populate_table_column_with_value(con, 'notification_method_type', 'name', 'EMAIL')
    populate_table_column_with_value(con, 'notification_method_type', 'name', 'WEBHOOK')
    populate_table_column_with_value(con, 'notification_method_type', 'name', 'PAGERDUTY')


def populate_stream_actions_action_type_table(con):
    populate_table_column_with_value(con, 'stream_actions_action_type', 'name', 'FIRE')
    populate_table_column_with_value(con, 'stream_actions_action_type', 'name', 'EXPIRE')


def update_notification_method_type_table(con):
    query = """
        ALTER TABLE `notification_method_type` MODIFY `name` VARCHAR(20);
    """
    execute_query(con, query)

def add_constraint(con, table_name, constraint_name, add_constraint_query):
    query = """
        select * from information_schema.table_constraints where constraint_schema = 'mon' and constraint_name = '%s' and table_name = '%s';
    """ % (constraint_name, table_name)
    result = execute_fetchone_query(con, query)
    if not result:
        execute_query(con, add_constraint_query)


def update_alarm_table(con):
    querys = ["""ALTER TABLE `alarm` MODIFY COLUMN `state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL;""",
              """ALTER TABLE `alarm` MODIFY COLUMN `created_at` datetime NOT NULL;""",
              """ALTER TABLE `alarm` MODIFY COLUMN `state_updated_at` datetime DEFAULT NULL;""",
              """ALTER TABLE `alarm` MODIFY COLUMN `updated_at` datetime NOT NULL;"""]
    for query in querys:
        execute_query(con, query)

    query = """ALTER TABLE `alarm` ADD CONSTRAINT `fk_alarm_alarm_state` FOREIGN KEY (`state`) REFERENCES `alarm_state` (`name`);"""
    add_constraint(con, 'alarm', 'fk_alarm_alarm_state', query)

    #query = """ALTER TABLE `alarm` ADD `inhibited` tinyint(1) NOT NULL DEFAULT '0';"""
    #add_table_column(con, 'alarm', 'inhibited', query)
    #query = """ALTER TABLE `alarm` ADD `silenced` tinyint(1) NOT NULL DEFAULT '0';"""
    #add_table_column(con, 'alarm', 'silenced', query)


def update_alarm_action_table(con):
    querys = ["""ALTER TABLE `alarm_action` MODIFY COLUMN `alarm_state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL;"""]
    for query in querys:
        execute_query(con, query)

    query = """ALTER TABLE `alarm_action` ADD CONSTRAINT `fk_alarm_action_alarm_state` FOREIGN KEY (`alarm_state`) REFERENCES `alarm_state` (`name`);"""
    add_constraint(con, 'alarm_action', 'fk_alarm_action_alarm_state', query)


def update_alarm_definition_table(con):
    querys = ["""ALTER TABLE `alarm_definition` MODIFY COLUMN `expression` longtext COLLATE utf8mb4_unicode_ci NOT NULL;""",
              """ALTER TABLE `alarm_definition` MODIFY COLUMN `severity` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL;""",
              """ALTER TABLE `alarm_definition` MODIFY COLUMN `actions_enabled` tinyint(1) NOT NULL DEFAULT '1';"""]
    for query in querys:
        execute_query(con, query)

    query = """ALTER TABLE `alarm_definition` ADD CONSTRAINT `fk_alarm_definition_severity` FOREIGN KEY (`severity`) REFERENCES `alarm_definition_severity` (`name`);"""
    add_constraint(con, 'alarm_definition', 'fk_alarm_definition_severity', query)


def update_notification_method_table(con):
    query = """ALTER TABLE `notification_method` ADD CONSTRAINT `fk_alarm_noticication_method_type` FOREIGN KEY (`type`) REFERENCES `notification_method_type` (`name`);"""
    add_constraint(con, 'notification_method', 'fk_alarm_noticication_method_type', query)


def update_sub_alarm_table(con):
    querys = ["""ALTER TABLE `sub_alarm` MODIFY COLUMN `expression` longtext COLLATE utf8mb4_unicode_ci NOT NULL;""",
              """ALTER TABLE `sub_alarm` MODIFY COLUMN `created_at` datetime NOT NULL;""",
              """ALTER TABLE `sub_alarm` MODIFY COLUMN `updated_at` datetime NOT NULL;""",
              """ALTER TABLE `sub_alarm` MODIFY COLUMN `state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'OK';"""]
    for query in querys:
        execute_query(con, query)

    query = """ALTER TABLE `sub_alarm` ADD CONSTRAINT `fk_sub_alarm_state` FOREIGN KEY (`state`) REFERENCES `alarm_state` (`name`);"""
    add_constraint(con, 'sub_alarm', 'fk_sub_alarm_state', query)


def drop_schema_version_table(con):
    drop_table(con, 'schema_version')


def main():
    return_code = 0
    try:
        ssl = {'ca': '{{ monasca_schema_system_cacert_file }}' }
        con = MySQLdb.connect('{{ mysql_host }}', '{{ monasca_api_mysql_user }}', '{{ monasca_api_mysql_password }}',
                              '{{ monasca_mysql_db }}', ssl=ssl)

        con.autocommit(True)

        # NOTE(gyee): the following code was used to retrace the upstream
        # migration steps. They were merely used to retrace the intermediate
        # steps, and therefore no loger needed once we've reached the final
        # stamp. We are leaving it here instead of removing it so we can
        # reuse it for future debugging purposes.
        #create_schema_migration_table(con)
        #create_stream_definition_table(con)
        #create_stream_actions_action_type_table(con)
        #populate_stream_actions_action_type_table(con)
        #create_stream_actions_table(con)
        #create_event_transform_table(con)

        create_alarm_state_table(con)
        populate_alarm_state_table(con)
        create_alarm_definition_severity_table(con)
        populate_alarm_definition_severity_table(con)
        update_notification_method_type_table(con)
        populate_notification_method_type_table(con)
        update_alarm_table(con)
        update_alarm_action_table(con)
        update_alarm_definition_table(con)
        update_notification_method_table(con)
        update_sub_alarm_table(con)
        drop_schema_version_table(con)

    except MySQLdb.MySQLError as sql_error:
        print "Mysql error {0} when running the script".format(sql_error)
        return_code = 1
    except Exception as e:
        print "Error {0} when running the script".format(e)
        return_code = 1

    finally:
        if con:
            con.close()
        sys.exit(return_code)

if __name__ == "__main__":
    sys.exit(main())
0707010000011A000081A40000000000000000000000015EBC182800000E2A000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/templates/winchester.sql.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
USE '{{ monasca_mysql_winchester_db }}';

CREATE TABLE alembic_version (
    version_num VARCHAR(32) NOT NULL
);

-- Running upgrade None -> 3ab6d7bf80cd

CREATE TABLE event_type (
    id INTEGER NOT NULL AUTO_INCREMENT,
    `desc` VARCHAR(255),
    PRIMARY KEY (id),
    UNIQUE (`desc`)
);

CREATE TABLE event (
    id INTEGER NOT NULL AUTO_INCREMENT,
    message_id VARCHAR(50),
    generated DECIMAL(20, 6),
    event_type_id INTEGER,
    PRIMARY KEY (id),
    FOREIGN KEY(event_type_id) REFERENCES event_type (id),
    UNIQUE (message_id)
);

CREATE TABLE trait (
    event_id INTEGER NOT NULL,
    name VARCHAR(100) NOT NULL,
    type INTEGER,
    t_string VARCHAR(255),
    t_float FLOAT,
    t_int INTEGER,
    t_datetime DECIMAL(20, 6),
    PRIMARY KEY (event_id, name),
    FOREIGN KEY(event_id) REFERENCES event (id)
);

INSERT INTO alembic_version (version_num) VALUES ('3ab6d7bf80cd');

-- Running upgrade 3ab6d7bf80cd -> 44289d1492e6

CREATE TABLE stream (
    id INTEGER NOT NULL AUTO_INCREMENT,
    first_event DECIMAL(20, 6) NOT NULL,
    last_event DECIMAL(20, 6) NOT NULL,
    expire_timestamp DECIMAL(20, 6),
    fire_timestamp DECIMAL(20, 6),
    name VARCHAR(255) NOT NULL,
    state INTEGER NOT NULL,
    state_serial_no INTEGER NOT NULL,
    PRIMARY KEY (id)
);

CREATE INDEX ix_stream_expire_timestamp ON stream (expire_timestamp);

CREATE INDEX ix_stream_fire_timestamp ON stream (fire_timestamp);

CREATE INDEX ix_stream_name ON stream (name);

CREATE INDEX ix_stream_state ON stream (state);

CREATE TABLE dist_trait (
    stream_id INTEGER NOT NULL,
    name VARCHAR(100) NOT NULL,
    type INTEGER,
    dt_string VARCHAR(255),
    dt_float FLOAT,
    dt_int INTEGER,
    dt_datetime DECIMAL(20, 6),
    dt_timerange_begin DECIMAL(20, 6),
    dt_timerange_end DECIMAL(20, 6),
    PRIMARY KEY (stream_id, name),
    FOREIGN KEY(stream_id) REFERENCES stream (id)
);

CREATE INDEX ix_dist_trait_dt_datetime ON dist_trait (dt_datetime);

CREATE INDEX ix_dist_trait_dt_float ON dist_trait (dt_float);

CREATE INDEX ix_dist_trait_dt_int ON dist_trait (dt_int);

CREATE INDEX ix_dist_trait_dt_string ON dist_trait (dt_string);

CREATE INDEX ix_dist_trait_dt_timerange_begin ON dist_trait (dt_timerange_begin);

CREATE INDEX ix_dist_trait_dt_timerange_end ON dist_trait (dt_timerange_end);

CREATE TABLE streamevent (
    stream_id INTEGER NOT NULL,
    event_id INTEGER NOT NULL,
    PRIMARY KEY (stream_id, event_id),
    FOREIGN KEY(event_id) REFERENCES event (id),
    FOREIGN KEY(stream_id) REFERENCES stream (id)
);

CREATE INDEX ix_event_generated ON event (generated);

CREATE INDEX ix_event_message_id ON event (message_id);

CREATE INDEX ix_event_type_id ON event (event_type_id);

CREATE INDEX ix_trait_t_datetime ON trait (t_datetime);

CREATE INDEX ix_trait_t_float ON trait (t_float);

CREATE INDEX ix_trait_t_int ON trait (t_int);

CREATE INDEX ix_trait_t_string ON trait (t_string);

UPDATE alembic_version SET version_num='44289d1492e6';

0707010000011B000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/vars0707010000011C000081A40000000000000000000000015EBC18280000027C000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/vars/debian.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_schema_package_dependencies:
  - python-mysqldb
0707010000011D000081A40000000000000000000000015EBC18280000027A000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-schema/vars/suse.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_schema_package_dependencies:
  - python-mysql
0707010000011E000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh0707010000011F000081A40000000000000000000000015EBC1828000002EE000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/README.md#monasca-thresh
Installs the [monasca-thresh](https://github.com/stackforge/monasca-notification) part of the [Monasca](https://wiki.openstack.org/wiki/Monasca) project.
Monasca-thresh requires storm to be running and should be installed on the nimbus box.

##Requirements
- kafka_hosts - comma separated list of host:port pairs.
- mysql_host - By default ssl will be used if available.
- monasca_thresh_mysql_user
- monasca_thresh_mysql_password
- zookeeper_hosts - comma separated list of host:port pairs.

## Optional
- run_mode: One of Deploy, Stop, Install, Configure or Start. The default is Deploy which will do Install, Configure, then Start.

##License
Apache

##Author Information
Tim Kuhlman
Monasca Team email monasca@lists.launchpad.net
07070100000120000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/defaults07070100000121000081A40000000000000000000000015EBC182800000968000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/defaults/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
kafka_event:
  consumer_topic: events
  group: thresh-event
  producer_topic: alarm-state-transitions
kafka_metric:
  topic: metrics
  group: thresh-metric
thresh_conf_file: "{{ 'monasca' | config_dir() }}/thresh-config.yml"
monasca_group: monasca
thresh_group: thresh
monasca_mysql_db: "{{ MON_THR.consumes_FND_MDB.vars.databases.monasca.dbname }}"
monasca_thresh_version: "2.1.1-SNAPSHOT"
thresh_statsd_host: localhost

monasca_thresh_jar: "{{ monasca_jars_virtualenv_dir }}/usr/share/monasca-thresh/monasca-thresh-{{ monasca_thresh_version }}-shaded.jar"

monasca_thresh_jdbc_driver_class: "com.mysql.jdbc.Driver"

monasca_thresh_jdbc_driver_type: "mysql"

monasca_thresh_jar_saved_md5: /opt/monasca/md5sums/monasca-thresh.md5
monasca_thresh_shell: /sbin/nologin
monasca_thresh_wrapper: /usr/sbin/monasca-thresh-wrapper
monasca_thresh_storm_timeout: "2m"

run_mode: Deploy
skip_install: False

kafka_nodes: "{{ MON_THR.consumes_FND_KFK.members.private }}"
kafka_hosts: "{% for node in kafka_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

mysql_host: "{{MON_THR.consumes_FND_MDB.vips.private[0].host}}"
mysql_port: "{{ MON_THR.consumes_FND_MDB.vips.private[0].port }}"

mysql_https_arg: "{% if MON_THR.consumes_FND_MDB.vips.private[0].use_tls %}&useSSL=true{% endif %}"

monasca_thresh_mysql_user: "{{ MON_THR.consumes_FND_MDB.vars.accounts.monasca_thresh.username }}"
monasca_thresh_mysql_password: "{{ MON_THR.consumes_FND_MDB.vars.accounts.monasca_thresh.password | quote }}"

zookeeper_nodes: "{{ MON_THR.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"

storm_executable: "/usr/bin/storm"
07070100000122000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/meta07070100000123000081A40000000000000000000000015EBC182800000370000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs Monasca-Thresh
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - all
  categories:
  - system
dependencies: []
07070100000124000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks07070100000125000081A40000000000000000000000015EBC18280000032D000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: monasca-thresh | _schedule_restart |
    Schedule a restart for monasca-thresh
  debug:
    msg: "Trigger a change notification in monasca-thresh"
  changed_when: true
  register: ardana_notify_monasca_thresh_restart_required07070100000126000081A40000000000000000000000015EBC1828000010F4000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks/configure.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: setup monasca_group
  group: name={{monasca_group}} system=yes
  register: ardana_notify_monasca_thresh_restart_required

- name: Setup user
  user:
    name: "{{ thresh_user }}"
    system: yes
    group: "{{ monasca_group }}"
    groups: "storm"
    shell: "{{ monasca_thresh_shell }}"
    createhome: no
    home: /var/nonexistent
  register: ardana_notify_monasca_thresh_restart_required
  failed_when: ardana_notify_monasca_thresh_restart_required|failed and
                "user {{ thresh_user }} is currently used by process"
                not in ardana_notify_monasca_thresh_restart_required.msg

- name: stat /etc/monasca/thresh-config.yml file
  stat: path=/etc/monasca/thresh-config.yml
  register: thresh_conf_file_result

- name: move thresh-config.yml to thresh-config.yml.old if not a symlink
  command: mv /etc/monasca/thresh-config.yml /etc/monasca/thresh-config.yml.old
  when: thresh_conf_file_result.stat.exists and thresh_conf_file_result.stat.isreg

- name: create conf_file from template
  template: dest={{ thresh_conf_file }} owner=root group={{monasca_group}} mode=0640 src=thresh-config.yml.j2
  register: ardana_notify_monasca_thresh_restart_required

- name: link /etc/monasca/thresh-config.yml to service config dir
  file:
    path: /etc/monasca/thresh-config.yml
    src: "{{ 'monasca' | config_dir() }}/thresh-config.yml"
    state: link
    owner: root
    group: "{{monasca_group}}"
    mode: 0640

- name: create wrapper script from template
  template:
    src: monasca-thresh-wrapper.j2
    owner: root
    group: root
    mode: 0744
    dest: "{{ monasca_thresh_wrapper }}"
  register: ardana_notify_monasca_thresh_restart_required

- name: Detect if this is a systemd based system
  command: cat /proc/1/comm
  register: init
- set_fact: use_systemd=True
  when: init.stdout == 'systemd'
- set_fact: use_systemd=False
  when: init.stdout != 'systemd'

- name: Drop monasca-tresh init service file
  template:
    src: monasca-thresh.init.j2
    dest: /etc/init.d/monasca-thresh
    owner: root
    group: root
    mode: 0744
  when: not use_systemd

- name: Drop monasca-tresh systemd service file
  template:
    src: monasca-thresh.service.j2
    dest: /etc/systemd/system/monasca-thresh.service
    owner: root
    group: root
    mode: 0640
  when: use_systemd

- command: systemctl daemon-reload
  when: use_systemd

- name: Create directory for storing md5sums
  file:
    path: "{{ monasca_thresh_jar_saved_md5 | dirname }}"
    state: directory
    owner: root
    group: root
    mode: 0755

- name: Determine md5 of monasca-thresh jar
  stat:
    path: "{{ monasca_thresh_jar }}"
    follow: yes
  register: monasca_thresh_jar_result

- name: Check if current md5 exists
  stat:
    path: "{{ monasca_thresh_jar_saved_md5 }}"
  register: monasca_thresh_jar_old_md5_file_result

- name: Get the current md5 if it exists
  slurp:
    src: "{{ monasca_thresh_jar_saved_md5 }}"
  when: monasca_thresh_jar_old_md5_file_result.stat.exists
  register: monasca_thresh_jar_old_md5_result

- name: Mark Monasca Threshold Engine for restart if new monasca-thresh jar
  debug: msg="restart monasca-thresh because monasca-thresh jar changed"
  changed_when: True
  when: not monasca_thresh_jar_old_md5_file_result.stat.exists or
        ( monasca_thresh_jar_old_md5_file_result.stat.exists and
          ( monasca_thresh_jar_result.stat.md5 !=
            ( monasca_thresh_jar_old_md5_result.content | b64decode ) ) )
  register: ardana_notify_monasca_thresh_restart_required

- name: Write md5sum if changed or not written yet
  copy:
    dest: "{{ monasca_thresh_jar_saved_md5 }}"
    content: "{{ monasca_thresh_jar_result.stat.md5 }}"
07070100000127000081A40000000000000000000000015EBC182800000432000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks/install.yml# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Update venv cache
  become: yes
  install_package:
    cache: update

- name: Install the monasca venv
  install_package:
    name: monasca
    service: monasca
    state: present
  register: ardana_notify_monasca_thresh_restart_required

- name: Install | Set up service dirs
  set_fact:
    thresh_conf_file: "{{ 'monasca' | config_dir(ardana_notify_monasca_thresh_restart_required.version) }}/thresh-config.yml"
07070100000128000081A40000000000000000000000015EBC18280000042A000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- include: stop.yml
  when: run_mode == 'Stop'

- include: install.yml
  when: not skip_install and
    (run_mode == 'Install' or run_mode == 'Deploy' or run_mode == 'Upgrade')

- include: configure.yml
  when: run_mode == 'Configure' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'

- include: start.yml
  when: run_mode == 'Configure' or run_mode == 'Start' or
    run_mode == 'Deploy' or run_mode == 'Upgrade'
07070100000129000081A40000000000000000000000015EBC1828000006C4000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: monasca-thresh | start | restart monasca thresh service
  service: name=monasca-thresh state=restarted enabled=yes
  when: (not (ardana_notify_monasca_thresh_restart_required is not defined)) and
        ardana_notify_monasca_thresh_restart_required.changed
  failed_when: false

- name: start | Start monasca thresh service
  service: name=monasca-thresh state=started enabled=yes
  failed_when: false

# wait for the service to start or fail to start, allowing for
# possibility of limited number of auto-restarts
- name: monasca-thresh | start | wait for monasca-thresh service to start
  include: "{{ playbook_dir }}/roles/monasca-variables/tasks/service_status.yml"
  vars:
    service_name: monasca-thresh

# NOTE: stat'ing /dev/null to run an arbitrary action that generates no output
- name: monasca-thresh | start | clear any persistent monasca-thresh restart flag
  stat:
    path: /dev/null
  when: ardana_notify_monasca_thresh_restart_required is defined
  changed_when: False

- name: monasca-thresh | start | pause for monasca-thresh to start
  pause: seconds=2
0707010000012A000081A40000000000000000000000015EBC1828000002CC000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/tasks/stop.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop Monasca-thresh
  service: name=monasca-thresh state=stopped
0707010000012B000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/templates0707010000012C000081A40000000000000000000000015EBC182800000C56000000000000000000000000000000000000006300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/templates/monasca-thresh-wrapper.j2#!/bin/bash
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#

# Run storm command optionally with specified timeout
storm_cmd()
{
  local timeout="" cmd_args=()

  # check if a specific timeout specified, can be empty string to disable
  case "${1}" in
      timeout=*)
        eval "${1}"
        shift
        ;;
  esac

  # if timeout is not disabled prepend timeout ${timeout} to cmd_args
  if [[ -n "${timeout}" ]]; then
    cmd_args+=( timeout "${timeout}" )
  fi

  # add storm command + args to cmd_args
  cmd_args+=( {{ storm_executable }} "${@}" )

  sudo -EHu {{ thresh_user }} "${cmd_args[@]}"
}

storm_check_svc()
{
  local list_rc svc timeout="{{ monasca_thresh_storm_timeout }}" tmp_file="$(mktemp --tmpdir mtw_storm_check_svc.XXXXXXXX)"

  case "${1}" in
      timeout=*)
        timeout="${1}"
        shift
        ;;
  esac

  svc="${1}"

  storm_cmd ${timeout:+timeout="${timeout}"} list > "${tmp_file}" 2>&1
  list_rc=$?

  # if list command timed out
  if (( list_rc == 124 )); then
    echo "storm list timed out"
  else
    grep "${svc}" "${tmp_file}"
    list_rc=$?
  fi

  # remove temp file
  rm -f "${tmp_file}"

  return ${list_rc}
}

case "$1" in
    start)
      storm_check_svc thresh-cluster
      check_rc=$?
      if (( check_rc == 124 )); then
        exit ${check_rc}
      elif (( check_rc != 0 )); then
        storm_cmd jar {{ monasca_thresh_jar }} monasca.thresh.ThresholdingEngine {{ 'monasca' | config_dir() }}/thresh-config.yml thresh-cluster
        exit $?
      else
        echo "monasca-thresh is already running"
        exit 0
      fi
    ;;
    stop)
      # On system shutdown storm is being shutdown also and this will hang so skip shutting down thresh in that case
      if [ -e '/sbin/runlevel' ]; then  # upstart/sysV case
        if [ $(runlevel | cut -d\  -f 2) == 0 ]; then
          exit 0
        fi
      else  # systemd case
        systemctl list-units --type=target |grep shutdown.target
        if [ $? -eq 0 ]; then
          exit 0
        fi
      fi

      storm_cmd kill thresh-cluster

      # The kill command returns but actually takes awhile loop watching status
      timeout_retries=3
      while true; do
        storm_check_svc thresh-cluster
        check_rc=$?

        if (( check_rc == 124 )); then
          (( timeout_retries -= 1 ))
          (( timeout_retries == 0 )) && exit ${check_rc}
        elif (( check_rc == 1 )); then
          break
        fi

        sleep 1
      done
    ;;
    status)
        storm_check_svc thresh-cluster
        exit $?
    ;;
esac
0707010000012D000081A40000000000000000000000015EBC182800000887000000000000000000000000000000000000006000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/templates/monasca-thresh.init.j2#!/bin/bash
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
### BEGIN INIT INFO
# Provides:          monasca-thresh
# Required-Start:    $nimbus
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Monitoring threshold engine running under storm
# Description:
### END INIT INFO

case "$1" in
    start)
      $0 status
      if [ $? -ne 0 ]; then
        sudo -Hu {{thresh_user}} {{ storm_executable }} jar {{ monasca_thresh_jar}} monasca.thresh.ThresholdingEngine {{ 'monasca' | config_dir() }}/thresh-config.yml thresh-cluster
        exit $?
      else
        echo "monasca-thresh is already running"
        exit 0
      fi
    ;;
    stop)
      # On system shutdown storm is being shutdown also and this will hang so skip shutting down thresh in that case
      if [ -e '/sbin/runlevel' ]; then  # upstart/sysV case
        if [ $(runlevel | cut -d\  -f 2) == 0 ]; then
          exit 0
        fi
      else  # systemd case
        systemctl list-units --type=target |grep shutdown.target
        if [ $? -eq 0 ]; then
          exit 0
        fi
      fi
      sudo -Hu {{thresh_user}} {{ storm_executable }} kill thresh-cluster
      # The above command returns but actually takes awhile loop watching status
      while true; do
        sudo -Hu {{thresh_user}} {{ storm_executable }} list |grep thresh-cluster
        if [ $? -ne 0 ]; then break; fi
        sleep 1
      done
    ;;
    status)
        sudo -Hu {{thresh_user}} {{ storm_executable }} list |grep thresh-cluster
    ;;
    restart)
      $0 stop
      $0 start
    ;;
esac
0707010000012E000081A40000000000000000000000015EBC1828000001ED000000000000000000000000000000000000006300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/templates/monasca-thresh.service.j2[Unit]
After=systemd-journald.socket basic.target system.slice
Requires=basic.target
Description=Monitoring threshold engine running under storm
Conflicts=shutdown.target
Before=shutdown.target multi-user.target

[Service]
Type=forking
Restart=always
RestartSec=10
TimeoutSec=5min
KillMode=process
IgnoreSIGPIPE=no
GuessMainPID=no
RemainAfterExit=yes
PrivateTmp=yes
ExecStart={{ monasca_thresh_wrapper }} start
ExecStop={{ monasca_thresh_wrapper }} stop

[Install]
WantedBy=multi-user.target

0707010000012F000081A40000000000000000000000015EBC182800000F67000000000000000000000000000000000000005E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/templates/thresh-config.yml.j2{#
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
metricSpoutThreads: {{ thresh_metric_spout_threads }}
metricSpoutTasks: {{ thresh_metric_spout_tasks }}

statsdConfig:
  host: "{{thresh_statsd_host}}"
  port: 8125
  prefix: monasca.storm.
  dimensions: !!map
    service : monitoring
    component : storm


metricSpoutConfig:
  kafkaConsumerConfiguration:
  # See http://kafka.apache.org/documentation.html#api for semantics and defaults.
    topic: "{{kafka_metric.topic}}"
    numThreads: 1
    groupId: "{{kafka_metric.group}}"
    zookeeperConnect: "{{zookeeper_hosts}}"
    consumerId: 1
    socketTimeoutMs: 30000
    socketReceiveBufferBytes : 65536
    fetchMessageMaxBytes: 1048576
    autoCommitEnable: true
    autoCommitIntervalMs: 60000
    queuedMaxMessageChunks: 10
    rebalanceMaxRetries: 4
    fetchMinBytes:  1
    fetchWaitMaxMs:  100
    rebalanceBackoffMs: 2000
    refreshLeaderBackoffMs: 200
    autoOffsetReset: largest
    consumerTimeoutMs:  -1
    clientId : 1
    zookeeperSessionTimeoutMs : 60000
    zookeeperConnectionTimeoutMs : 60000
    zookeeperSyncTimeMs: 2000


eventSpoutConfig:
  kafkaConsumerConfiguration:
  # See http://kafka.apache.org/documentation.html#api for semantics and defaults.
    topic: "{{kafka_event.consumer_topic}}"
    numThreads: 1
    groupId: "{{kafka_event.group}}"
    zookeeperConnect: "{{zookeeper_hosts}}"
    consumerId: 1
    socketTimeoutMs: 30000
    socketReceiveBufferBytes : 65536
    fetchMessageMaxBytes: 1048576
    autoCommitEnable: true
    autoCommitIntervalMs: 60000
    queuedMaxMessageChunks: 10
    rebalanceMaxRetries: 4
    fetchMinBytes:  1
    fetchWaitMaxMs:  100
    rebalanceBackoffMs: 2000
    refreshLeaderBackoffMs: 200
    autoOffsetReset: largest
    consumerTimeoutMs:  -1
    clientId : 1
    zookeeperSessionTimeoutMs : 60000
    zookeeperConnectionTimeoutMs : 60000
    zookeeperSyncTimeMs: 2000


kafkaProducerConfig:
  # See http://kafka.apache.org/documentation.html#api for semantics and defaults.
  topic: "{{kafka_event.producer_topic}}"
  metadataBrokerList: "{{kafka_hosts}}"
  serializerClass: kafka.serializer.StringEncoder
  partitionerClass:
  requestRequiredAcks: 1
  requestTimeoutMs: 10000
  producerType: sync
  keySerializerClass:
  compressionCodec: none
  compressedTopics:
  messageSendMaxRetries: 3
  retryBackoffMs: 100
  topicMetadataRefreshIntervalMs: 600000
  queueBufferingMaxMs: 5000
  queueBufferingMaxMessages: 10000
  queueEnqueueTimeoutMs: -1
  batchNumMessages: 200
  sendBufferBytes: 102400
  clientId : Threshold_Engine


sporadicMetricNamespaces:
  - foo

database:
  driverClass: {{ monasca_thresh_jdbc_driver_class }}
  url: "jdbc:{{ monasca_thresh_jdbc_driver_type }}://{{mysql_host}}:{{ mysql_port }}/{{monasca_mysql_db}}?connectTimeout=5000&autoReconnect=true&useLegacyDatetimeCode=false&serverTimezone=UTC{{ mysql_https_arg }}"
  user: "{{monasca_thresh_mysql_user}}"
  password: "{{monasca_thresh_mysql_password| quote }}"
  # the maximum amount of time to wait on an empty pool before throwing an exception
  maxWaitForConnection: 1s

  # the SQL query to run when validating a connection's liveness
  validationQuery: "/* MyService Health Check */ SELECT 1"

  # the minimum number of connections to keep open
  minSize: 8

  # the maximum number of connections to keep open


  maxSize: 41
07070100000130000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/vars07070100000131000081A40000000000000000000000015EBC1828000002B2000000000000000000000000000000000000004D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/vars/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_group: monasca
thresh_user: mon-thresh
07070100000132000081A40000000000000000000000015EBC18280000034B000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-thresh/vars/nodes.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
thresh_host_list: "{{ MON_THR.members.admin | sort(attribute='member_id') }}"
thresh_start_enabled: "{% if host.vars.member_id | int == thresh_host_list[0].member_id %}True{% else %}False{% endif %}"
07070100000133000041ED0000000000000000000000065EBC182800000000000000000000000000000000000000000000004200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables07070100000134000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/defaults07070100000135000081A40000000000000000000000015EBC182800001C55000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/defaults/main.yml
#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
# Select default tunings based on system RAM
# RAM < 32GB, use demo
# RAM < 64GB, use small
# RAM < 128GB, use medium
# RAM >= 128GB, use large
monasca_ram_tuning_selector: "{% if ansible_memtotal_mb < 31000 %}demo{% elif ansible_memtotal_mb < 63000 %}small{% elif ansible_memtotal_mb < 127000 %}medium{% else %}large{%endif %}"

# tuning_selector has precedence in order to be compatible with versions of older release.
tuning_selector:
monasca_tuning_selector: "{% if tuning_selector %}{{ tuning_selector }}{% elif monasca_tuning_selector_override %}{{ monasca_tuning_selector_override }}{% else %}{{ monasca_ram_tuning_selector }}{% endif %}"

monasca_tunings: "{{ monasca_possible_tunings[monasca_tuning_selector] }}"

storm_nimbus_extra_config:
    nimbus.childopts: "{% if storm_nimbus_childopts_override %}{{ storm_nimbus_childopts_override }}{% else %}{{ monasca_tunings.storm_nimbus_childopts }}{% endif %}"
storm_supervisor_extra_config:
    supervisor.childopts: "{% if storm_supervisor_childopts_override %}{{ storm_supervisor_childopts_override }}{% else %}{{ monasca_tunings.storm_supervisor_childopts }}{% endif %}"
storm_ui_extra_config:
    ui.childopts: "{% if storm_ui_childopts_override %}{{ storm_ui_childopts_override }}{% else %}{{ monasca_tunings.storm_ui_childopts }}{% endif %}"
storm_worker_extra_config:
    worker.childopts: "{% if storm_worker_childopts_override %}{{ storm_worker_childopts_override }}{% else %}{{ monasca_tunings.storm_worker_childopts_heap }}{% endif %} -XX:+UseConcMarkSweepGC -Dcom.sun.management.jmxremote"
storm_worker_ports: "{% if storm_worker_ports_override %}{{ storm_worker_ports_override }}{% else %}{{ monasca_tunings.storm_worker_ports }}{% endif %}"
monasca_jars_virtualenv_dir: /opt/stack/service/monasca/venv
monasca_notification_virtualenv_dir: /opt/stack/service/monasca-notification/venv

# Agent Defaults
monasca_agent_virtualenv_dir: /opt/stack/service/monasca-agent/venv
monasca_agent_check_frequency: 30
monasca_agent_system_only: true
monasca_agent_detection_args: send_rollup_stats=True

# For RHEL node, monasca-setup is found at both venv/usr/bin and venv/bin
# paths. We are using venv/usr/bin path so that related agent templates can be
# found at venv/usr/share/monasca/agent path. This is different from legacy and
# SLES setup. SLES node installs monasca-agent via rpm where as in RHEL node,
# its installed via venv.
monasca_setup_bin_dir: "{%- if ansible_os_family|lower == 'redhat' -%}
                          {{monasca_agent_virtualenv_dir}}/usr/bin
                        {%- else -%}
                          /usr/bin
                        {%- endif -%}"

# Kafka Defaults
kafka_heap_opts: "{% if kafka_heap_opts_override %}{{ kafka_heap_opts_override }}{% else %}{{ monasca_tunings.kafka_heap_opts }}{% endif %}"
kafka_log_retention_hours: "{% if kafka_log_retention_hours_override %}{{ kafka_log_retention_hours_override }}{% else %}{{ monasca_tunings.kafka_log_retention_hours }}{% endif %}"
kafka_consumer_path: /etc/monasca/agent/conf.d/kafka_consumer.yaml

# API Defaults
monasca_api_java_opts: "{% if monasca_api_java_opts_override %}{{ monasca_api_java_opts_override }}{% else %}{{ monasca_tunings.monasca_api_java_opts }}{% endif %}"
monasca_api_conn_timeout: "{% if monasca_api_conn_timeout_override %}{{ monasca_api_conn_timeout_override }}{% else %}{{ monasca_tunings.monasca_api_conn_timeout }}{% endif %}"

# Persister Defaults
monasca_persister_java_opts: "{% if monasca_persister_java_opts_override %}{{ monasca_persister_java_opts_override }}{% else %}{{ monasca_tunings.monasca_persister_java_opts }}{% endif %}"
monasca_persister_alarm_threads: "{% if monasca_persister_alarm_threads_override %}{{ monasca_persister_alarm_threads_override }}{% else %}{{ monasca_tunings.monasca_persister_alarm_threads }}{% endif %}"
monasca_persister_alarm_batch_size: "{% if monasca_persister_alarm_batch_size_override %}{{ monasca_persister_alarm_batch_size_override }}{% else %}{{ monasca_tunings.monasca_persister_alarm_batch_size }}{% endif %}"
monasca_persister_metric_threads: "{% if monasca_persister_metric_threads_override %}{{ monasca_persister_metric_threads_override }}{% else %}{{ monasca_tunings.monasca_persister_metric_threads }}{% endif %}"
monasca_persister_metric_batch_size: "{% if monasca_persister_metric_batch_size_override %}{{ monasca_persister_metric_batch_size_override }}{% else %}{{ monasca_tunings.monasca_persister_metric_batch_size }}{% endif %}"

# Cassandra Defaults
cassandra_users:
  - username: "{% if database_type == 'cassandra' %}{{ MON_API.consumes_FND_CDB.vars.cassandra_monasca_api_user }}{% endif %}"
    password: "{% if database_type == 'cassandra' %}{{ MON_API.consumes_FND_CDB.vars.cassandra_monasca_api_password }}{% endif %}"
    role: monasca_api_role
  - username: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_user }}{% endif %}"
    password: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_password }}{% endif %}"
    role: monasca_persister_role
cassandra_api_user: "{% if database_type == 'cassandra' %}{{ MON_API.consumes_FND_CDB.vars.cassandra_monasca_api_user }}{% endif %}"
cassandra_api_password: "{% if database_type == 'cassandra' %}{{ MON_API.consumes_FND_CDB.vars.cassandra_monasca_api_password }}{% endif %}"
cassandra_persister_user: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_user }}{% endif %}"
cassandra_persister_password: "{% if database_type == 'cassandra' %}{{ MON_PST.consumes_FND_CDB.vars.cassandra_monasca_persister_password }}{% endif %}"
cassandra_version: 3.11.1

# Threshold Engine defaults
thresh_metric_spout_tasks: "{% if thresh_metric_spout_tasks_override %}{{ thresh_metric_spout_tasks_override }}{% else %}{{ monasca_tunings.thresh_metric_spouts }}{% endif %}"
thresh_metric_spout_threads: "{% if thresh_metric_spout_threads_override %}{{ thresh_metric_spout_threads_override }}{% else %}{{ monasca_tunings.thresh_metric_threads }}{% endif %}"

# Notification defaults
monasca_notification_alarm_processors: "{% if monasca_notification_alarm_processors_override %}{{ monasca_notification_alarm_processors_override }}{% else %}{{ monasca_tunings.monasca_notification_alarm_processors }}{% endif %}"
monasca_notification_notification_processors: "{% if monasca_notification_notification_processors_override %}{{ monasca_notification_notification_processors_override }}{% else %}{{ monasca_tunings.monasca_notification_notification_processors }}{% endif %}"
07070100000136000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/tasks07070100000137000081A40000000000000000000000015EBC1828000005E5000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/tasks/service_status.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
- include_vars: status.yml

- name: "{{ service_name }} | Check systemd service status"
  command: systemctl status {{ service_name }}
  register: status_result
  ignore_errors: yes
  changed_when: false
  until:
    # retry until active or inactive (dead), i.e. retry while service
    # is attempting to auto-restart or up to (retries * delay) seconds.
    - status_result | systemctl_active_or_dead
  retries: "{{ monasca_service_status_retry_count }}"
  delay: "{{ monasca_service_status_retry_delay }}"

- name: "{{ service_name }} | Report retries needed if > 0"
  debug:
    msg: |
      {{ service_name }} status check attempts {{ status_result.attempts }}.
  when:
    - status_result.attempts > 0

- name: "{{ service_name }} | Report systemd service failure"
  fail:
    msg: |
      {{ service_name }} is not running.
  when: status_result | failed
07070100000138000081A40000000000000000000000015EBC182800000481000000000000000000000000000000000000005700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/tasks/smoke_test.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: monasca-variables | smoke_test | Copy smoke_test.py
  template:
    src: smoke_test.py.j2
    dest: /opt/monasca/bin/smoke_test.py
    owner: root
    group: root
    mode: 0700
  become: yes

- name: monasca-variables | smoke_test | Run smoke_test.py
  command: /opt/monasca/bin/smoke_test.py
  register: smoke_test_result
  ignore_errors: yes
  changed_when: false

- name: monasca-variables | smoke_test | Report Failure
  fail:
    msg: |
      Smoke test failed
  when: smoke_test_result | failed
07070100000139000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/templates0707010000013A000081ED0000000000000000000000015EBC182800001146000000000000000000000000000000000000005D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/templates/smoke_test.py.j2#!/usr/bin/env python
#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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 datetime
import logging
from sys import exit, path, stdout
path.append('/opt/stack/service/monascaclient/venv/lib/python2.7/site-packages')
from monascaclient import client as mnclient

username = "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_user }}"
password = "{{ MON_API.consumes_KEY_API.vars.keystone_monasca_password }}"
auth_url = "{{ KEY_API.advertises.vips.private[0].url }}/v3"
monasca_url = "{{ MON_AGN.consumes_MON_API.vips.private[0].url }}/v2.0"
project_name = "{{ KEY_API.vars.keystone_admin_tenant }}"
metric_name = "cpu.idle_perc"
monasca_version = "2_0"
ks_kwargs = {'username': username,
             'password': password,
             'project_name': project_name,
             'auth_url': auth_url}
monasca_client = mnclient.Client(monasca_version, monasca_url, **ks_kwargs)

# console logger
logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
formatter = logging.Formatter("%(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)


def determine_hostname():
    with open("/etc/monasca/agent/agent.yaml") as fp:
        for line in fp:
            if 'hostname:' in line:
                hostname = line.split(':')[1].strip()
                return hostname
    return None


def test_measurement(hostname):
    hour_ago = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
    hour_ago_str = hour_ago.strftime('%Y-%m-%dT%H:%M:%S') + 'Z'
    try:
        dimensions = {'hostname': hostname}
        list_args = {}
        list_args['name'] = metric_name
        list_args['start_time'] = hour_ago_str
        list_args['dimensions'] = dimensions
        measurement_list = monasca_client.metrics.list_measurements(**list_args)
        if len(measurement_list) == 0:
            logger.error('test_measurement measurement-list failed for metric name: {} hostname: {} '
                         'start_time: {}'.format(metric_name, dimensions['hostname'], hour_ago_str))
            return False
    except Exception as e:
        logger.exception('test_measurement failed with Monascaclient Exception: {}'.format(e.message))
        return False
    return True


def test_metric(hostname):
    try:
        dimensions = {'hostname': hostname}
        list_args = {}
        list_args['name'] = metric_name
        list_args['dimensions'] = dimensions
        metric_list = monasca_client.metrics.list(**list_args)
        if len(metric_list) == 0:
            logger.error('test_metric metric-list failed for metric name: {} hostname: '
                         '{}'.format(metric_name, dimensions['hostname']))
            return False
    except Exception as e:
        logger.exception('test_metric failed with Monascaclient Exception: {}'.format(e.message))
        return False
    return True


def test_alarm(hostname):
    try:
        dimensions = {'hostname': hostname}
        list_args = {}
        list_args['metric_name'] = "host_alive_status"
        list_args['metric_dimensions'] = dimensions
        alarm_list = monasca_client.alarms.list(**list_args)
        if len(alarm_list) == 0:
            logger.error('test_alarm alarm-list failed for metric name: {} hostname: '
                         '{}'.format(list_args['metric_name'], dimensions['hostname']))
            return False
    except Exception as e:
        logger.exception('test_alarm failed with Monascaclient Exception: {}'.format(e.message))
        return False
    return True

hostname = determine_hostname()
if not hostname:
    logger.error('Did not determine hostname')
    exit(1)

if not test_metric(hostname):
    exit(1)
if not test_measurement(hostname):
    exit(1)
if not test_alarm(hostname):
    exit(1)
logger.info("OK")
exit(0)
0707010000013B000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004700000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/vars0707010000013C000081A40000000000000000000000015EBC182800001B29000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/vars/configuration.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
# count cassandra nodes
cassandra_node_count: "{{ groups['FND-CDB'] | length }}"

# Retention variables
kafka_low_disk_retention: 1800000 # 30 minutes in milliseconds

# The tuning selector is normally set by the amount of RAM in the system.
# Set this variable to override that tuning. Setting it to smaller values
# can adversely affect the operation of Monasca and the components of
# Ardana OpenStack that rely on it. Possible values are: demo, small, medium, large
# and extra_large. Only demo, small, medium and large will be chosen
# based on the amount of RAM. extra_large is only used if set by
# monasca_tuning_selector_override
monasca_tuning_selector_override:

# Must be influxdb or cassandra
database_type: "{{ 'cassandra' if ansible_os_family == 'Suse' else 'influxdb' }}"

# The number of seconds between metric collections for the Monasca Agent.
# Decreasing this will increase the amount of disk, CPU and RAM used by
# the Monasca components.
# Increasing this can cause issues for the Threshold Engine evaluating
# Alarms as most Alarm Definitions have a period of 60 seconds
monasca_agent_check_frequency: 30

# monasca api implementation language
monasca_api_implementation_lang: python

# Do not make changes to monasca_possible_tunings. Use the override
# parameters below in order to set individual parameters if required
monasca_possible_tunings:
    demo:
        kafka_log_retention_hours: 1 # 1 hour default retention
        kafka_heap_opts: "-Xmx128m"
        monasca_api_java_opts: "-Xmx128m"
        monasca_api_conn_timeout: 8000
        monasca_notification_alarm_processors: 1
        monasca_notification_notification_processors: 1
        monasca_persister_java_opts: "-Xmx64m"
        monasca_persister_alarm_threads: 1
        monasca_persister_alarm_batch_size: 100
        monasca_persister_metric_threads: 1
        monasca_persister_metric_batch_size: 500
        storm_nimbus_childopts: "-Xmx64m"
        storm_supervisor_childopts: "-Xmx64m"
        storm_ui_childopts: "-Xmx32m"
        storm_worker_childopts_heap: "-Xmx64m"
        storm_worker_ports: [6701]
        thresh_metric_spouts: 2
        thresh_metric_threads: 2
    small:
        kafka_log_retention_hours: 4 # 4 hour default retention
        kafka_heap_opts: "-Xmx512m"
        monasca_api_java_opts: "-Xmx256m"
        monasca_api_conn_timeout: 2000
        monasca_notification_alarm_processors: 1
        monasca_notification_notification_processors: 1
        monasca_persister_java_opts: "-Xmx128m"
        monasca_persister_alarm_threads: 1
        monasca_persister_alarm_batch_size: 200
        monasca_persister_metric_threads: 1
        monasca_persister_metric_batch_size: 500
        storm_nimbus_childopts: "-Xmx128m"
        storm_supervisor_childopts: "-Xmx128m"
        storm_ui_childopts: "-Xmx64m"
        storm_worker_childopts_heap: "-Xmx128m"
        storm_worker_ports: [6701]
        thresh_metric_spouts: 2
        thresh_metric_threads: 2
    medium:
        kafka_log_retention_hours: 4 # 4 hour default retention
        kafka_heap_opts: "-Xmx1G -Xms1G"
        monasca_api_java_opts: "-Xmx512m"
        monasca_api_conn_timeout: 2000
        monasca_notification_alarm_processors: 2
        monasca_notification_notification_processors: 2
        monasca_persister_java_opts: "-Xmx512m"
        monasca_persister_alarm_threads: 1
        monasca_persister_alarm_batch_size: 100
        monasca_persister_metric_threads: 2
        monasca_persister_metric_batch_size: 5000
        storm_nimbus_childopts: "-Xmx256m"
        storm_supervisor_childopts: "-Xmx256m"
        storm_ui_childopts: "-Xmx256m"
        storm_worker_childopts_heap: "-Xmx512m"
        storm_worker_ports: [6701, 6702]
        thresh_metric_spouts: 4
        thresh_metric_threads: 4
    large:
        kafka_log_retention_hours: 4 # 4 hour default retention
        kafka_heap_opts: "-Xmx2G -Xms2G"
        monasca_api_java_opts: "-Xmx1G"
        monasca_api_conn_timeout: 2000
        monasca_notification_alarm_processors: 2
        monasca_notification_notification_processors: 2
        monasca_persister_java_opts: "-Xmx1G"
        monasca_persister_alarm_threads: 2
        monasca_persister_alarm_batch_size: 100
        monasca_persister_metric_threads: 2
        monasca_persister_metric_batch_size: 10000
        thresh_metric_spouts: 8
        thresh_metric_threads: 8
        storm_nimbus_childopts: "-Xmx512m"
        storm_supervisor_childopts: "-Xmx512m"
        storm_ui_childopts: "-Xmx512m"
        storm_worker_childopts_heap: "-Xmx1280m"
        storm_worker_ports: [6701, 6702, 6703, 6704]
    extra-large:
        kafka_log_retention_hours: 4 # 4 hour default retention
        kafka_heap_opts: "-Xmx3G -Xms3G"
        monasca_api_java_opts: "-Xmx2G"
        monasca_api_conn_timeout: 2000
        monasca_notification_alarm_processors: 2
        monasca_notification_notification_processors: 2
        monasca_persister_java_opts: "-Xmx2G"
        monasca_persister_alarm_threads: 2
        monasca_persister_alarm_batch_size: 200
        monasca_persister_metric_threads: 2
        monasca_persister_metric_batch_size: 100000
        thresh_metric_spouts: 8
        thresh_metric_threads: 8
        storm_nimbus_childopts: "-Xmx512m"
        storm_supervisor_childopts: "-Xmx512m"
        storm_ui_childopts: "-Xmx512m"
        storm_worker_childopts_heap: "-Xmx1536m"
        storm_worker_ports: [6701, 6702, 6703, 6704]

# Kafka Overrides
kafka_heap_opts_override:
# Must be an integer greater than 0
kafka_log_retention_hours_override:

# API Overrides
monasca_api_java_opts_override:
monasca_api_conn_timeout_override:

# Persister Overrides
monasca_persister_java_opts_override:
monasca_persister_alarm_threads_override:
monasca_persister_alarm_batch_size_override:
monasca_persister_metric_threads_override:
monasca_persister_metric_batch_size_override:

# Threshold Engine Overrides
thresh_metric_spout_tasks_override:
thresh_metric_spout_threads_override:

# Notification Overrides
monasca_notification_alarm_processors_override:
monasca_notification_notification_processors_override:

# Storm Overrides
storm_nimbus_childopts_override:
storm_supervisor_childopts_override:
storm_ui_childopts_override:
storm_worker_childopts_override:
storm_worker_ports_override:
0707010000013D000081A40000000000000000000000015EBC1828000002EA000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/vars/debian.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
zookeeper_post_upgrade_cleanup:
  - openjdk-7-jre-headless

monasca_post_upgrade_cleanup:
  - openjdk-7-jre-headless

monasca_pre_upgrade_pkg_lock:
  - influxdb
0707010000013E000081A40000000000000000000000015EBC1828000002B8000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/vars/status.yml#
# (c) Copyright 2020 SUSE LLC
#
# 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.
#
---

# Service status check retry settings
monasca_service_status_retry_count: 60
monasca_service_status_retry_delay: 2
0707010000013F000081A40000000000000000000000015EBC1828000002F5000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/monasca-variables/vars/suse.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
zookeeper_post_upgrade_cleanup:
  - java-1_7_0-openjdk-headless

monasca_post_upgrade_cleanup:
  - java-1_7_0-openjdk-headless

monasca_pre_upgrade_pkg_lock:
  - influxdb

07070100000140000041ED0000000000000000000000085EBC182800000000000000000000000000000000000000000000003600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm07070100000141000081A40000000000000000000000015EBC182800000435000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/README.md#Storm
Installs [Apache Storm](http://storm.incubator.apache.org/)

##Requirements
By default neither ui or logviewer will be enabled, set one or both of these variables to enable.
- storm_ui_enabled: true
- storm_logviewer_enabled: true

If `storm_ui_enabled` is set to True the UI is installed on the same box as nimbus. Typically there is a single nimbus server and multiple supervisors. Storm-logviewer is installed on the same box as the supervisors.

The variable are required for proper setup
- zookeeper_hosts - comma separated list of hosts, any specified port is ignored 2181 is used.

## Optional
- monasca_log_level - Log level to be used for storm logs. Defaults to WARN
- storm_wait_for_period - The time in seconds for how long to wait for the nimbus port and the ui port to be available after starting them. Default is 60 seconds.
- run_mode: One of Deploy, Stop, Install, Configure or Start. The default is Deploy which will do Install, Configure, then Start.

##License
Apache

##Author Information
Tim Kuhlman

Monasca Team email monasca@lists.launchpad.net
07070100000142000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/defaults07070100000143000081A40000000000000000000000015EBC182800000951000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/defaults/main.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
nimbus_thrift_port: 6627
storm_drpc_extra_config:
storm_local_dir: "/var/lib/storm/"
storm_java_library_path: "/usr/lib64:/usr/lib"
storm_zookeeper_port: 2181
storm_topology_extra_config:
    topology.acker.executors: 1
    topology.debug: false
storm_transactional_extra_config:
    transactional.zookeeper.port: "{{ storm_zookeeper_port }}"
    transactional.zookeeper.root: "/storm-transactional"
storm_logviewer_enabled: false  # logviewer is used by the UI
storm_ui_enabled: false
storm_ui_port: 8088
storm_version: 1.0.1
storm_shell: /usr/sbin/nologin
storm_zookeeper_extra_config:
    storm.zookeeper.port:  "{{ storm_zookeeper_port }}"
    storm.zookeeper.retry.interval: 5000
    storm.zookeeper.retry.times: 60
    storm.zookeeper.root: "/storm"
    storm.zookeeper.session.timeout: 3000
storm_tarball_name: apache-storm-{{storm_version}}.tar.gz

monasca_log_level: WARN
# In MB
storm_log_max_size: 50
storm_access_log_max_size: 2
storm_metrics_log_max_size: 2
monasca_log_rotation_backup_count: 4
storm_wait_for_period: 120
run_mode: Deploy
skip_install: False

storm_tarball_location: "{{ monasca_jars_virtualenv_dir }}/lib"

zookeeper_nodes: "{{ MON_THR.consumes_FND_ZOO.members.private }}"
zookeeper_hosts: "{{ zookeeper_nodes | map(attribute='host') | join(',') }}"

thresh_nodes: "{{ MON_THR.members.admin }}"
thresh_hosts: "{{ thresh_nodes | map(attribute='host') | join(',') }}"
storm_local_host: >
  {{ (thresh_nodes |
      selectattr('ardana_ansible_host','equalto', inventory_hostname) |
      first).host }}

stop_old_thresh: False

#
# storm extlib directory
#
storm_ext_lib_dir: "/usr/lib64/storm/extlib"

#
# mysql jdbc driver
#
mysql_jdbc_dir: "/usr/share/java"
mysql_jdbc_jar: "mysql-connector-java.jar"
07070100000144000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/files07070100000145000081A40000000000000000000000015EBC1828000000FE000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/files/storm-logviewer.conf# Startup script for Storm Logviewer

description "Storm Logviewer daemon"
start on runlevel [2345]

console log
respawn

kill timeout 240
respawn limit 25 5

setgid storm
setuid storm
chdir /opt/storm/current
exec /opt/storm/current/bin/storm logviewer
07070100000146000081A40000000000000000000000015EBC1828000000F5000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/files/storm-nimbus.conf# Startup script for Storm Nimbus

description "Storm Nimbus daemon"
start on runlevel [2345]

console log
respawn

kill timeout 240
respawn limit 25 5

setgid storm
setuid storm
chdir /opt/storm/current
exec /opt/storm/current/bin/storm nimbus
07070100000147000081A40000000000000000000000015EBC182800000101000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/files/storm-supervisor.conf# Startup script for Storm Supervisor

description "Storm Supervisor daemon"
start on runlevel [2345]

console log
respawn

kill timeout 240
respawn limit 25 5

setgid storm
setuid storm
chdir /opt/storm/current
exec /opt/storm/current/bin/storm supervisor
07070100000148000081A40000000000000000000000015EBC1828000000E9000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/files/storm-ui.conf# Startup script for Storm UI

description "Storm UI daemon"
start on runlevel [2345]

console log
respawn

kill timeout 240
respawn limit 25 5

setgid storm
setuid storm
chdir /opt/storm/current
exec /opt/storm/current/bin/storm ui
07070100000149000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/meta0707010000014A000081A40000000000000000000000015EBC1828000003AC000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs Apache Storm
  company: SUSE
  license: Apache
  min_ansible_version: 1.7
  platforms:
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - clustering
  - system
dependencies: []
0707010000014B000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks0707010000014C000081A40000000000000000000000015EBC1828000003B7000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Storm | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in Kafka package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: monasca_storm_restart_packages
  register: ardana_notify_storm_restart_required
0707010000014D000081A40000000000000000000000015EBC18280000030C000000000000000000000000000000000000005200000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: storm | _schedule_restart | Schedule a restart for all services
  debug:
    msg: "Trigger a change notification in storm"
  changed_when: true
  register: ardana_notify_storm_restart_required0707010000014E000081A40000000000000000000000015EBC182800000688000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/configure.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Detect if this is a systemd based system
  command: cat /proc/1/comm
  register: init

- set_fact: use_systemd=True
  when: init.stdout == 'systemd'

- set_fact: use_systemd=False
  when: init.stdout != 'systemd'

- name: Create Storm log4j2 conf directory (rpm)
  file:
    path: "{{ storm_log4j2_dir }}"
    state: directory
    owner: root
    group: "{{ storm_group }}"
    mode: 0755

- name: Configure cluster.xml for setting log level
  template:
    dest: "{{ storm_log4j2_dir }}/cluster.xml"
    owner: "{{storm_user}}"
    group: "{{storm_group}}"
    mode: 0644
    src: cluster.xml.j2
  register: ardana_notify_storm_restart_required

- name: Configure worker.xml for setting log level
  template:
    dest: "{{ storm_log4j2_dir }}/worker.xml"
    owner: "{{storm_user}}"
    group: "{{storm_group}}"
    mode: 0644
    src: worker.xml.j2
  register: ardana_notify_storm_restart_required

- include: configure_nimbus.yml tags=storm_nimbus

- include: configure_supervisor.yml tags=storm_supervisor
0707010000014F000081A40000000000000000000000015EBC18280000073A000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/configure_nimbus.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Configure storm.yaml
  template:
    dest: "{{ storm_conf_file }}"
    owner: root
    group: "{{ storm_group }}"
    mode: 0644
    src: storm.yaml.j2
  register: ardana_notify_storm_restart_required

- name: Setup Storm nimbus upstart script
  copy: dest={{nimbus_upstart_conf}} owner=root group=root mode=0644 src=storm-nimbus.conf
  when: not use_systemd
  register: ardana_notify_storm_restart_required

- name: Setup Storm nimbus systemd script
  template:
    dest: "{{ nimbus_systemd_service }}"
    owner: root
    group: root
    mode: 0644
    src: storm-nimbus.service.j2
  when: use_systemd
  register: ardana_notify_storm_restart_required

- name: Setup Storm UI upstart script
  copy: dest={{stormui_upstart_conf}} owner=root group=root mode=0644 src=storm-ui.conf
  when: storm_ui_enabled and not use_systemd
  register: ardana_notify_storm_restart_required

- name: Setup Storm UI systemd script
  template:
    dest: "{{ stormui_systemd_service }}"
    owner: root
    group: root
    mode: 0644
    src: storm-ui.service.j2
  when: storm_ui_enabled and use_systemd
  register: ardana_notify_storm_restart_required

- command: systemctl daemon-reload
  when: use_systemd
07070100000150000081A40000000000000000000000015EBC182800000780000000000000000000000000000000000000005500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/configure_supervisor.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: Configure storm.yaml
  template:
    dest: "{{ storm_conf_file }}"
    owner: root
    group: "{{ storm_group }}"
    mode: 0644
    src: storm.yaml.j2
  register: ardana_notify_storm_restart_required

- name: Setup Storm supervisor upstart script
  copy: dest={{supervisor_upstart_conf}} owner=root group=root mode=0644 src=storm-supervisor.conf
  when: not use_systemd
  register: ardana_notify_storm_restart_required

- name: Setup Storm supervisor systemd script
  template:
    dest: "{{ supervisor_systemd_service }}"
    owner: root
    group: root
    mode: 0644
    src: storm-supervisor.service.j2
  when: use_systemd
  register: ardana_notify_storm_restart_required

- name: Setup Storm Logviewer upstart script
  copy: dest={{logviewer_upstart_conf}} owner=root group=root mode=0644 src=storm-logviewer.conf
  when: storm_logviewer_enabled and not use_systemd
  register: ardana_notify_storm_restart_required

- name: Setup Storm Logviewer systemd script
  template:
    dest: "{{ logviewer_systemd_service }}"
    owner: root
    group: root
    mode: 0644
    src: storm-logviewer.service.j2
  when: storm_logviewer_enabled and use_systemd
  register: ardana_notify_storm_restart_required

- command: systemctl daemon-reload
  when: use_systemd
07070100000151000081A40000000000000000000000015EBC1828000004C1000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/install.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: storm | install | Install storm from rpm
  package:
    name: "{{ item }}"
    state: present
  with_items:
    - storm
    - storm-nimbus
    - storm-supervisor

- name: storm | install | Install the mysql jdbc driver from repo
  become: yes
  zypper:
    name: "{{ item }}"
    state: present
  with_items:
    - "mysql-connector-java"

- name: storm | install | create symlink to mysql connector jdbc jar
  become: yes
  file:
    src: "{{ mysql_jdbc_dir }}/{{ mysql_jdbc_jar }}"
    dest: "{{ storm_ext_lib_dir }}/{{ mysql_jdbc_jar }}"
    state: link
07070100000152000081A40000000000000000000000015EBC1828000004A2000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: storm | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

- include: stop.yml
  when: run_mode == 'Stop'

- include: _check_upgraded_pkgs.yml
  when: run_mode == 'Upgrade'

- include: install.yml
  when: not skip_install and ( run_mode in ['Install','Deploy','Upgrade'] )

- include: configure.yml
  when: run_mode in ['Configure','Deploy','Upgrade']

- include: upgrade.yml
  when: run_mode == 'Upgrade'

- include: start.yml
  when: run_mode in ['Configure','Start','Deploy','Upgrade']
07070100000153000081A40000000000000000000000015EBC182800000C09000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: start | Restart all storm services
  set_fact:
    ardana_notify_storm_nimbus_restart_required: "{{ ardana_notify_storm_restart_required }}"
    ardana_notify_storm_supervisor_restart_required: "{{ ardana_notify_storm_restart_required }}"
    ardana_notify_storm_logviewer_restart_required: "{{ ardana_notify_storm_restart_required }}"
    ardana_notify_storm_ui_restart_required: "{{ ardana_notify_storm_restart_required }}"
  when: ardana_notify_storm_restart_required is defined and
        ardana_notify_storm_restart_required.changed

- name: start | Mark ardana notify storm variable for deletion if defined
  debug: msg="Marking ardana notify storm variable for deletion"
  when: ardana_notify_storm_restart_required is defined and
        ardana_notify_storm_restart_required.changed

- name: start | Restart Nimbus
  service: name=storm-nimbus state=restarted enabled=yes
  when: ardana_notify_storm_nimbus_restart_required is defined and
        ardana_notify_storm_nimbus_restart_required.changed

- name: start | Start Nimbus
  service: name=storm-nimbus state=started enabled=yes

- name: start | wait for nimbus port
  wait_for: port={{nimbus_thrift_port}} state=started timeout={{ storm_wait_for_period }}

- name: start | Restart Supervisor
  service: name=storm-supervisor state=restarted enabled=yes
  when: ardana_notify_storm_supervisor_restart_required is defined and
        ardana_notify_storm_supervisor_restart_required.changed

- name: start | Start Supervisor
  service: name=storm-supervisor state=started enabled=yes

- name: start | Restart Logviewer
  service: name=storm-logviewer state=restarted enabled=yes
  when: storm_logviewer_enabled | bool and
        ardana_notify_storm_logviewer_restart_required is defined and
        ardana_notify_storm_logviewer_restart_required.changed

- name: start | Start Logviewer
  service: name=storm-logviewer state=started enabled=yes
  when: storm_logviewer_enabled | bool

- name: Restart UI
  service: name=storm-ui state=restarted enabled=yes
  when: storm_ui_enabled | bool and
        ardana_notify_storm_ui_restart_required is defined and
        ardana_notify_storm_ui_restart_required.changed

- name: start | Start UI
  service: name=storm-ui state=started enabled=yes
  when: storm_ui_enabled | bool

- name: wait for ui port
  wait_for: port={{storm_ui_port}} state=started timeout={{ storm_wait_for_period }}
  when: storm_ui_enabled | bool
07070100000154000081A40000000000000000000000015EBC1828000003FC000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/stop.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop Nimbus
  service: name=storm-nimbus state=stopped enabled=yes

- name: Stop Storm UI
  service: name=storm-ui state=stopped enabled=yes
  when: storm_ui_enabled

- name: Stop Supervisor
  service: name=storm-supervisor state=stopped enabled=yes

- name: Stop Logviewer
  service: name=storm-logviewer state=stopped enabled=yes
  when: storm_logviewer_enabled
07070100000155000081A40000000000000000000000015EBC182800000696000000000000000000000000000000000000005000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/stop_on_upgrade.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: storm | stop_on_upgrade | Stop Thresh on upgrade
  service: name=monasca-thresh state=stopped enabled=yes
  when: thresh_start_enabled | bool

- name: storm | stop_on_upgrade | Stop Storm UI on upgrade
  service: name=storm-ui state=stopped enabled=yes
  when: storm_ui_enabled | bool

- name: storm | stop_on_upgrade | Stop Logviewer on upgrade
  service: name=storm-logviewer state=stopped enabled=yes
  when: storm_logviewer_enabled | bool

- name: storm | stop_on_upgrade | Stop Supervisor on upgrade
  service: name=storm-supervisor state=stopped enabled=yes

- name: storm | stop_on_upgrade | Stop Nimbus on upgrade
  service: name=storm-nimbus state=stopped enabled=yes

- name: storm | stop_on_upgrade | Clean Storm Supervisor Data
  file: path="{{ storm_local_dir }}/supervisor" state=absent

- name: storm | stop_on_upgrade | Clean Storm Workers Data
  file: path="{{ storm_local_dir }}/workers" state=absent

- name: storm | stop_on_upgrade | Clean Storm Nimbus Data
  file: path="{{ storm_local_dir }}/nimbus" state=absent
07070100000156000081A40000000000000000000000015EBC1828000002F6000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/tasks/upgrade.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Remove old storm directories
  file:
    path: "{{ storm_root_dir }}/apache-storm-0.9.5"
    state: absent
07070100000157000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates07070100000158000081A40000000000000000000000015EBC182800000DFE000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/cluster.xml.j2<?xml version="1.0" encoding="UTF-8"?>
<!--
 (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 (c) Copyright 2017 SUSE LLC

 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You 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.
-->

<configuration monitorInterval="60">
<properties>
    <property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} %c{1.} [%p] %msg%n</property>
</properties>
<appenders>
    <RollingFile name="A1" immediateFlush="false"
                 fileName="${sys:storm.log.dir}/${sys:logfile.name}"
                 filePattern="${sys:storm.log.dir}/${sys:logfile.name}.%i.gz">
        <PatternLayout>
            <pattern>${pattern}</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <RollingFile name="WEB-ACCESS" immediateFlush="false"
                 fileName="${sys:storm.log.dir}/access-web-${sys:daemon.name}.log"
                 filePattern="${sys:storm.log.dir}/access-web-${sys:daemon.name}.log.%i.gz">
        <PatternLayout>
            <pattern>${pattern}</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_access_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <RollingFile name="THRIFT-ACCESS" immediateFlush="false"
                 fileName="${sys:storm.log.dir}/access-${sys:logfile.name}"
                 filePattern="${sys:storm.log.dir}/access-${sys:logfile.name}.%i.gz">
    <PatternLayout>
        <pattern>${pattern}</pattern>
    </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <Syslog name="syslog" format="RFC5424" charset="UTF-8" host="localhost" port="514"
            protocol="UDP" appName="[${sys:daemon.name}]" mdcId="mdc" includeMDC="true"
            facility="LOCAL5" enterpriseNumber="18060" newLine="true" exceptionPattern="%rEx{full}"
            messageId="[${sys:user.name}:S0]" id="storm" immediateFlush="true" immediateFail="true"/>
</appenders>
<loggers>

    <Logger name="org.apache.storm.logging.filters.AccessLoggingFilter" level="WARN" additivity="false">
        <AppenderRef ref="WEB-ACCESS"/>
        <AppenderRef ref="syslog"/>
    </Logger>
    <Logger name="org.apache.storm.logging.ThriftAccessLogger" level="WARN" additivity="false">
        <AppenderRef ref="THRIFT-ACCESS"/>
        <AppenderRef ref="syslog"/>
    </Logger>
    <root level="{{ monasca_log_level }}">
        <appender-ref ref="A1"/>
        <appender-ref ref="syslog"/>
    </root>
</loggers>
</configuration>
07070100000159000081A40000000000000000000000015EBC1828000003A1000000000000000000000000000000000000005B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/storm-logviewer.service.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Storm Logviewer daemon
After=storm-nimbus.service zookeeper.service

[Service]
Type=simple
User=storm
Group=storm
Restart=on-failure
WorkingDirectory={{ storm_working_dir }}
ExecStart={{ storm_executable }} logviewer

[Install]
WantedBy=multi-user.target
0707010000015A000081A40000000000000000000000015EBC182800000386000000000000000000000000000000000000005800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/storm-nimbus.service.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Storm Nimbus daemon
After=zookeeper.service

[Service]
Type=simple
User=storm
Group=storm
Restart=on-failure
WorkingDirectory={{ storm_working_dir }}
ExecStart={{ storm_executable }} nimbus

[Install]
WantedBy=multi-user.target
0707010000015B000081A40000000000000000000000015EBC1828000003A3000000000000000000000000000000000000005C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/storm-supervisor.service.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Storm Supervisor daemon
After=storm-nimbus.service zookeeper.service

[Service]
Type=simple
User=storm
Group=storm
Restart=on-failure
WorkingDirectory={{ storm_working_dir }}
ExecStart={{ storm_executable }} supervisor

[Install]
WantedBy=multi-user.target
0707010000015C000081A40000000000000000000000015EBC182800000381000000000000000000000000000000000000005400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/storm-ui.service.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
[Unit]
Description=Storm UI daemon
After=storm-nimbus.service

[Service]
Type=simple
User=storm
Group=storm
Restart=on-failure
WorkingDirectory={{ storm_working_dir }}
ExecStart={{ storm_executable }} ui

[Install]
WantedBy=multi-user.target
0707010000015D000081A40000000000000000000000015EBC182800000B4F000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/storm.yaml.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
#}
### base
java.library.path: "{{ storm_java_library_path }}"
storm.local.dir: "{{ storm_local_dir }}"

storm.log4j2.conf.dir: "{{ storm_log4j2_dir }}"

storm.local.hostname: "{{ storm_local_host }}"
nimbus.seeds: [{{ thresh_hosts }}]

### zookeeper.*
storm.zookeeper.servers:
{% for host in zookeeper_hosts.split(',') %}
    - "{{ host }}"
{% endfor %}
{% if storm_zookeeper_extra_config.items is defined %}
{% for key, value in storm_zookeeper_extra_config|dictsort %}
{{ key }}: {{ value}}
{% endfor %}
{% endif %}

### supervisor.* configs are for node supervisors
supervisor.slots.ports:
{% for port in storm_worker_ports %}
    - {{ port }}
{% endfor %}
{% if storm_supervisor_extra_config.items is defined %}
{% for key, value in storm_supervisor_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}

### worker.* configs are for task workers
{% if storm_worker_extra_config.items is defined %}
{% for key, value in storm_worker_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}
storm.workers.artifacts.dir: {{ storm_local_dir }}/workers-artifacts

nimbus.thrift.port: {{ nimbus_thrift_port }}
{% if storm_nimbus_extra_config.items is defined %}
{% for key, value in storm_nimbus_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}

### ui.* configs are for the master
ui.port: {{ storm_ui_port }}
{% if storm_ui_extra_config.items is defined %}
{% for key, value in storm_ui_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}

### drpc.* configs
{% if storm_drpc_extra_config.items is defined %}
{% for key, value in storm_drpc_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}

### transactional.* configs
transactional.zookeeper.servers:
{% for host in zookeeper_hosts.split(',') %}
    - "{{ host.split(':')[0] }}"
{% endfor %}
{% if storm_transactional_extra_config.items is defined %}
{% for key, value in storm_transactional_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}

### topology.* configs are for specific executing storms
{% if storm_topology_extra_config.items is defined %}
{% for key, value in storm_topology_extra_config|dictsort %}
{{ key }}: {{ value }}
{% endfor %}
{% endif %}
0707010000015E000081A40000000000000000000000015EBC182800001053000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/templates/worker.xml.j2<?xml version="1.0" encoding="UTF-8"?>
<!--
(c) Copyright 2016 Hewlett Packard Enterprise Development LP
(c) Copyright 2017 SUSE LLC

 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You 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.
-->

<configuration monitorInterval="60">
<properties>
    <property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} %c{1.} [%p] %msg%n</property>
    <property name="patternNoTime">%msg%n</property>
    <property name="patternMetrics">%d %-8r %m%n</property>
</properties>
<appenders>
    <RollingFile name="A1"
		fileName="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}"
		filePattern="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.%i.gz">
        <PatternLayout>
            <pattern>${pattern}</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <RollingFile name="STDOUT"
		fileName="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.out"
		filePattern="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.out.%i.gz">
        <PatternLayout>
            <pattern>${patternNoTime}</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <RollingFile name="STDERR"
		fileName="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.err"
		filePattern="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.err.%i.gz">
        <PatternLayout>
            <pattern>${patternNoTime}</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <RollingFile name="METRICS"
		fileName="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.metrics"
		filePattern="${sys:storm.log.dir}/${sys:worker.port}/${sys:logfile.name}.metrics.%i.gz">
        <PatternLayout>
            <pattern>${patternMetrics}</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="{{ storm_metrics_log_max_size }} MB"/>
        </Policies>
        <DefaultRolloverStrategy max="{{ monasca_log_rotation_backup_count }}"/>
    </RollingFile>
    <Syslog name="syslog" format="RFC5424" charset="UTF-8" host="localhost" port="514"
        protocol="UDP" appName="[${sys:storm.id}:${sys:worker.port}]" mdcId="mdc" includeMDC="true"
        facility="LOCAL5" enterpriseNumber="18060" newLine="true" exceptionPattern="%rEx{full}"
        messageId="[${sys:user.name}:${sys:logging.sensitivity}]" id="storm" immediateFail="true" immediateFlush="true"/>
</appenders>
<loggers>
    <root level="WARN">
        <appender-ref ref="A1"/>
        <appender-ref ref="syslog"/>
    </root>
    <Logger name="org.apache.storm.metric.LoggingMetricsConsumer" level="WARN" additivity="false">
        <appender-ref ref="METRICS"/>
    </Logger>
    <Logger name="STDERR" level="WARN">
        <appender-ref ref="STDERR"/>
        <appender-ref ref="syslog"/>
    </Logger>
    <Logger name="STDOUT" level="WARN">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="syslog"/>
    </Logger>
</loggers>
</configuration>
0707010000015F000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003B00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/vars07070100000160000081A40000000000000000000000015EBC1828000002BA000000000000000000000000000000000000004600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/vars/debian.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_storm_package_dependencies:
  - default-jre-headless

monasca_storm_restart_packages:
  - default-jre-headless07070100000161000081A40000000000000000000000015EBC18280000058D000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/vars/main.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
nimbus_systemd_service: /etc/systemd/system/storm-nimbus.service
nimbus_upstart_conf: /etc/init/storm-nimbus.conf
storm_root_dir: /opt/storm
storm_install_dir: "{{ storm_root_dir }}/apache-storm-{{ storm_version }}"
storm_log4j2_dir: "/etc/storm/log4j/"
storm_working_dir: "/var/lib/storm"
storm_executable: "/usr/bin/storm"
storm_conf_file: "/etc/storm/storm.yaml"

storm_group: storm
stormui_systemd_service: /etc/systemd/system/storm-ui.service
stormui_upstart_conf: /etc/init/storm-ui.conf
supervisor_systemd_service: /etc/systemd/system/storm-supervisor.service
supervisor_upstart_conf: /etc/init/storm-supervisor.conf
logviewer_systemd_service: /etc/systemd/system/storm-logviewer.service
logviewer_upstart_conf: /etc/init/storm-logviewer.conf
storm_user: storm
07070100000162000081A40000000000000000000000015EBC18280000041E000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/vars/nodes.yml#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
thresh_host_list: "{{ MON_THR.members.admin | sort(attribute='member_id') }}"
thresh_node_count: "{{ groups['MON-THR'] | length }}"
storm_nimbus_enabled: "{% if host.vars.member_id | int == thresh_host_list[0].member_id %}True{% else %}False{% endif %}"
storm_supervisor_enabled: "{% if thresh_node_count | int == 1 or host.vars.member_id != thresh_host_list[0].member_id %}True{% else %}False{% endif %}"
07070100000163000081A40000000000000000000000015EBC1828000002C9000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/storm/vars/suse.yml#
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
monasca_storm_package_dependencies:
  - java-1_8_0-openjdk-headless

monasca_storm_restart_packages:
  - java-1_8_0-openjdk-headless
07070100000164000041ED0000000000000000000000075EBC182800000000000000000000000000000000000000000000003A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper07070100000165000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/defaults07070100000166000081A40000000000000000000000015EBC18280000082A000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/defaults/main.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
run_mode: Deploy
# Select default tunings based on system RAM
# RAM < 32GB, use demo
# RAM < 64GB, use small
# RAM < 128GB, use medium
# RAM >= 128GB, use large
zookeeper_ram_tuning_selector: "{% if ansible_memtotal_mb < 31000 %}demo{% elif ansible_memtotal_mb < 63000 %}small{% elif ansible_memtotal_mb < 127000 %}medium{% else %}large{%endif %}"

# tuning_selector has precedence in order to be compatible with earlier versions
tuning_selector:
zookeeper_tuning_selector: "{% if tuning_selector %}{{ tuning_selector }}{% elif zookeeper_tuning_selector_override %}{{ zookeeper_tuning_selector_override }}{% else %}{{ zookeeper_ram_tuning_selector }}{% endif %}"
zookeeper_tunings: "{{ zookeeper_possible_tunings[zookeeper_tuning_selector] }}"
zookeeper_client_port: "{{ FND_ZOO.members.private[0].port }}"
zookeeper_nodes: "{{ FND_ZOO.members.private }}"
zookeeper_hosts: "{% for node in zookeeper_nodes | sort(attribute='member_id') %}{{ node.host }}:{{ node.port }}{% if not loop.last %},{% endif %}{% endfor %}"
zookeeper_id: "{{ host.vars.member_id | int - 1 }}"
zookeeper_heap_opt: "{% if zookeeper_heap_opt_override %}{{ zookeeper_heap_opt_override }}{% else %}{{ zookeeper_tunings.zookeeper_heap_opts }}{% endif %}"
zookeeper_maxClientCnxns: "{% if zookeeper_maxClientCnxns_override %}{{ zookeeper_maxClientCnxns_override }}{% else %}{{ zookeeper_tunings.zookeeper_maxClientCnxns }}{% endif %}"
zookeeper_data_dir: /var/lib/zookeeper
07070100000167000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/meta07070100000168000081A40000000000000000000000015EBC182800000463000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/meta/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
galaxy_info:
  author: Ardana Developers
  description: Installs zookeeper
  company: SUSE
  license: Apache
  min_ansible_version: 1.2
  platforms:
  - name: Ubuntu
    versions:
    - trusty
  - name: Debian
    versions:
    - jessie
  categories:
  - clustering
dependencies: []
  # List your role dependencies here, one per line. Only
  # dependencies available via galaxy should be listed here.
  # Be sure to remove the '[]' above if you add dependencies
  # to this list.
07070100000169000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks0707010000016A000081A40000000000000000000000015EBC1828000003C2000000000000000000000000000000000000005900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/_check_upgraded_pkgs.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Zookeeper | _check_upgraded_pkgs | Check upgraded packages
  debug:
    msg: "Notify change in Zookeeper package dependency: {{ item }}"
  changed_when: true
  when: item in ardana_upgraded_pkgs | default({})
  with_items: monasca_zookeeper_restart_packages
  register: ardana_notify_zookeeper_restart_required
0707010000016B000081A40000000000000000000000015EBC182800000315000000000000000000000000000000000000005600000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/_schedule_restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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: zookeeper | _schedule_restart | Schedule a restart for zookeeper
  debug:
    msg: "Trigger a change notification in zookeeper"
  changed_when: true
  register: ardana_notify_zookeeper_restart_required0707010000016C000081A40000000000000000000000015EBC182800000813000000000000000000000000000000000000004E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/configure.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: zookeeper | configure | Find jars installed by zookeeper rpm
  shell: "ls {{ zookeeper_java_share_dir }}/*.jar"
  become: yes
  register: zookeeper_jars_list_result
  when: ansible_os_family | lower == 'suse'

- name: zookeeper | configure | Add jars to zookeeper classpath
  set_fact:
    zookeeper_java_share_classpath: "{{ zookeeper_jars_list_result.stdout_lines | join(':') }}"
  when: ansible_os_family | lower == 'suse'

- name: zookeeper | configure | Setup zoo.cfg
  template: dest="{{ zookeeper_conf_dir }}/zoo.cfg" src=zoo.cfg.j2
  register: ardana_notify_zookeeper_restart_required

- name: zookeeper | configure | Setup myid
  template: dest="{{ zookeeper_myid_dir }}/myid" src=myid.j2
  register: ardana_notify_zookeeper_restart_required

- name: zookeeper | configure | Setup environment
  template: dest="{{ zookeeper_conf_dir }}/{{ zookeeper_env_file }}" src=environment.j2
  register: ardana_notify_zookeeper_restart_required

- name: zookeeper | configure | Create log_dir
  file:
    path: "{{ zookeeper_log_dir }}"
    state: directory
    owner: zookeeper
    group: zookeeper
    mode: 0755
  register: ardana_notify_zookeeper_restart_required

- name: zookeeper | configure | Setup log4j
  template:
    dest: "{{ zookeeper_conf_dir }}/log4j.properties"
    owner: root
    group: root
    mode: 0644
    src: log4j.properties.j2
  register: ardana_notify_zookeeper_restart_required
0707010000016D000081A40000000000000000000000015EBC18280000033B000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/install.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
# 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: zookeeper | install | Install OS specific required packages
  package:
    name: "{{ item }}"
    state: present
  with_items: monasca_zookeeper_package_dependencies
0707010000016E000081A40000000000000000000000015EBC18280000050E000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/main.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: zookeeper | main | include OS specific variables
  include_vars: "{{ ansible_os_family | lower }}.yml"

- name: zookeeper | main | Include configuration yml file
  include_vars: configuration.yml

- include: stop.yml
  when: run_mode == 'Stop'

- include: install.yml
  when: run_mode == 'Install' or run_mode == 'Deploy'

- include: _check_upgraded_pkgs.yml
  when: run_mode == 'Upgrade'

- include: configure.yml
  when: run_mode == 'Configure' or run_mode == 'Deploy' or
        run_mode == 'Upgrade'

- include: start.yml
  when: run_mode == 'Configure' or run_mode == 'Start' or
        run_mode == 'Deploy' or run_mode == 'Upgrade'
0707010000016F000081A40000000000000000000000015EBC182800000481000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: zookeeper | start | Restart zookeeper service
  service: name=zookeeper state=restarted enabled=yes
  when: ardana_notify_zookeeper_restart_required is defined and
        ardana_notify_zookeeper_restart_required.changed

- name: zookeeper | start | Start zookeeper service
  service: name=zookeeper state=started enabled=yes

- name: zookeeper | start | Wait for zookeeper port
  wait_for:
    port: "{{ zookeeper_client_port }}"
    state: started
    timeout: "{{ zookeeper_wait_for_period }}"
07070100000170000081A40000000000000000000000015EBC1828000002E7000000000000000000000000000000000000004900000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/tasks/stop.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: zookeeper | stop | Stops the zookeeper service
  service: name=zookeeper state=stopped
07070100000171000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/templates07070100000172000081A40000000000000000000000015EBC182800000366000000000000000000000000000000000000005300000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/templates/environment.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017-2018 SUSE LLC
#
#}
# Modified from http://packages.ubuntu.com/saucy/zookeeperd
NAME=zookeeper
ZOOCFGDIR={{ zookeeper_conf_dir }}

# seems, that log4j requires the log4j.properties file to be in the classpath
CLASSPATH="$ZOOCFGDIR:{{ zookeeper_java_share_classpath }}"

ZOOCFG="$ZOOCFGDIR/zoo.cfg"
ZOO_LOG_DIR={{ zookeeper_log_dir }}
USER=$NAME
GROUP=$NAME
PIDDIR=/var/run/$NAME
PIDFILE=$PIDDIR/$NAME.pid
{% if zookeeper_script_name is defined %}
SCRIPTNAME={{ zookeeper_script_name }}
{% endif %}
JAVA=/usr/bin/java
ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain"
ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
JMXLOCALONLY=false
{% if zookeeper_heap_opt is defined %}
{{ zookeeper_java_opts_key }}="{{ zookeeper_heap_opt }}"
{% else %}
{{ zookeeper_java_opts_key }}=""
{% endif %}
07070100000173000081A40000000000000000000000015EBC182800000686000000000000000000000000000000000000005800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/templates/log4j.properties.j2{#
#
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
#}
# From http://packages.ubuntu.com/saucy/zookeeperd

# ZooKeeper Logging Configuration
#

# Format is "<default threshold> (, <appender>)+

log4j.rootLogger=${zookeeper.root.logger}

# Example: console appender only
# log4j.rootLogger=INFO, CONSOLE

# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE

# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE

#
# Add ROLLINGFILE to rootLogger to get log file output
#    Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold={{ zookeeper_log_level }}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/zookeeper.log

# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize={{ zookeeper_log_max_size }}MB
log4j.appender.ROLLINGFILE.MaxBackupIndex={{ zookeeper_log_rotation_backup_count }}

log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n


#
# Add TRACEFILE to rootLogger to get log file output
#    Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.log.dir}/zookeeper_trace.log

log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n
07070100000174000081A40000000000000000000000015EBC1828000003BA000000000000000000000000000000000000004C00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/templates/myid.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
#}
{%- if zookeeper_id is defined -%}
{{ zookeeper_id }}
{%- else -%}
  {%- for url in zookeeper_hosts.split(',') -%}
    {%- set url_host = url.split(':')[0] -%}
    {%- if url_host == ansible_fqdn or url_host in ansible_all_ipv4_addresses -%}
{{ loop.index0 }}
    {%- endif -%}
  {%- endfor -%}
{%- endif -%}
07070100000175000081A40000000000000000000000015EBC182800000978000000000000000000000000000000000000004F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/templates/zoo.cfg.j2{#
#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
#}
# http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir={{ zookeeper_data_dir }}
# Place the dataLogDir to a separate physical disc for better performance
# dataLogDir=/disk2/zookeeper

# the port at which the clients will connect
clientPort={{zookeeper_client_port}}

# Maximum number of clients that can connect from one client
maxClientCnxns={{zookeeper_maxClientCnxns}}

# specify all zookeeper servers
# The fist port is used by followers to connect to the leader
# The second one is used for leader election
{% for url in zookeeper_hosts.split(',') %}
server.{{loop.index0}}={{url.split(':')[0]}}:2888:3888
{% endfor %}

# To avoid seeks ZooKeeper allocates space in the transaction log file in
# blocks of preAllocSize kilobytes. The default block size is 64M. One reason
# for changing the size of the blocks is to reduce the block size if snapshots
# are taken more often. (Also, see snapCount).
#preAllocSize=65536

# Clients can submit requests faster than ZooKeeper can process them,
# especially if there are a lot of clients. To prevent ZooKeeper from running
# out of memory due to queued requests, ZooKeeper will throttle clients so that
# there is no more than globalOutstandingLimit outstanding requests in the
# system. The default limit is 1,000.ZooKeeper logs transactions to a
# transaction log. After snapCount transactions are written to a log file a
# snapshot is started and a new transaction log file is started. The default
# snapCount is 100,000.
snapCount=10000

# If this option is defined, requests will be will logged to a trace file named
# traceFile.year.month.day.
#traceFile=

# Leader accepts client connections. Default value is "yes". The leader machine
# coordinates updates. For higher update throughput at thes slight expense of
# read throughput the leader can be configured to not accept clients and focus
# on coordination.
#leaderServes=yes

# Autopurge every hour to avoid using lots of disk in bursts
autopurge.snapRetainCount=3
autopurge.purgeInterval=1
07070100000176000041ED0000000000000000000000025EBC182800000000000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/vars07070100000177000081A40000000000000000000000015EBC18280000093F000000000000000000000000000000000000005100000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/vars/configuration.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
# Zookeeper logging level
zookeeper_log_level: WARN

# Zookeeper log file configuration
# In MB
zookeeper_log_max_size: 10
zookeeper_log_rotation_backup_count: 4

# How long to wait for zookeeper port to be accessible on startup
zookeeper_wait_for_period: 30

# The tuning selector is normally set by the amount of RAM in the system.
# Set this variable to override that tuning. Setting it to smaller values
# can adversely affect the operation of Zookeeper and the components of
# Ardana OpenStack that rely on it. Possible values are: demo, small, medium, large
# and extra_large. Only demo, small, medium and large will be chosen
# based on the amount of RAM. extra_large is only used if set by
# zookeeper_tuning_selector_override
zookeeper_tuning_selector_override:

# Do not make changes to zookeeper_possible_tunings. Use the override
# parameters below in order to set individual parameters if required
zookeeper_possible_tunings:
    demo:
        zookeeper_heap_opts: "-Xmx128m"
        zookeeper_maxClientCnxns: 120
    small:
        zookeeper_heap_opts: "-Xmx256m"
        zookeeper_maxClientCnxns: 120
    medium:
        zookeeper_heap_opts: "-Xmx512m"
        zookeeper_maxClientCnxns: 120
    large:
        zookeeper_heap_opts: "-Xmx784m"
        zookeeper_maxClientCnxns: 240
    extra-large:
        zookeeper_heap_opts: "-Xmx1024m"
        zookeeper_maxClientCnxns: 360

# The JVM Heap option for zookeeper. Set this to override the value that
# would be chosen from zookeeper_possible_tunings
zookeeper_heap_opt_override:

# The maximum number of client connections for zookeeper. Set this to
# override the value that would be chosen from zookeeper_possible_tunings
zookeeper_maxClientCnxns_override:
07070100000178000081A40000000000000000000000015EBC18280000057A000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/vars/debian.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_zookeeper_package_dependencies:
  - openjdk-8-jre-headless
  - default-jre-headless
  - zookeeperd

monasca_zookeeper_restart_packages:
  - default-jre-headless
  - zookeeperd

zookeeper_conf_dir: /etc/zookeeper/conf
zookeeper_script_name: /etc/init.d/zookeeper

zookeeper_env_file: environment
zookeeper_java_opts_key: JAVA_OPTS

# Location of myid file for zookeeper cluster
zookeeper_myid_dir: "{{ zookeeper_conf_dir }}"

zookeeper_java_share_dir: /usr/share/java

# predefined jars defined and available as part of debian package
zookeeper_java_share_classpath: "/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar"
07070100000179000081A40000000000000000000000015EBC1828000002A8000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/vars/main.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
zookeeper_log_dir: /var/log/zookeeper0707010000017A000081A40000000000000000000000015EBC1828000004B9000000000000000000000000000000000000004800000000ardana-monasca-9.0+git.1589385256.7fbfaaf/roles/zookeeper/vars/suse.yml#
# (c) Copyright 2017-2018 SUSE LLC
#
# 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.
#
---
monasca_zookeeper_package_dependencies:
  - java-1_8_0-openjdk-headless
  - zookeeper-server

monasca_zookeeper_restart_packages:
  - java-1_8_0-openjdk-headless
  - zookeeper-server


zookeeper_conf_dir: /etc/zookeeper

zookeeper_env_file: java.env
zookeeper_java_opts_key: JVMFLAGS

# Location of myid file for zookeeper cluster
zookeeper_myid_dir: "{{ zookeeper_data_dir }}"

zookeeper_java_share_dir: /usr/share/java/zookeeper

# All jar files available under zookeeper_java_share_dir are added to classpath.
# That's why there is no predefined list of files and hence blank value below.
zookeeper_java_share_classpath:
0707010000017B000081A40000000000000000000000015EBC1828000003A6000000000000000000000000000000000000004A00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-configure-monasca.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Setup zookeeper monasca-agent plugin
  hosts: FND-ZOO:&MON-AGN
  become: yes
  tags: [zookeeper]
  roles:
    - {role: monasca-agent, run_mode: Use, tags: [zookeeper]}
  tasks:
    - name: Run Monasca Agent detection plugin for zookeeper
      monasca_agent_plugin: name="zookeeper"
0707010000017C000081A40000000000000000000000015EBC182800000333000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-deploy.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Setup zookeeper
  hosts: FND-ZOO
  become: yes
  tags: [zookeeper]
  roles:
    - {role: zookeeper, tags: [zookeeper]}

- include: zookeeper-configure-monasca.yml
0707010000017D000081A40000000000000000000000015EBC1828000003A9000000000000000000000000000000000000004500000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-post-upgrade.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---
- hosts: FND-ZOO
  vars_files:
    - roles/monasca-variables/vars/{{ ansible_os_family | lower }}.yml
  tasks:
  - name: zookeeper-post-upgrade | Remove OS specfic packages
    become: yes
    package:
      name: "{{ item }}"
      state: absent
    with_items: zookeeper_post_upgrade_cleanup
0707010000017E000081A40000000000000000000000015EBC1828000002B7000000000000000000000000000000000000004400000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-reconfigure.yml#
# (c) Copyright 2015 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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.
#
---

- include: zookeeper-deploy.yml run_mode=Configure
0707010000017F000081A40000000000000000000000015EBC18280000028F000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-restart.yml#
# (c) Copyright 2018 SUSE LLC
#
# 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.
#
---
- include: _zookeeper-schedule-restart.yml

- include: zookeeper-start.yml
07070100000180000081A40000000000000000000000015EBC18280000030F000000000000000000000000000000000000003E00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-start.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Start zookeeper
  hosts: FND-ZOO
  become: yes
  vars:
    run_mode: Start
  roles:
    - {role: zookeeper, tags: [zookeeper]}
07070100000181000081A40000000000000000000000015EBC18280000035B000000000000000000000000000000000000003F00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-status.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: zookeeper Status
  hosts: FND-ZOO
  max_fail_percentage: 0
  become: yes
  tags: [zookeeper]
  tasks:
    - { include: roles/monasca-variables/tasks/service_status.yml,
        service_name: zookeeper }
07070100000182000081A40000000000000000000000015EBC18280000030D000000000000000000000000000000000000003D00000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-stop.yml#
# (c) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Stop zookeeper
  hosts: FND-ZOO
  become: yes
  vars:
    run_mode: Stop
  roles:
    - {role: zookeeper, tags: [zookeeper]}
07070100000183000081A40000000000000000000000015EBC182800000343000000000000000000000000000000000000004000000000ardana-monasca-9.0+git.1589385256.7fbfaaf/zookeeper-upgrade.yml#
# (c) Copyright 2016 Hewlett Packard Enterprise Development LP
# (c) Copyright 2017 SUSE LLC
#
# 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: Upgrade zookeeper
  hosts: FND-ZOO
  become: yes
  tags: [zookeeper]
  roles:
    - {role: zookeeper, run_mode: Upgrade, tags: [zookeeper]}

- include: zookeeper-configure-monasca.yml
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!1229 blocks