Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for erlang atom configuration values #1

Open
tedgin opened this issue Oct 7, 2015 · 2 comments
Open

support for erlang atom configuration values #1

tedgin opened this issue Oct 7, 2015 · 2 comments

Comments

@tedgin
Copy link
Contributor

tedgin commented Oct 7, 2015

The auth_backends configuration value expects a list of erlang atoms. e.g. rabbit_auth_backend_internal, rabbit_auth_backend_ldap, etc. When attempting to use this role to define the auth_backends configuration value, it encodes the atoms in the list as strings.

Pretend this is our playbook.


---
- hosts: amqp-brokers
  roles:
     - role: jtyr.rabbitmq
       rabbitmq_config:
          - rabbit:
               - auth_backends:
                    - rabbit_auth_backend_internal

When run, this generates the following rabbitmq.config file.

%%
%% This file is managed by Ansible.
%% Do not edit this file manually.
%% Any changes will be automatically reverted.
%%

[
  {rabbit, [
      {auth_backends, [
        "rabbit_auth_backend_internal"
      ]}
  ]}
].

The quoted "rabbit_auth_backend_internal" names causes authentication to error out.

Please add support to this role for atom configuration values.

I would be willing to help out with this, if you want. I suspect this will require some of encoding hint being needed in the playbook to tell the encoder that the relevant value is an atom and not a string.

@jtyr
Copy link
Contributor

jtyr commented Oct 7, 2015

Thanks for reporting this issue. The solution requires to enhance the erlang macro:

--- a/macros/erlang_encode_macro.j2
+++ b/macros/erlang_encode_macro.j2
@@ -51,7 +51,11 @@
   {%- elif item is string %}
     {#- The item is a string -#}

-    {{ '"' ~ item ~ '"' }}
+    {%- if item[0] == ':' -%}
+      {{ item[1:] }}
+    {%- else -%}
+      {{ '"' ~ item ~ '"' }}
+    {%- endif -%}

   {%- else %}
     {#- The item is a list -#}

Then if you add : at the beginning of the rabbit_auth_backend_internal it shouldn't quote it.

Please let me know if that works for you and I will submit a pull request for the erlang macro.

@tedgin
Copy link
Contributor Author

tedgin commented Oct 8, 2015

That works well for me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants