ansible-collections / community.rabbitmq

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

community.rabbitmq.rabbitmq_user - For Remote URL, Username/Password #152

Open mohammedazfar-sanuk opened 1 year ago

mohammedazfar-sanuk commented 1 year ago
SUMMARY

To Add user in the Remote Rabbitmq, community.rabbitmq.rabbitmq_user didnt have options need some help.

ISSUE TYPE
COMPONENT NAME

community.rabbitmq.rabbitmq_user

ANSIBLE VERSION
2.13.6
Im0 commented 1 year ago

Hello @mohammedazfar-sanuk , I wasn't quite sure what you were trying to do. Which options were missing? Did you see https://docs.ansible.com/ansible/latest/collections/community/rabbitmq/rabbitmq_user_module.html ?

What would you like to see in that documentation? Is there missing functionality?

macbash commented 1 year ago

@Im0 - thanks for your comments, if you the https://docs.ansible.com/ansible/latest/collections/community/rabbitmq/rabbitmq_user_module.html there is no option to specify the remote rabbitmq URL, is there any option is there ?

macbash commented 1 year ago

means its missing login_host, login_port, loging_protocol

oneoneonepig commented 10 months ago

Some of the modules uses rabbitmqctl (such as rabbitmq_user, which seems to connect locally only)

Some other uses HTTP API (such as rabbitmq_binding), and in those you can specify remote rabbitmq endpoints.

# https://github.com/ansible-collections/community.rabbitmq/blob/146b006de99112e1abb5c2be0c4f2bcc8d6c3a5f/plugins/modules/rabbitmq_user.py#L285-L312
    def _exec(self, args, check_rc=True):
        """Execute a command using the `rabbitmqctl` utility.

        By default the _exec call will cause the module to fail, if the error code is non-zero. If the `check_rc`
        flag is set to False, then the exit_code, stdout and stderr will be returned to the calling function to
        perform whatever error handling it needs.

        :param args: the arguments to pass to the `rabbitmqctl` utility
        :param check_rc: when set to True, fail if the utility's exit code is non-zero
        :return: the output of the command or all the outputs plus the error code in case of error
        """
        cmd = [self._rabbitmqctl, '-q']
        if self.node:
            cmd.extend(['-n', self.node])
        rc, out, err = self.module.run_command(cmd + args)
        if check_rc and rc != 0:
            # check_rc is not passed to the `run_command` method directly to allow for more fine grained checking of
            # error messages returned by `rabbitmqctl`.
            user_error_msg_regex = r"(Only root or .* .* run rabbitmqctl)"
            user_error_msg = re.search(user_error_msg_regex, out)
            if user_error_msg:
                self.module.fail_json(msg="Wrong user used to run the `rabbitmqctl` utility: {err}"
                                      .format(err=user_error_msg.group(1)))
            else:
                self.module.fail_json(msg="rabbitmqctl exited with non-zero code: {err}".format(err=err),
                                      rc=rc, stdout=out)
        return out if check_rc else (rc, out, err)
Learloj commented 5 months ago

We have a similar issue; we use a SaaS solution for RabbitMQ (via CloudAMQP) and we currently cannot ie. manage users using this Ansible collection. It would be nice if it would support remote configuration using the Management Plugin and its API.

Learloj commented 5 months ago

I think this is actually a duplicate of https://github.com/ansible-collections/community.rabbitmq/issues/76