diff --git a/docker/services/logging/files/panko-api.yaml b/docker/services/logging/files/panko-api.yaml new file mode 100644 index 0000000000..9ac2b97e90 --- /dev/null +++ b/docker/services/logging/files/panko-api.yaml @@ -0,0 +1,41 @@ +heat_template_version: pike + +description: > + OpenStack containerized Panko service + +parameters: + DockerPankoApiImage: + description: image + type: string + +outputs: + cmd_extra_args: + description: Extra command line arguments for running the service in the container. + value: '' + config_settings: + description: Extra hieradata needed to log to files in the host. + value: null + volumes: + description: The volumes needed to log to files in the host. + value: &panko_api_volumes + - /var/log/containers/panko:/var/log/panko + - /var/log/containers/httpd/panko-api:/var/log/httpd + docker_config: + description: Extra containers needed for logging to files in the host. + value: + step_2: + panko_init_log: + image: {get_param: DockerPankoApiImage} + user: root + volumes: *panko_api_volumes + command: ['/bin/bash', '-c', 'chown -R panko:panko /var/log/panko'] + host_prep_tasks: + description: Extra ansible tasks needed for logging to files in the host. + value: + - name: create persistent logs directory + file: + path: "{{ item }}" + state: directory + with_items: + - /var/log/containers/panko + - /var/log/containers/httpd/panko-api diff --git a/docker/services/logging/stdout/panko-api.yaml b/docker/services/logging/stdout/panko-api.yaml new file mode 100644 index 0000000000..f20590adf2 --- /dev/null +++ b/docker/services/logging/stdout/panko-api.yaml @@ -0,0 +1,63 @@ +heat_template_version: pike + +description: > + OpenStack containerized Keystone service + +parameters: + DockerPankoApiImage: + description: image + type: string + +outputs: + cmd_extra_args: + description: Extra command line arguments for running the service in the container. + value: "--log-dir= --log-file=" + config_settings: + description: Extra hieradata needed to log to stdout. + value: + panko::wsgi::apache::access_log_file: /var/log/httpd/access.log + panko::wsgi::apache::error_log_file: /var/log/httpd/error_log + docker_config: + description: Extra containers needed for logging to stdout or a sidecar container. + value: + step_2: + panko_api_apache_error_logs: + start_order: 1 + image: {get_param: DockerPankoApiImage} + user: root + privileged: false + restart: always + healthcheck: + test: '[ -p /var/log/httpd/error_log ]' + command: ['/bin/bash', '-c', 'mkdir -p /var/log/httpd && rm -f /var/log/httpd/error_log && mkfifo /var/log/httpd/error_log && while true; do cat /var/log/httpd/error_log; done'] + volumes: + - PankoApiLogs:/var/log/ + panko_api_apache_access_logs: + start_order: 1 + image: {get_param: DockerPankoApiImage} + user: root + privileged: false + restart: always + healthcheck: + test: '[ -p /var/log/httpd/access.log ]' + command: ['/bin/bash', '-c', 'mkdir -p /var/log/httpd && rm -f /var/log/httpd/access.log && mkfifo /var/log/httpd/access.log && while true; do cat /var/log/httpd/access.log; done'] + volumes: + - PankoApiLogs:/var/log/ + panko_api_logs: + start_order: 2 + image: {get_param: DockerPankoApiImage} + user: panko + privileged: false + restart: always + healthcheck: + test: '[ -p /var/log/panko/app.log ]' + command: ['/bin/bash', '-c', 'mkdir -p /var/log/panko && rm -f /var/log/panko/app.log && mkfifo /var/log/panko/app.log && while true; do cat /var/log/panko/app.log; done'] + volumes: + - PankoApiLogs:/var/log/ + volumes: + description: The volumes needed to log to stdout or a sidecar container. + value: + - PankoApiLogs:/var/log/ + host_prep_tasks: + description: Extra ansible tasks needed for logging to files in the host. + value: null diff --git a/docker/services/panko-api.yaml b/docker/services/panko-api.yaml index 7987c8dcb9..198ddeca09 100644 --- a/docker/services/panko-api.yaml +++ b/docker/services/panko-api.yaml @@ -64,6 +64,9 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + PankoApiLogging: + type: OS::TripleO::Services::Logging::PankoApi + outputs: role_data: description: Role data for the Panko API role. @@ -72,6 +75,7 @@ outputs: config_settings: map_merge: - get_attr: [PankoApiPuppetBase, role_data, config_settings] + - get_attr: [PankoApiLogging, config_settings] - apache::default_vhost: false logging_source: {get_attr: [PankoApiPuppetBase, role_data, logging_source]} logging_groups: {get_attr: [PankoApiPuppetBase, role_data, logging_groups]} @@ -101,16 +105,10 @@ outputs: recurse: true docker_config: step_2: - panko_init_log: - image: &panko_api_image {get_param: DockerPankoApiImage} - user: root - volumes: - - /var/log/containers/panko:/var/log/panko - - /var/log/containers/httpd/panko-api:/var/log/httpd - command: ['/bin/bash', '-c', 'chown -R panko:panko /var/log/panko'] + get_attr: [PankoApiLogging, docker_config, step_2] step_3: panko_db_sync: - image: *panko_api_image + image: &panko_api_image {get_param: DockerPankoApiImage} net: host detach: false privileged: false @@ -118,12 +116,19 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [PankoApiLogging, volumes]} - - /var/lib/config-data/panko/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro - /var/lib/config-data/panko/etc/panko:/etc/panko:ro - - /var/log/containers/panko:/var/log/panko - - /var/log/containers/httpd/panko-api:/var/log/httpd - command: "/usr/bin/bootstrap_host_exec panko_api su panko -s /bin/bash -c '/usr/bin/panko-dbsync'" + command: + # NOTE(jaosorior): When providing extra arguments, we need to make sure that they're part + # of the bash -c invocation, so we include them in the quoted db sync command. Hence the + # final single quote that's part of the list_join. + list_join: + - ' ' + - - "/usr/bin/bootstrap_host_exec panko_api su panko -s /bin/bash -c '/usr/bin/panko-dbsync" + - {get_attr: [PankoApiLogging, cmd_extra_args]} + - "'" step_4: panko_api: start_order: 2 @@ -134,11 +139,10 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [PankoApiLogging, volumes]} - - /var/lib/kolla/config_files/panko_api.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/panko/:/var/lib/kolla/config_files/src:ro - - /var/log/containers/panko:/var/log/panko - - /var/log/containers/httpd/panko-api:/var/log/httpd - if: - internal_tls_enabled @@ -151,13 +155,6 @@ outputs: - '' environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - host_prep_tasks: - - name: create persistent logs directory - file: - path: "{{ item }}" - state: directory - with_items: - - /var/log/containers/panko - - /var/log/containers/httpd/panko-api + host_prep_tasks: {get_attr: [PankoApiLogging, host_prep_tasks]} metadata_settings: get_attr: [PankoApiPuppetBase, role_data, metadata_settings] diff --git a/environments/stdout-logging.yaml b/environments/stdout-logging.yaml index adb859ab0b..ae1f047806 100644 --- a/environments/stdout-logging.yaml +++ b/environments/stdout-logging.yaml @@ -11,3 +11,4 @@ resource_registry: OS::TripleO::Services::Logging::NovaCommon: ../docker/services/logging/stdout/nova-common.yaml OS::TripleO::Services::Logging::NovaPlacement: ../docker/services/logging/stdout/nova-placement.yaml OS::TripleO::Services::Logging::NovaLibvirt: ../docker/services/logging/stdout/nova-libvirt.yaml + OS::TripleO::Services::Logging::PankoApi: ../docker/services/logging/stdout/panko-api.yaml diff --git a/overcloud-resource-registry-puppet.j2.yaml b/overcloud-resource-registry-puppet.j2.yaml index 8e3634808d..7622fd65f5 100644 --- a/overcloud-resource-registry-puppet.j2.yaml +++ b/overcloud-resource-registry-puppet.j2.yaml @@ -309,6 +309,7 @@ resource_registry: OS::TripleO::Services::Logging::NovaCommon: docker/services/logging/files/nova-common.yaml OS::TripleO::Services::Logging::NovaLibvirt: OS::Heat::None OS::TripleO::Services::Logging::NovaPlacement: docker/services/logging/files/nova-placement.yaml + OS::TripleO::Services::Logging::PankoApi: docker/services/logging/files/panko-api.yaml parameter_defaults: EnablePackageInstall: false