use of config_template plugin breaks ceilometer.conf

Bug #1542513 reported by Steve Lewis
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Fix Released
High
Kevin Carter

Bug Description

When overrides are applied to ceilometer.conf.j2 the various messaging_urls are not rendering into the resulting file, causing meters and events to not be collected.

ceilometer.conf relies on duplicate "messaging_urls" entries within the ini-format config file
(see https://github.com/openstack/openstack-ansible/blob/master/playbooks/roles/os_ceilometer/templates/ceilometer.conf.j2)

When an override is specified (using ceilometer_ceilometer_conf_overrides) these are munged when the merger function runs and the ini file entries are treated as a dict.

Related: http://stackoverflow.com/questions/30095471/configparser-duplicate-keys-in-python

Simplified Repro: https://gist.github.com/stevelle/cceb1f58617c20f44c7c
Contents of that gist included below but formatting will always fail

#bug.conf.j2
#{{ ansible_managed}}

[DEFAULT]
bug_is = multiple entries with the same key get collapsed to one entry

magic_phrases = abracadabra
magic_phrases = presto changeo

---
# bug_playbook.yml
- name: Demo config_template bug
  hosts: all
  tasks:
    - name: Apply config template after duplicate keys are produced
      config_template:
        src: "{{ item.src }}"
        dest: "{{ item.dest }}"
        config_overrides: "{{ item.config_overrides }}"
        config_type: "{{ item.config_type }}"
      with_items:
        - src: "bug.conf.j2"
          dest: "/tmp/output.conf"
          config_overrides: "{{ overrides }}"
          config_type: "ini"
  vars:
    overrides:
      foo:
        bar: baz

Tags: in-liberty
Revision history for this message
Steve Lewis (steve-lewis) wrote :

Many thanks to alextricity25 for helping to track this down

description: updated
Revision history for this message
Steve Lewis (steve-lewis) wrote :

This is a blocker for a Gnocchi role because the only alternative available to using config_template is to incorporate gnocchi-specific logic into the Ceilometer role's ceilometer.conf.j2 template to conditionally include gnocchi-specific configuration directives.

Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

This may resolve it for you? https://review.openstack.org/277579

Revision history for this message
Steve Lewis (steve-lewis) wrote :

That does not resolve this issue, as discussed on IRC.

Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

Fix proposed in master: https://review.openstack.org/278214

Changed in openstack-ansible:
assignee: nobody → Kevin Carter (kevin-carter)
status: New → Confirmed
importance: Undecided → High
milestone: none → mitaka-3
Changed in openstack-ansible:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-plugins (master)

Reviewed: https://review.openstack.org/278214
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-plugins/commit/?id=b42faff7848d4adbee2afc729e4f2d949eb1be87
Submitter: Jenkins
Branch: master

commit b42faff7848d4adbee2afc729e4f2d949eb1be87
Author: Kevin Carter <email address hidden>
Date: Tue Feb 9 23:54:16 2016 -0600

    Add MultiStrOps support to config_template

    This change adds the MultiStrOps variaable type to the config
    template parsing as well as supports multi string options when
    passing configuration overrides.

    This is made prossible by using the set type for options found within
    config overrides and creating a custom dictionary class that allows
    for multiple keys to be stored as a set. When the config_template
    encounters a set type it will process and reder value as a
    MultiStrOps.

    Set types are defined in yaml via the "?" entry.

    Example Overrides:
      things:
        - 1
        - 2
      multistrops_things:
        ? a
        ? b

    Example Rendered Config:
      things = 1,2
      multistrops_things = a
      multistrops_things = b

    Change-Id: I2193ea2eb7f839c3151c2c96f9dfe86f141e5a15
    Closes-Bug: #1542513
    Signed-off-by: Kevin Carter <email address hidden>

Changed in openstack-ansible:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible (liberty)

Fix proposed to branch: liberty
Review: https://review.openstack.org/325568

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible (liberty)

Reviewed: https://review.openstack.org/325568
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible/commit/?id=54f8ddfe9663cee93c7d939a541c39c679191735
Submitter: Jenkins
Branch: liberty

commit 54f8ddfe9663cee93c7d939a541c39c679191735
Author: Kevin Carter <email address hidden>
Date: Fri Jun 3 15:36:09 2016 -0500

    Add MultiStrOps support to config_template

    This change adds the MultiStrOps variaable type to the config
    template parsing as well as supports multi string options when
    passing configuration overrides.

    This is made prossible by using the set type for options found within
    config overrides and creating a custom dictionary class that allows
    for multiple keys to be stored as a set. When the config_template
    encounters a set type it will process and reder value as a
    MultiStrOps.

    Set types are defined in yaml via the "?" entry.

    Example Overrides:
      things:
        - 1
        - 2
      multistrops_things:
        ? a
        ? b

    Example Rendered Config:
      things = 1,2
      multistrops_things = a
      multistrops_things = b

    Change-Id: I59c3c14238242c61ca760d4235d94b3f775378e0
    Backport-Of: I2193ea2eb7f839c3151c2c96f9dfe86f141e5a15
    Closes-Bug: #1542513
    Signed-off-by: Kevin Carter <email address hidden>

tags: added: in-liberty
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/openstack-ansible 12.0.15

This issue was fixed in the openstack/openstack-ansible 12.0.15 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.