<commit_before>heat_template_version: rocky

description: >
  OpenStack containerized Rabbitmq service

parameters:
  ContainerRabbitmqImage:
    description: image
    type: string
  ContainerRabbitmqConfigImage:
    description: The container image to use for the rabbitmq config_volume
    type: string
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json
  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
  RabbitCookie:
    type: string
    default: ''
    hidden: true
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json
  ConfigDebug:
    default: false
    description: Whether to run config management (e.g. Puppet) in debug mode.
    type: boolean
  ContainerCli:
    type: string
    default: 'podman'
    description: CLI tool used to manage containers.
    constraints:
      - allowed_values: ['docker', 'podman']
  DeployIdentifier:
    default: ''
    type: string
    description: >
      Setting this to a unique value will re-run any deployment tasks which
      perform configuration on a Heat stack-update.

conditions:
  puppet_debug_enabled: {get_param: ConfigDebug}
  docker_enabled: {equals: [{get_param: ContainerCli}, 'docker']}

resources:

  ContainersCommon:
    type: ../containers-common.yaml

  RabbitmqBase:
    type: ./rabbitmq-messaging-rpc-container-puppet.yaml
    properties:
      EndpointMap: {get_param: EndpointMap}
      ServiceData: {get_param: ServiceData}
      ServiceNetMap: {get_param: ServiceNetMap}
      DefaultPasswords: {get_param: DefaultPasswords}
      RoleName: {get_param: RoleName}
      RoleParameters: {get_param: RoleParameters}

outputs:
  role_data:
    description: Role data for the Rabbitmq API role.
    value:
      service_name: {get_attr: [RabbitmqBase, role_data, service_name]}
      global_config_settings: {get_attr: [RabbitmqBase, role_data, global_config_settings]}
      config_settings:
        map_merge:
          - {get_attr: [RabbitmqBase, role_data, config_settings]}
          - rabbitmq::service_manage: false
            tripleo::profile::pacemaker::rabbitmq_bundle::rabbitmq_docker_image: &rabbitmq_image_pcmklatest
              list_join:
                - ':'
                - - yaql:
                      data: {get_param: ContainerRabbitmqImage}
                      expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
                  - 'pcmklatest'
            tripleo::profile::pacemaker::rabbitmq_bundle::control_port: 3122
            tripleo::profile::pacemaker::rabbitmq_bundle::container_backend: {get_param: ContainerCli}
            tripleo::oslo_messaging_rpc::firewall_rules:
              '109 rabbitmq-bundle':
                dport:
                  - 3122
                  - 4369
                  - 5672
                  - 25672
      service_config_settings: {get_attr: [RabbitmqBase, role_data, service_config_settings]}
      # BEGIN DOCKER SETTINGS
      puppet_config:
        config_volume: rabbitmq
        puppet_tags: 'file,file_line'
        step_config:
          list_join:
            - "\n"
            - - "['Rabbitmq_policy', 'Rabbitmq_user'].each |String $val| { noop_resource($val) }"
              - "include ::tripleo::profile::pacemaker::rabbitmq_bundle"
        config_image: {get_param: ContainerRabbitmqConfigImage}
      kolla_config:
        /var/lib/kolla/config_files/rabbitmq.json:
          command: /usr/sbin/pacemaker_remoted
          config_files:
          - dest: /etc/libqb/force-filesystem-sockets
            source: /dev/null
            owner: root
            perm: '0644'
          - dest: /var/log/btmp
            source: /dev/null
            owner: root:utmp
            perm: '0600'
          - source: "/var/lib/kolla/config_files/src/*"
            dest: "/"
            merge: true
            preserve_properties: true
          - source: "/var/lib/kolla/config_files/src-tls/*"
            dest: "/"
            merge: true
            optional: true
            preserve_properties: true
          permissions:
           - path: /var/lib/rabbitmq
             owner: rabbitmq:rabbitmq
             recurse: true
           - path: /var/log/rabbitmq
             owner: rabbitmq:rabbitmq
             recurse: true
           - path: /etc/pki/tls/certs/rabbitmq.crt
             owner: rabbitmq:rabbitmq
             perm: '0600'
             optional: true
           - path: /etc/pki/tls/private/rabbitmq.key
             owner: rabbitmq:rabbitmq
             perm: '0600'
             optional: true
      # When using pacemaker we don't launch the container, instead that is done by pacemaker
      # itself.
      container_config_scripts: {get_attr: [ContainersCommon, container_config_scripts]}
      docker_config:
        step_1:
          rabbitmq_bootstrap:
            start_order: 0
            image: {get_param: ContainerRabbitmqImage}
            net: host
            privileged: false
            volumes:
              - /var/lib/kolla/config_files/rabbitmq.json:/var/lib/kolla/config_files/config.json:ro
              - /var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro
              - /etc/hosts:/etc/hosts:ro
              - /etc/localtime:/etc/localtime:ro
              - /var/lib/rabbitmq:/var/lib/rabbitmq:z
            environment:
              KOLLA_CONFIG_STRATEGY: COPY_ALWAYS
              KOLLA_BOOTSTRAP: true
              # NOTE: this should force this container to re-run on each
              # update (scale-out, etc.)
              RABBITMQ_CLUSTER_COOKIE:
                yaql:
                  expression: $.data.passwords.where($ != '').first()
                  data:
                    passwords:
                      - {get_param: RabbitCookie}
                      - {get_param: [DefaultPasswords, rabbit_cookie]}
        step_2:
          rabbitmq_restart_bundle:
            start_order: 0
            config_volume: rabbitmq
            detach: false
            net: host
            ipc: host
            user: root
            environment:
              TRIPLEO_MINOR_UPDATE: ''
            command: /pacemaker_restart_bundle.sh rabbitmq-bundle oslo_messaging_rpc
            image: {get_param: ContainerRabbitmqImage}
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, pacemaker_restart_volumes]}
                - - /var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro
          rabbitmq_init_bundle:
            start_order: 1
            detach: false
            net: host
            ipc: host
            user: root
            command: # '/container_puppet_apply.sh "STEP" "TAGS" "CONFIG" "DEBUG"'<commit_msg>Fix missing environment variable in rabbitmq_init_bundle<commit_after>heat_template_version: rocky

description: >
  OpenStack containerized Rabbitmq service

parameters:
  ContainerRabbitmqImage:
    description: image
    type: string
  ContainerRabbitmqConfigImage:
    description: The container image to use for the rabbitmq config_volume
    type: string
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json
  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
  RabbitCookie:
    type: string
    default: ''
    hidden: true
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json
  ConfigDebug:
    default: false
    description: Whether to run config management (e.g. Puppet) in debug mode.
    type: boolean
  ContainerCli:
    type: string
    default: 'podman'
    description: CLI tool used to manage containers.
    constraints:
      - allowed_values: ['docker', 'podman']
  DeployIdentifier:
    default: ''
    type: string
    description: >
      Setting this to a unique value will re-run any deployment tasks which
      perform configuration on a Heat stack-update.

conditions:
  puppet_debug_enabled: {get_param: ConfigDebug}
  docker_enabled: {equals: [{get_param: ContainerCli}, 'docker']}

resources:

  ContainersCommon:
    type: ../containers-common.yaml

  RabbitmqBase:
    type: ./rabbitmq-messaging-rpc-container-puppet.yaml
    properties:
      EndpointMap: {get_param: EndpointMap}
      ServiceData: {get_param: ServiceData}
      ServiceNetMap: {get_param: ServiceNetMap}
      DefaultPasswords: {get_param: DefaultPasswords}
      RoleName: {get_param: RoleName}
      RoleParameters: {get_param: RoleParameters}

outputs:
  role_data:
    description: Role data for the Rabbitmq API role.
    value:
      service_name: {get_attr: [RabbitmqBase, role_data, service_name]}
      global_config_settings: {get_attr: [RabbitmqBase, role_data, global_config_settings]}
      config_settings:
        map_merge:
          - {get_attr: [RabbitmqBase, role_data, config_settings]}
          - rabbitmq::service_manage: false
            tripleo::profile::pacemaker::rabbitmq_bundle::rabbitmq_docker_image: &rabbitmq_image_pcmklatest
              list_join:
                - ':'
                - - yaql:
                      data: {get_param: ContainerRabbitmqImage}
                      expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
                  - 'pcmklatest'
            tripleo::profile::pacemaker::rabbitmq_bundle::control_port: 3122
            tripleo::profile::pacemaker::rabbitmq_bundle::container_backend: {get_param: ContainerCli}
            tripleo::oslo_messaging_rpc::firewall_rules:
              '109 rabbitmq-bundle':
                dport:
                  - 3122
                  - 4369
                  - 5672
                  - 25672
      service_config_settings: {get_attr: [RabbitmqBase, role_data, service_config_settings]}
      # BEGIN DOCKER SETTINGS
      puppet_config:
        config_volume: rabbitmq
        puppet_tags: 'file,file_line'
        step_config:
          list_join:
            - "\n"
            - - "['Rabbitmq_policy', 'Rabbitmq_user'].each |String $val| { noop_resource($val) }"
              - "include ::tripleo::profile::pacemaker::rabbitmq_bundle"
        config_image: {get_param: ContainerRabbitmqConfigImage}
      kolla_config:
        /var/lib/kolla/config_files/rabbitmq.json:
          command: /usr/sbin/pacemaker_remoted
          config_files:
          - dest: /etc/libqb/force-filesystem-sockets
            source: /dev/null
            owner: root
            perm: '0644'
          - dest: /var/log/btmp
            source: /dev/null
            owner: root:utmp
            perm: '0600'
          - source: "/var/lib/kolla/config_files/src/*"
            dest: "/"
            merge: true
            preserve_properties: true
          - source: "/var/lib/kolla/config_files/src-tls/*"
            dest: "/"
            merge: true
            optional: true
            preserve_properties: true
          permissions:
           - path: /var/lib/rabbitmq
             owner: rabbitmq:rabbitmq
             recurse: true
           - path: /var/log/rabbitmq
             owner: rabbitmq:rabbitmq
             recurse: true
           - path: /etc/pki/tls/certs/rabbitmq.crt
             owner: rabbitmq:rabbitmq
             perm: '0600'
             optional: true
           - path: /etc/pki/tls/private/rabbitmq.key
             owner: rabbitmq:rabbitmq
             perm: '0600'
             optional: true
      # When using pacemaker we don't launch the container, instead that is done by pacemaker
      # itself.
      container_config_scripts: {get_attr: [ContainersCommon, container_config_scripts]}
      docker_config:
        step_1:
          rabbitmq_bootstrap:
            start_order: 0
            image: {get_param: ContainerRabbitmqImage}
            net: host
            privileged: false
            volumes:
              - /var/lib/kolla/config_files/rabbitmq.json:/var/lib/kolla/config_files/config.json:ro
              - /var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro
              - /etc/hosts:/etc/hosts:ro
              - /etc/localtime:/etc/localtime:ro
              - /var/lib/rabbitmq:/var/lib/rabbitmq:z
            environment:
              KOLLA_CONFIG_STRATEGY: COPY_ALWAYS
              KOLLA_BOOTSTRAP: true
              # NOTE: this should force this container to re-run on each
              # update (scale-out, etc.)
              TRIPLEO_DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
              RABBITMQ_CLUSTER_COOKIE:
                yaql:
                  expression: $.data.passwords.where($ != '').first()
                  data:
                    passwords:
                      - {get_param: RabbitCookie}
                      - {get_param: [DefaultPasswords, rabbit_cookie]}
        step_2:
          rabbitmq_restart_bundle:
            start_order: 0
            config_volume: rabbitmq
            detach: false
            net: host
            ipc: host
            user: root
            environment:
              TRIPLEO_MINOR_UPDATE: ''
            command: /pacemaker_restart_bundle.sh rabbitmq-bundle oslo_messaging_rpc
            image: {get_param: ContainerRabbitmqImage}
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, pacemaker_restart_volumes]}
                - - /var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro
          rabbitmq_init_bundle:
            start_order: 1
            detach: false
            net: host
            ipc: host
            user: root
            command: # '/container_puppet_apply.sh "STEP" "TAGS" "CONFIG" "DEBUG"'
{'fraction_non_alphanumeric': 0.08595871808799566, 'fraction_numerical': 0.006382400869092884, 'mean_word_length': 1.9629853148259908, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1564184', 'n_tokens_mistral': 4415, 'n_tokens_neox': 4128, 'n_words': 925}