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

[WIP] Add RabbitMQ users/vhosts #164

Closed
wants to merge 2 commits into from

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Sep 5, 2017

If rmq_users is defined, then the guest user is removed, and the provided users are added.

TODO:

  • Add test suite to test with rabbitmq auth enabled (probably one suite for all auth including mongo)
  • Be ok with increasing minimum ansible version to 2.4 (for urlsplit filter use in st2 module to extract user, vhost from st2_config.messaging.url).

TODO for #75 for RabbitMQ security:

  • Configure/Set username/password

To configure the host (in a separate PR) we will need to modify or template /etc/rabbitmq/rabbitmq.config (see: https://www.rabbitmq.com/networking.html#interfaces)

  • [-] Ensure we can configure host
  • [-] Services should run on 127.0.0.1 by default

Leave pw generation to the playbook user.

  • [-] If not explicitly set, passwords should be generated randomly and placed in st2.conf

@arm4b arm4b added the WIP label Sep 5, 2017
@arm4b arm4b self-assigned this Sep 5, 2017
Copy link
Member Author

@cognifloyd cognifloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running this on an ansible host with CentOS 6 is broken (the machine ansible runs from, not the target host of the playbook) because I used the map filter which is only available in Jinja2 2.7, but CentOS 6 has Jinja2 2.6.

I'm not sure how to accomplish what I did in Jinja 2.6. Can we require an upgrade to 2.7? Maybe using an RPM like https://centos.pkgs.org/6/puias-computational-x86_64/python27-jinja2-2.7.2-2.sdl6.noarch.rpm.html

state: absent
when:
- rmq_users|length > 0
- "'guest' not in rmq_users|map(attribute='user')"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map requires jinja 2.7

state: present
loop_control:
loop_var: rmq_vhost
with_items: "{{ lookup('flattened', rmq_users|map(attribute='permissions')|list ) | map(attribute='vhost')|list|unique }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map requires jinja2.7.

@cognifloyd cognifloyd mentioned this pull request Sep 6, 2017
4 tasks
@cognifloyd
Copy link
Member Author

Another option would be to require an extra play:

- hosts: localhost
  tasks:
    - name: Upgrade ansible host's Jinja2 when using RedHat 6
      when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6"
      pip:
        name: jinja2

@cognifloyd
Copy link
Member Author

rebased

@cognifloyd
Copy link
Member Author

To get that map like functionality, I could use json_query, but that would add a dep on jmespath.

@cognifloyd
Copy link
Member Author

So far, this only adds the ability to add the user, but the playbook user has to actually add it. So, to accomplish #75 for RabbitMQ, this needs to switch to adding the user by default, and make the host configurable. That's a much bigger change, but maybe then it'll actually get merged.

@cognifloyd
Copy link
Member Author

rebased

By default, we just use the guest user. But, this makes it possible to
add or remove vhosts and users from rabbitmq.

This requires fairly explicit rabbitmq configuration options.

Originally, this used a map filter to extract vhosts from the list of
users and check for guest in the list of users, but the map filter is
not available in EL6 with Jinja2 2.6, so we can't rely on using that
here. Instead of extracting vhosts, or checking the list of users to
determine whether or not to remove guest, we require explicit
configuration of users and vhosts.
This uses the urlsplit filter to extract user and vhost bits from:
st2_config.messaging.url

The urlsplit filter is only availble with ansible 2.4 and later, so
this will probably need to wait until ready to increase the minimum.

[skip ci] until we're ready to revisit this.
@cognifloyd cognifloyd changed the title Add RabbitMQ users/vhosts [WIP] Add RabbitMQ users/vhosts Sep 22, 2018
@cognifloyd
Copy link
Member Author

Closing for now. Once there are resources to review something, I'll deal with it again.

@cognifloyd cognifloyd closed this Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants