mirror of https://github.com/ansible/ansible.git
Integration tests for rabbitmq_user module (#35421)
parent
b9c5147be2
commit
b9571eb4bf
@ -0,0 +1,5 @@
|
|||||||
|
destructive
|
||||||
|
posix/ci/group1
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
skip/rhel
|
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- setup_rabbitmq
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- include: tests.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu'
|
@ -0,0 +1,137 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Test add user in check mode
|
||||||
|
block:
|
||||||
|
- name: Add user
|
||||||
|
rabbitmq_user: user=joe password=changeme
|
||||||
|
check_mode: true
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that user adding succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == true
|
||||||
|
|
||||||
|
- name: Test add user
|
||||||
|
block:
|
||||||
|
- name: Add user
|
||||||
|
rabbitmq_user: user=joe password=changeme
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that user adding succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == true
|
||||||
|
|
||||||
|
- name: Test add user idempotence
|
||||||
|
block:
|
||||||
|
- name: Add user
|
||||||
|
rabbitmq_user: user=joe password=changeme
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that user adding succeeds without a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == false
|
||||||
|
|
||||||
|
- name: Test change user permissions in check mode
|
||||||
|
block:
|
||||||
|
- name: Add user with permissions
|
||||||
|
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.*
|
||||||
|
check_mode: true
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that changing permissions succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == true
|
||||||
|
|
||||||
|
- name: Test change user permissions
|
||||||
|
block:
|
||||||
|
- name: Add user with permissions
|
||||||
|
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.*
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that changing permissions succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == true
|
||||||
|
|
||||||
|
- name: Test change user permissions idempotence
|
||||||
|
block:
|
||||||
|
- name: Add user with permissions
|
||||||
|
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.*
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that changing permissions succeeds without a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == false
|
||||||
|
|
||||||
|
- name: Test add user tags in check mode
|
||||||
|
block:
|
||||||
|
- name: Add user with tags
|
||||||
|
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.* tags=management,administrator
|
||||||
|
check_mode: true
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that adding tags succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == true
|
||||||
|
|
||||||
|
- name: Test add user tags
|
||||||
|
block:
|
||||||
|
- name: Add user with tags
|
||||||
|
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.* tags=management,administrator
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that adding tags succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == true
|
||||||
|
|
||||||
|
- name: Test add user tags idempotence
|
||||||
|
block:
|
||||||
|
- name: Add user with tags
|
||||||
|
rabbitmq_user: user=joe password=changeme vhost=/ configure_priv=.* read_priv=.* write_priv=.* tags=administrator,management
|
||||||
|
register: add_user
|
||||||
|
|
||||||
|
- name: Check that adding tags succeeds without a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- add_user.changed == false
|
||||||
|
|
||||||
|
- name: Test remove user in check mode
|
||||||
|
block:
|
||||||
|
- name: Remove user
|
||||||
|
rabbitmq_user: user=joe state=absent
|
||||||
|
check_mode: true
|
||||||
|
register: remove_user
|
||||||
|
|
||||||
|
- name: Check that user removing succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- remove_user.changed == true
|
||||||
|
|
||||||
|
- name: Test remove user
|
||||||
|
block:
|
||||||
|
- name: Remove user
|
||||||
|
rabbitmq_user: user=joe state=absent
|
||||||
|
register: remove_user
|
||||||
|
|
||||||
|
- name: Check that user removing succeeds with a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- remove_user.changed == true
|
||||||
|
|
||||||
|
- name: Test remove user idempotence
|
||||||
|
block:
|
||||||
|
- name: Remove user
|
||||||
|
rabbitmq_user: user=joe state=absent
|
||||||
|
register: remove_user
|
||||||
|
|
||||||
|
- name: Check that user removing succeeds without a change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- remove_user.changed == false
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- include: ubuntu.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu'
|
@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install https transport for apt
|
||||||
|
apt: name=apt-transport-https state=latest force=yes
|
||||||
|
|
||||||
|
- name: Add Erlang Solutions public GPG key
|
||||||
|
apt_key: url=https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc state=present
|
||||||
|
|
||||||
|
- name: Add Erlang Solutions repository
|
||||||
|
apt_repository: repo="deb https://packages.erlang-solutions.com/ubuntu {{ ansible_distribution_release }} contrib" filename='erlang-solutions' state=present update_cache=yes
|
||||||
|
|
||||||
|
- name: Add RabbitMQ public GPG key
|
||||||
|
apt_key: url=https://www.rabbitmq.com/rabbitmq-release-signing-key.asc state=present
|
||||||
|
|
||||||
|
- name: Add RabbitMQ repository
|
||||||
|
apt_repository: repo='deb https://dl.bintray.com/rabbitmq/debian {{ ansible_distribution_release }} main' filename='rabbitmq' state=present update_cache=yes
|
||||||
|
|
||||||
|
- name: Install RabbitMQ Server
|
||||||
|
apt: name=rabbitmq-server state=latest
|
||||||
|
|
||||||
|
- name: Start RabbitMQ service
|
||||||
|
service: name=rabbitmq-server state=started
|
||||||
|
when: ansible_distribution_release == 'trusty'
|
||||||
|
|
||||||
|
# This is an ugly workaround!
|
||||||
|
# There is a problem to run services via systemd inside docker containers (https://github.com/moby/moby/issues/2296):
|
||||||
|
# systemctl command fails with the error 'Failed to connect to bus: No such file or directory'
|
||||||
|
- name: Start RabbitMQ service
|
||||||
|
command: /etc/init.d/rabbitmq-server start
|
||||||
|
when: ansible_distribution_release == 'xenial'
|
Loading…
Reference in New Issue