<commit_before>heat_template_version: rocky

description: >
  OpenStack containerized fluentd services

parameters:
  DockerFluentdImage:
    description: image
    type: string
  DockerFluentdConfigImage:
    description: The container image to use fluentd 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
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json

resources:

  ContainersCommon:
    type: ./containers-common.yaml

  FluentdClientBase:
    type: ../../puppet/services/logging/fluentd.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 fluentd role.
    value:
      service_name: {get_attr: [FluentdClientBase, role_data, service_name]}
      config_settings:
        map_merge:
          - {get_attr: [FluentdClientBase, role_data, config_settings]}
      # BEGIN DOCKER SETTINGS
      puppet_config:
        config_volume: fluentd
        puppet_tags: config
        step_config:
          get_attr: [FluentdClientBase, role_data, step_config]
        config_image: {get_param: DockerFluentdConfigImage}
      kolla_config:
        /var/lib/kolla/config_files/fluentd.json:
          command: /usr/bin/fluentd -c /etc/fluentd/fluent.conf -o /var/log/fluentd/fluentd.log
          config_files:
            - source: "/var/lib/kolla/config_files/src/*"
              dest: "/"
              merge: true
              preserve_properties: true
          permissions:
            - path: /var/lib/fluentd
              owner: fluentd:fluentd
              recurse: true
            - path: /var/log/fluentd
              owner: fluentd:fluentd
              recurse: true
      docker_config:
        step_3:
          fluentd:
            image: {get_param: DockerFluentdImage}
            net: host
            privileged: true
            user: root
            restart: always
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, volumes]}
                -
                  - /var/cache/containers/fluentd:/var/cache/fluentd:rw
                  - /var/lib/kolla/config_files/fluentd.json:/var/lib/kolla/config_files/config.json:ro
                  - /var/lib/config-data/puppet-generated/fluentd/:/var/lib/kolla/config_files/src:ro
                  - /var/log/containers:/var/log/containers:ro
                  - /var/log/containers/fluentd:/var/log/fluentd:rw
            environment:
              - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
      host_prep_tasks:
        - name: create persistent logs directory for fluentd
          file:
            path: /var/log/containers/fluentd
            state: directory
        - name: fluentd logs readme
          copy:
            dest: /var/log/fluentd/readme.txt
            content: |
              Log files from fluentd containers can be found under<commit_msg>Fluentd configures rsyslog to send logs properly<commit_after>heat_template_version: rocky

description: >
  OpenStack containerized fluentd services

parameters:
  DockerFluentdImage:
    description: image
    type: string
  DockerFluentdConfigImage:
    description: The container image to use fluentd 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
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json

resources:

  ContainersCommon:
    type: ./containers-common.yaml

  FluentdClientBase:
    type: ../../puppet/services/logging/fluentd.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 fluentd role.
    value:
      service_name: {get_attr: [FluentdClientBase, role_data, service_name]}
      config_settings:
        map_merge:
          - {get_attr: [FluentdClientBase, role_data, config_settings]}
      # BEGIN DOCKER SETTINGS
      puppet_config:
        config_volume: fluentd
        puppet_tags: config
        step_config:
          get_attr: [FluentdClientBase, role_data, step_config]
        config_image: {get_param: DockerFluentdConfigImage}
      kolla_config:
        /var/lib/kolla/config_files/fluentd.json:
          command: /usr/bin/fluentd -c /etc/fluentd/fluent.conf -o /var/log/fluentd/fluentd.log
          config_files:
            - source: "/var/lib/kolla/config_files/src/*"
              dest: "/"
              merge: true
              preserve_properties: true
          permissions:
            - path: /var/lib/fluentd
              owner: fluentd:fluentd
              recurse: true
            - path: /var/log/fluentd
              owner: fluentd:fluentd
              recurse: true
      docker_config:
        step_3:
          fluentd:
            image: {get_param: DockerFluentdImage}
            net: host
            privileged: true
            user: root
            restart: always
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, volumes]}
                -
                  - /var/cache/containers/fluentd:/var/cache/fluentd:rw
                  - /var/lib/kolla/config_files/fluentd.json:/var/lib/kolla/config_files/config.json:ro
                  - /var/lib/config-data/puppet-generated/fluentd/:/var/lib/kolla/config_files/src:ro
                  - /var/log/containers:/var/log/containers:ro
                  - /var/log/containers/fluentd:/var/log/fluentd:rw
                  - /etc/rsyslog.d:/etc/rsyslog.d:rw
            environment:
              - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
      host_prep_tasks:
        - name: create persistent logs directory for fluentd
          file:
            path: /var/log/containers/fluentd
            state: directory
        - name: fluentd logs readme
          copy:
            dest: /var/log/fluentd/readme.txt
            content: |
              Log files from fluentd containers can be found under
{'fraction_non_alphanumeric': 0.07943317732709308, 'fraction_numerical': 0.00026001040041601667, 'mean_word_length': 2.05035685963521, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7363298', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2222, 'n_words': 506}