ansible-collections / community.rabbitmq

Manage RabbitMQ with Ansible
http://galaxy.ansible.com/community/rabbitmq
Other
30 stars 46 forks source link

Define Default Action Group #157

Open wandersonwhcr opened 1 year ago

wandersonwhcr commented 1 year ago
SUMMARY

This PR defines an action group for all collection modules.

When same module is frequently called with same arguments, we can use module_defaults to avoid duplications. Since Ansible 2.7, we can group modules that share common sets of parameters. And since ansible-core 2.12, collections can define its own groups via action_groups on runtime.yml.

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_module_defaults.html

ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION

Before:

# playbook.yaml
- name: rabbitmq
  hosts: all
  module_defaults:
    community.rabbitmq.rabbitmq_exchanges:
      login_user: "admin"
      login_password: "admin"
    community.rabbitmq.rabbitmq_queues:
      login_user: "admin"
      login_password: "admin"
    # ...
  roles:
    - "exchanges"
    - "queues"

After:

# playbook.yaml
- name: rabbitmq
  hosts: all
  module_defaults:
    group/rabbitmq:
      login_user: "admin"
      login_password: "admin"
  roles:
    - "exchanges"
    - "queues"
csmart commented 5 months ago

hi @wandersonwhcr thanks for this contribution! I'm wondering whether the group can be set to rabbitmq rather than the FQDN? If so, this might make it a little more clean?

wandersonwhcr commented 4 months ago

Hi @csmart! Of course!

Changed as requested.

But I think these pipeline errors are not caused because of my changes.