heat_template_version: rocky

description: >
  OpenStack Ceilometer service configured with Puppet

parameters:
  ServiceData:
    default: {}
    description: Dictionary packing service data
    type: json
  ServiceNetMap:
    default: {}
    description: Mapping of service_name -> network name. Typically set
                 via parameter_defaults in the resource registry.  This
                 mapping overrides those in ServiceNetMapDefaults.
    type: json
  DefaultPasswords:
    default: {}
    type: json
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json
  CeilometerMeteringSecret:
    description: Secret shared by the ceilometer services.
    type: string
    hidden: true
  CeilometerPassword:
    description: The password for the ceilometer service account.
    type: string
    hidden: true
  AmqpRpcAddressPrefix:
    default: ''
    description: Address prefix for RPC addresses
    type: string
  AmqpNotifyAddressPrefix:
    default: ''
    description: Address prefix for Notification addresses
    type: string
  MetricsQdrPort:
    default: '5666'
    description: Service name or port number on which the qdrouterd will accept
                 connections. This argument must be string, even if the numeric
                 form is used.
    type: string
  ManageEventPipeline:
    default: true
    description: Whether to manage event_pipeline.yaml.
    type: boolean
  EventPipelinePublishers:
    default: []
    description: >
        A list of publishers to put in event_pipeline.yaml. When the
        collector is used, override this with notifier:// publisher.
        If zaqar is enabled, you can also publish to a zaqar queue
        by including "zaqar://?queue=queue_name" in this list.
        Set ManageEventPipeline to true for override to take effect.
    type: comma_delimited_list
  ManagePipeline:
    default: false
    description: Whether to manage pipeline.yaml.
    type: boolean
  PipelinePublishers:
    default: []
    description: >
        A list of publishers to put in pipeline.yaml. When the
        collector is used, override this with notifier:// publisher.
        Set ManagePipeline to true for override to take effect.
    type: comma_delimited_list
  CeilometerQdrPublish:
    default: false
    description: Whether to send telemetry data to Qdr.
    type: boolean
  ManagePolling:
    default: false
    description: Whether to manage polling.yaml.
    type: boolean
  Debug:
    default: false
    description: Set to True to enable debugging on all services.
    type: boolean
  CeilometerDebug:
    default: ''
    description: Set to True to enable debugging Ceilometer services.
    type: string
    constraints:
      - allowed_values: [ '', 'true', 'True', 'TRUE', 'false', 'False', 'FALSE']
  KeystoneRegion:
    type: string
    default: 'regionOne'
    description: Keystone region for endpoint
  SnmpdReadonlyUserName:
    default: ro_snmp_user
    description: The user name for SNMPd with readonly rights running on all Overcloud nodes
    type: string
  SnmpdReadonlyUserPassword:
    description: The user password for SNMPd with readonly rights running on all Overcloud nodes
    type: string
    hidden: true
  NotificationDriver:
    type: string
    default: 'messagingv2'
    description: Driver or drivers to handle sending notifications.
  GnocchiArchivePolicy:
    default: 'ceilometer-low-rate'
    type: string
    description: (DEPRECATED) archive policy to use with gnocchi backend

parameter_groups:
- label: deprecated
  description: |
   The following parameters are deprecated and will be removed. They should not
   be relied on for new deployments. If you have concerns regarding deprecated
   parameters, please contact the TripleO development team on IRC or the
   OpenStack mailing list.
  parameters:
  - GnocchiArchivePolicy

conditions:
  service_debug_unset: {equals : [{get_param: CeilometerDebug}, '']}
  ceilometer_qdr_publish: {equals: [{get_param: CeilometerQdrPublish}, true]}

outputs:
  role_data:
    description: Role data for the Ceilometer role.
    value:
      service_name: ceilometer_base
      config_settings:
        map_merge:
          - ceilometer::logging::debug:
              if:
              - service_debug_unset
              - {get_param: Debug }
              - {get_param: CeilometerDebug }
            ceilometer::keystone::authtoken::project_name: 'service'
            ceilometer::keystone::authtoken::user_domain_name: 'Default'
            ceilometer::keystone::authtoken::project_domain_name: 'Default'
            ceilometer::keystone::authtoken::password: {get_param: CeilometerPassword}
            ceilometer::keystone::authtoken::www_authenticate_uri: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
            ceilometer::keystone::authtoken::auth_uri: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
            ceilometer::keystone::authtoken::auth_url: { get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
            ceilometer::agent::auth::auth_password: {get_param: CeilometerPassword}
            ceilometer::agent::auth::auth_url: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
            ceilometer::agent::notification::manage_event_pipeline: {get_param: ManageEventPipeline}
            ceilometer::agent::notification::manage_pipeline: {get_param: ManagePipeline}
            ceilometer::agent::polling::manage_polling: {get_param: ManagePolling}
            ceilometer::agent::auth::auth_region: {get_param: KeystoneRegion}
            ceilometer::agent::auth::auth_tenant_name: 'service'
            ceilometer::agent::auth::auth_user_domain_name: 'Default'
            ceilometer::agent::auth::auth_project_domain_name: 'Default'
            ceilometer::agent::auth::auth_endpoint_type: 'internalURL'
            ceilometer::notification_driver: {get_param: NotificationDriver}
            ceilometer::amqp_rpc_address_prefix: {get_param: AmqpRpcAddressPrefix}
            ceilometer::amqp_notify_address_prefix: {get_param: AmqpNotifyAddressPrefix}
            ceilometer::telemetry_secret: {get_param: CeilometerMeteringSecret}
            ceilometer::snmpd_readonly_username: {get_param: SnmpdReadonlyUserName}
            ceilometer::snmpd_readonly_user_password: {get_param: SnmpdReadonlyUserPassword}
            ceilometer::host: "%{hiera('fqdn_canonical')}"
            tripleo::profile::base::ceilometer::event_pipeline_publishers: {get_param: EventPipelinePublishers}
            tripleo::profile::base::ceilometer::pipeline_publishers: {get_param: PipelinePublishers}
          - if: #Ceilometer connection to qdr
            - ceilometer_qdr_publish
            - tripleo::profile::base::ceilometer::notifier_host_addr:
                str_replace:
                  template:
                    "%{hiera('$NETWORK')}"
                  params:
                    $NETWORK: {get_param: [ServiceNetMap, MetricsQdrNetwork]}
              tripleo::profile::base::ceilometer::notifier_host_port: {get_param: MetricsQdrPort}
            - {}
      service_config_settings:
        keystone:
          ceilometer_auth_enabled: true
          # NOTE(aschultz): no endpoints since ceilometer api removal
          ceilometer::keystone::auth::configure_endpoint: false
          ceilometer::keystone::auth::password: {get_param: CeilometerPassword}
          ceilometer::keystone::auth::region: {get_param: KeystoneRegion}
          ceilometer::keystone::auth::tenant: 'service'
          # Enable default notification queue
          tripleo::profile::base::keystone::ceilometer_notification_topics: ["notifications"]
