openshift/openshift-ansible

fluentd.j2 is missing endif

Closed this issue · 1 comments

Description

Provide a brief description of your issue here. For example:

Aggregated logging install fails due to missing endif statement in fluentd.j2 template

Version

Please put the following version information in the code block
indicated below.

  • Your ansible version per ansible --version
    2.8.2

If you're operating from a git clone:

  • The output of git describe
    openshift-ansible-3.11.155-1
Steps To Reproduce
  1. Install aggregate logging
    .... openshift-ansible/playbooks/openshift-logging/config.yml -e openshift_logging_install_logging=True
Expected Results

Installation completes without errors

Observed Results

Describe what is actually happening.

fatal: [node01]: FAILED! => {"changed": false, "msg": "AnsibleError: template error while templating string: Unexpected end of template. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.. String: apiVersion: extensions/v1beta1\nkind: \"DaemonSet\"\nmetadata:\n  name: \"{{ daemonset_name }}\"\n  labels:\n    provider: openshift\n    component: \"{{ daemonset_component }}\"\n    logging-infra: \"{{ daemonset_component }}\"\n  annotations:\n    prometheus.io/scrape: \"true\"\n    prometheus.io/port: \"24231\"\n    prometheus.io/scheme: \"https\"\nspec:\n  selector:\n    matchLabels:\n      provider: openshift\n      component: \"{{ daemonset_component }}\"\n  updateStrategy:\n    type: RollingUpdate\n    rollingUpdate:\n      minReadySeconds: 600\n  template:\n    metadata:\n      name: \"{{ daemonset_container_name }}\"\n      labels:\n        logging-infra: \"{{ daemonset_component }}\"\n        provider: openshift\n        component: \"{{ daemonset_component }}\"\n      annotations:\n        scheduler.alpha.kubernetes.io/critical-pod: ''\n    spec:\n      priorityClassName: cluster-logging\n      serviceAccountName: \"{{ daemonset_serviceAccount }}\"\n      nodeSelector:\n        {{ fluentd_nodeselector_key }}: \"{{ fluentd_nodeselector_value }}\"\n      containers:\n      - name: \"{{ daemonset_container_name }}\"\n        image: \"{{ openshift_logging_fluentd_image }}\"\n        imagePullPolicy: IfNotPresent\n        securityContext:\n          privileged: true\n{% if (fluentd_memory_limit is defined and fluentd_memory_limit is not none) or (fluentd_cpu_limit is defined and fluentd_cpu_limit is not none) or (fluentd_cpu_request is defined and fluentd_cpu_request is not none) %}\n        resources:\n{%   if (fluentd_memory_limit is defined and fluentd_memory_limit is not none) or (fluentd_cpu_limit is defined and fluentd_cpu_limit is not none) %}\n          limits:\n{%     if fluentd_cpu_limit is not none %}\n            cpu: \"{{fluentd_cpu_limit}}\"\n{%     endif %}\n{%     if fluentd_memory_limit is not none %}\n            memory: \"{{fluentd_memory_limit}}\"\n{%     endif %}\n{%   endif %}\n{%   if (fluentd_memory_limit is defined and fluentd_memory_limit is not none) or (fluentd_cpu_request is defined and fluentd_cpu_request is not none) %}\n          requests:\n{%     if fluentd_cpu_request is not none %}\n            cpu: \"{{fluentd_cpu_request}}\"\n{%     endif %}\n{%     if fluentd_memory_limit is not none %}\n            memory: \"{{fluentd_memory_limit}}\"\n{%     endif %}\n{%   endif %}\n{% endif %}\n        volumeMounts:\n        - name: runlogjournal\n          mountPath: /run/log/journal\n        - name: varlog\n          mountPath: /var/log\n        - name: varlibdockercontainers\n          mountPath: /var/lib/docker\n          readOnly: true\n        - name: config\n          mountPath: /etc/fluent/configs.d/user\n          readOnly: true\n        - name: certs\n          mountPath: /etc/fluent/keys\n          readOnly: true\n        - name: dockerhostname\n          mountPath: /etc/docker-hostname\n          readOnly: true\n        - name: localtime\n          mountPath: /etc/localtime\n          readOnly: true\n        - name: dockercfg\n          mountPath: /etc/sysconfig/docker\n          readOnly: true\n        - name: originnodecfg\n          mountPath: /etc/origin/node\n          readOnly: true\n        - name: dockerdaemoncfg\n          mountPath: /etc/docker\n          readOnly: true\n        - name: filebufferstorage\n          mountPath: /var/lib/fluentd\n{% if openshift_logging_mux_client_mode is defined and\n     ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or\n      (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}\n        - name: muxcerts\n          mountPath: /etc/fluent/muxkeys\n          readOnly: true\n{% endif %}\n        env:\n        - name: \"K8S_HOST_URL\"\n          value: \"{{ openshift_logging_fluentd_master_url }}\"\n        - name: \"ES_HOST\"\n          value: \"{{ app_host }}\"\n        - name: \"ES_PORT\"\n          value: \"{{ app_port }}\"\n        - name: \"ES_CLIENT_CERT\"\n          value: \"{{ openshift_logging_fluentd_app_client_cert }}\"\n        - name: \"ES_CLIENT_KEY\"\n          value: \"{{ openshift_logging_fluentd_app_client_key }}\"\n        - name: \"ES_CA\"\n          value: \"{{ openshift_logging_fluentd_app_ca }}\"\n        - name: \"OPS_HOST\"\n          value: \"{{ ops_host }}\"\n        - name: \"OPS_PORT\"\n          value: \"{{ ops_port }}\"\n        - name: \"OPS_CLIENT_CERT\"\n          value: \"{{ openshift_logging_fluentd_ops_client_cert }}\"\n        - name: \"OPS_CLIENT_KEY\"\n          value: \"{{ openshift_logging_fluentd_ops_client_key }}\"\n        - name: \"OPS_CA\"\n          value: \"{{ openshift_logging_fluentd_ops_ca }}\"\n        - name: \"JOURNAL_SOURCE\"\n          value: \"{{ openshift_logging_fluentd_journal_source | default('') }}\"\n        - name: \"JOURNAL_READ_FROM_HEAD\"\n          value: \"{{ openshift_logging_fluentd_journal_read_from_head | lower }}\"\n        - name: \"BUFFER_QUEUE_LIMIT\"\n          value: \"{{ openshift_logging_fluentd_buffer_queue_limit }}\"\n        - name: \"BUFFER_SIZE_LIMIT\"\n          value: \"{{ openshift_logging_fluentd_buffer_size_limit }}\"\n        - name: \"FLUENTD_CPU_LIMIT\"\n          valueFrom:\n            resourceFieldRef:\n              containerName: \"{{ daemonset_container_name }}\"\n              resource: limits.cpu\n        - name: \"FLUENTD_MEMORY_LIMIT\"\n          valueFrom:\n            resourceFieldRef:\n              containerName: \"{{ daemonset_container_name }}\"\n              resource: limits.memory\n        - name: \"FILE_BUFFER_LIMIT\"\n          value: \"{{ openshift_logging_fluentd_file_buffer_limit | default('256Mi') }}\"\n{% if openshift_logging_mux_client_mode is defined and\n     ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or\n      (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}\n        - name: \"MUX_CLIENT_MODE\"\n          value: \"{{ openshift_logging_mux_client_mode }}\"\n{% endif %}\n{% if openshift_logging_install_eventrouter is defined and (openshift_logging_install_eventrouter | bool) %}\n        - name: \"TRANSFORM_EVENTS\"\n          value: \"true\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog is defined and openshift_logging_fluentd_remote_syslog %}\n        - name: USE_REMOTE_SYSLOG\n          value: \"true\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_host is defined %}\n        - name: REMOTE_SYSLOG_HOST\n          value: \"{{ openshift_logging_fluentd_remote_syslog_host }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_port is defined %}\n        - name: REMOTE_SYSLOG_PORT\n          value: \"{{ openshift_logging_fluentd_remote_syslog_port }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_severity is defined %}\n        - name: REMOTE_SYSLOG_SEVERITY\n          value: \"{{ openshift_logging_fluentd_remote_syslog_severity }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_facility is defined %}\n        - name: REMOTE_SYSLOG_FACILITY\n          value: \"{{ openshift_logging_fluentd_remote_syslog_facility }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_remove_tag_prefix is defined %}\n        - name: REMOTE_SYSLOG_REMOVE_TAG_PREFIX\n          value: \"{{ openshift_logging_fluentd_remote_syslog_remove_tag_prefix }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_tag_key is defined %}\n        - name: REMOTE_SYSLOG_TAG_KEY\n          value: \"{{ openshift_logging_fluentd_remote_syslog_tag_key }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_use_record is defined %}\n        - name: REMOTE_SYSLOG_USE_RECORD\n          value: \"{{ openshift_logging_fluentd_remote_syslog_use_record }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_remote_syslog_payload_key is defined %}\n        - name: REMOTE_SYSLOG_PAYLOAD_KEY\n          value: \"{{ openshift_logging_fluentd_remote_syslog_payload_key }}\"\n{% endif %}\n\n{% if audit_container_engine %}\n        - name: \"AUDIT_CONTAINER_ENGINE\"\n          value: \"{{ audit_container_engine | lower }}\"\n{% endif %}\n\n{% if audit_container_engine %}\n        - name: \"NODE_NAME\"\n          valueFrom:\n            fieldRef:\n              fieldPath: spec.nodeName\n{% endif %}\n\n{% if audit_log_file != '' %}\n        - name: AUDIT_FILE\n          value: \"{{ audit_log_file }}\"\n{% endif %}\n\n{% if audit_pos_log_file != '' %}\n        - name: AUDIT_POS_FILE\n          value: \"{{ audit_pos_log_file }}\"\n{% endif %}\n\n        - name: \"MERGE_JSON_LOG\"\n          value: \"{{ openshift_logging_fluentd_merge_json_log }}\"\n\n{% if openshift_logging_fluentd_extra_keep_fields is defined %}\n        - name: CDM_EXTRA_KEEP_FIELDS\n          value: \"{{ openshift_logging_fluentd_extra_keep_fields }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_keep_empty_fields is defined %}\n        - name: CDM_KEEP_EMPTY_FIELDS\n          value: \"{{ openshift_logging_fluentd_keep_empty_fields }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_use_undefined is defined %}\n        - name: CDM_USE_UNDEFINED\n          value: \"{{ openshift_logging_fluentd_use_undefined }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_undefined_name is defined %}\n        - name: CDM_UNDEFINED_NAME\n          value: \"{{ openshift_logging_fluentd_undefined_name }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_undefined_to_string is defined %}\n        - name: CDM_UNDEFINED_TO_STRING\n          value: \"{{ openshift_logging_fluentd_undefined_to_string }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_undefined_dot_replace_char is defined %}\n        - name: CDM_UNDEFINED_DOT_REPLACE_CHAR\n          value: \"{{ openshift_logging_fluentd_undefined_dot_replace_char }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_undefined_max_num_fields is defined %}\n        - name: CDM_UNDEFINED_MAX_NUM_FIELDS\n          value: \"{{ openshift_logging_fluentd_undefined_max_num_fields }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_use_multiline_json is defined %}\n        - name: USE_MULTILINE_JSON\n          value: \"{{ openshift_logging_fluentd_use_multiline_json }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_use_multiline_journal is defined %}\n        - name: USE_MULTILINE_JOURNAL\n          value: \"{{ openshift_logging_fluentd_use_multiline_journal }}\"\n\n{% if openshift_logging_fluentd_refresh_interval is defined %}\n        - name: CONTAINER_LOGS_REFRESH_INTERVAL\n          value: \"{{ openshift_logging_fluentd_refresh_interval }}\"\n{% endif %}\n\n{% if openshift_logging_fluentd_rotate_wait is defined %}\n        - name: CONTAINER_LOGS_ROTATE_WAIT\n          value: \"{{ openshift_logging_fluentd_rotate_wait }}\"\n{% endif %}\n\n      volumes:\n      - name: runlogjournal\n        hostPath:\n          path: /run/log/journal\n      - name: varlog\n        hostPath:\n          path: /var/log\n      - name: varlibdockercontainers\n        hostPath:\n          path: /var/lib/docker\n      - name: config\n        configMap:\n          name: logging-fluentd\n      - name: certs\n        secret:\n          secretName: logging-fluentd\n      - name: dockerhostname\n        hostPath:\n          path: /etc/hostname\n      - name: localtime\n        hostPath:\n          path: /etc/localtime\n      - name: dockercfg\n        hostPath:\n          path: /etc/sysconfig/docker\n      - name: originnodecfg\n        hostPath:\n          path: /etc/origin/node\n      - name: dockerdaemoncfg\n        hostPath:\n          path: /etc/docker\n{% if openshift_logging_mux_client_mode is defined and\n     ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or\n      (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %}\n      - name: muxcerts\n        secret:\n          secretName: logging-mux\n{% endif %}\n      - name: filebufferstorage\n        hostPath:\n          path: \"/var/lib/fluentd\"\n      tolerations:\n      - operator: \"Exists\"\n\n"}
Additional Information
diff --git a/roles/openshift_logging_fluentd/templates/fluentd.j2 b/roles/openshift_logging_fluentd/templates/fluentd.j2
index ef16a0c05..1475516ad 100644
--- a/roles/openshift_logging_fluentd/templates/fluentd.j2
+++ b/roles/openshift_logging_fluentd/templates/fluentd.j2
@@ -265,6 +265,7 @@ spec:
 {% if openshift_logging_fluentd_use_multiline_journal is defined %}
         - name: USE_MULTILINE_JOURNAL
           value: "{{ openshift_logging_fluentd_use_multiline_journal }}"
+{% endif %}
 
 {% if openshift_logging_fluentd_refresh_interval is defined %}
         - name: CONTAINER_LOGS_REFRESH_INTERVAL

I see this is fixed now in #12029