<div dir="ltr">Hi all,<div><br></div><div>I have posted already in the IRC, but wanted to have a broader discussion with responses tracking.</div><div><br></div><div>When I am using apb-base:canary and try to create configMap reading description content from template and passing it to k8s module (how it is currently done in the prostgresql-apb) with the value of a specific key being taken completely from variable ansible corrupts it randomly replacing line breaks with a text '\n'. What worse, this happens not vor every value. I was not able to figure out what is the deciding factor here.</div><div><br></div><div>Example (templates/zuul_config.yaml):</div><div>```</div><div><div>- kind: ConfigMap</div><div>  apiVersion: v1</div><div>  metadata:</div><div>    name: "zuul-config"</div><div>    namespace: "{{ namespace }}"</div><div>  data:</div><div>    zuul_base_revision: {{ zuul_base_revision }}</div><div><br></div><div>    zuul.conf: |+</div><div>      {{ zuul_zuul_conf | indent(6, false) }}</div><div><br></div><div>    main.yaml: |+</div><div>      {{ zuul_main_yaml | indent(6, false) }}</div><div><br></div><div>    logging.conf: |+</div><div>      {{ zuul_logging_conf | indent(6, false) }}</div><div><br></div><div>    variables.yaml: |+</div><div>      {{ zuul_variables_yaml | indent(6, false) }}</div></div><div>```</div><div><br></div><div>Here all the variables are being defined in defaults (or from APB parameters as pure multiline text).</div><div><br></div><div>This results in following (from `oc describe`):</div><div>```</div><div><div>apiVersion: v1</div><div>data:</div><div>  logging.conf: <font color="#ff0000">|+</font></div><div>    [loggers]</div><div>    keys=root,zuul,gear,kazoo</div><div><br></div><div>    [handlers]</div><div>    keys=console,debug,normal</div><div><br></div><div>    [formatters]</div><div>    keys=simple</div><div><br></div><div>    [logger_root]</div><div>    level=INFO</div><div>    handlers=console</div><div><br></div><div>    [logger_zuul]</div><div>    level=DEBUG</div><div>    handlers=debug,normal</div><div>    qualname=zuul</div><div><br></div><div>    [logger_gear]</div><div>    level=DEBUG</div><div>    handlers=debug,normal</div><div>    qualname=gear</div><div><br></div><div>    [logger_kazoo]</div><div>    level=WARNING</div><div>    handlers=debug,normal</div><div>    qualname=kazoo</div><div><br></div><div>    [handler_console]</div><div>    level=INFO</div><div>    class=StreamHandler</div><div>    formatter=simple</div><div>    args=(sys.stdout,)</div><div><br></div><div>    [handler_debug]</div><div>    level=DEBUG</div><div>    class=logging.handlers.TimedRotatingFileHandler</div><div>    formatter=simple</div><div>    args=('/var/log/zuul/debug.log', 'midnight', 1, 30,)</div><div><br></div><div>    [handler_normal]</div><div>    level=INFO</div><div>    class=logging.handlers.TimedRotatingFileHandler</div><div>    formatter=simple</div><div>    args=('/var/log/zuul/zuul.log', 'midnight', 1, 30,)</div><div><br></div><div>    [formatter_simple]</div><div>    format=%(asctime)s %(levelname)s %(name)s: %(message)s</div><div>    datefmt=</div><div><br></div><div><br></div><div><br></div><div>  main.yaml: <font color="#ff0000">>-</font></div><div>    ---\n- tenant:\n    name: otc\n    source:\n      github:\n       </div><div>    config-projects:\n          - gtema/zuul-project-config\n       </div><div>    untrusted-projects:\n          - OpenTelekomCloud/zuul-jobs:\n             </div><div>    shadow: gtema/zuul-project-config\n          -</div><div>    OpenTelekomCloud/otc-zuul-jobs\n\n\n\n</div><div>  variables.yaml: '---\n# Optional site variables\n\n'</div><div>  zuul.conf: <font color="#ff0000">>-</font></div><div>    [gearman]\nserver=gearman\nssl_ca=/etc/ssl/gearman-client/root-ca.pem\nssl_cert=/etc/ssl/gearman-client/client.pem\nssl_key=/etc/ssl/gearman-client/client.key\n\n[gearman_server]\nstart=true\nssl_ca=/etc/ssl/gearman-server/root-ca.pem\nssl_cert=/etc/ssl/gearman-server/server.pem\nssl_key=/etc/ssl/gearman-server/server.key\nlog_config=/etc/zuul/logging.conf\n\n[zookeeper]\nhosts=zookeeper-0.zookeeper-svc\n\n[zuul]\npidfile=/var/run/zuul/zuul.pid\n\n[executor]\nlog_config=/etc/zuul/logging.conf\nprivate_key_file=/etc/zuul/ssl/ssh.pem\nfinger_port=7900\ntrusted_rw_paths=/var/log/zuul/zuul-logs\n#</div><div>    hostname=${EXECUTOR_HOSTNAME}\nvariables=/etc/zuul/variables/variables.yaml\n\n#</div><div>    [merger]\n#</div><div>    log_config=/etc/zuul/logging.conf\n\n[scheduler]\nlog_config=/etc/zuul/logging.conf\ntenant_config=/etc/zuul/main.yaml\n\n[web]\nstatus_url=https://${PUBLIC_HOST_NAME}/zuul/t/{<a href="http://tenant.name">tenant.name</a>}/status.html\nlog_config=/etc/zuul/logging.conf\nlisten_address=0.0.0.0\ngearman_server=gearman\nstatic_path=/opt/app-root/static_html\n\n[connection</div><div>    github]\ndriver=github\napp_id=11628\napp_key=/etc/zuul/ssl/github.pem\nwebhook_token=WZcstRtt2HowPt/xIbFDRjzvJ8sX8E0IWqu0aSa0Xkw=\n\n\n\n</div><div>  zuul_base_revision: 3.1.0</div><div>kind: ConfigMap</div><div>metadata:</div><div>  creationTimestamp: '2018-07-05T07:17:56Z'</div><div>  name: zuul-config</div><div>  namespace: zuul</div><div>  resourceVersion: '5146'</div><div>  selfLink: /api/v1/namespaces/zuul/configmaps/zuul-config</div><div>  uid: 8a2b901c-8023-11e8-95ab-5254009918b1</div></div><div>```</div><div><br></div><div>For ref, the template is being processed with the following ansible block (tasks/main.yaml):</div><div>```</div><div><div>- name: "set s2i state = {{ state }}"</div><div>  k8s:</div><div>    state: '{{ state }}'</div><div>    definition: "{{ item }}"</div><div>  when: use_s2i and cluster == 'openshift'</div><div>  with_items:</div><div>    - "{{ lookup('template', 'zuul_config.yaml') | from_yaml }}"</div></div><div>```</div><div><br></div><div>If you look - logging.conf maintains line breaks, while others not (this happens each time same). This would also happen if I define content in the template explicitly (not through variables).</div><div><br></div><div>The "nice" thing, if I use my own <b>apb-base </b>(forked from <b>canary</b>), which uses <b>stable-2.6</b> branch of ansible - the problem does not exist. There seems to be really ansible change in <b>devel</b> branch, which I was not able to nail down (do not even have time for that).</div><div><br></div><div>I would really appreciate if anyone have a look there and potentially also switch <b>apb-base:canary </b>from <b>devel</b> to <b>stable-2.6</b> branch, or finally switch <b>apb-base:latest</b> to ansible 2.6. I prefer the later, since releasing APB based on <b>devel</b> branches gives 0 stability.</div><div><br></div><div><br></div><div>Additional question (wrong channel, but still): does anyone have ideas, on how is it possible to improve the following ansible block:</div><div>```</div><div><div>- name: "Set general configs and secrets state={{ state }}"</div><div>  k8s:</div><div>    state: '{{ state }}'</div><div>    definition: "{{ item }}"</div><div>  with_items:</div><div>    - "{{ lookup('template', 'common_config.yaml') | from_yaml }}"</div><div>    - "{{ lookup('template', 'zuul_config.yaml') | from_yaml }}"</div><div>    - "{{ lookup('template', 'nodepool_config.yaml') | from_yaml }}"</div></div><div>```</div><div>I have multiple templates with particular elements for my complex application. So issue here, how can I pass list of templates to `lookup`? I can of course try to first read all elements with `set_fact`, group them and then process with k8s, but this is not really better than this.</div><div><br></div><div>Thanks a lot,</div><div>Artem</div></div>