We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
rabbitmq_parameter fails when passing dynamically generated json
##### Issue Type:

“Bug Report”
##### Ansible Version:

ansible 1.8.2
  configured module search path = None

Tested also on ansible 1.9
ansible 1.9 (devel 8f06ba2bc1) last updated 2015/02/05 11:16:37 (GMT +200)
  lib/ansible/modules/core: (detached HEAD 600fc15b42) last updated 2015/02/05 11:16:50 (GMT +200)
  lib/ansible/modules/extras: (detached HEAD 77485f6c6a) last updated 2015/02/05 11:17:01 (GMT +200)
  v2/ansible/modules/core: (detached HEAD 600fc15b42) last updated 2015/02/05 11:17:13 (GMT +200)
  v2/ansible/modules/extras: (detached HEAD 77485f6c6a) last updated 2015/02/05 11:17:36 (GMT +200)
  configured module search path = None
##### Environment:

OS X 10.9.5 > Ubuntu 14.04
##### Summary:

Passing non-hardcoded json (through templating) to rabbitmq_parameter's "value" argument raises an exception. It works when hardcoding the json though.
##### Steps To Reproduce:

Here's an example playbook with one successful task (the first one), and two failing tasks (the next two) which both raise the same exception (see below). All of them are supposed to do the same thing.

```
- hosts: my-host
  tasks:
        - set_fact:
              upstream_list:
                    - upstream: "test"
                    - upstream: "test2"
              json_upstreams: '[{"upstream":"test1"},{"upstream":"test2"}]'

        - rabbitmq_parameter:
              component: federation-upstream-set
              name: test-upstream-set
              value: '[{"upstream":"test1"},{"upstream":"test2"}]'
           sudo: yes

        - rabbitmq_parameter:
              component: federation-upstream-set
              name: test-upstream-set
              value: '{{ json_upstreams }}'
           sudo: yes

        - rabbitmq_parameter:
              component: federation-upstream-set
              name: test-upstream-set
              value: '{{ upstream_list|to_json }}'
           sudo: yes
```
##### Expected Results:

Set a federation-upstream-set parameter to the default vhost.
##### Actual Results:

The two failing tasks raise the same exception. The output from ansible with -vvvv is as follows:

```
<my-host> ESTABLISH CONNECTION FOR USER: xxxx
<my-host> REMOTE_MODULE rabbitmq_parameter name=test-upstream-set component=federation-upstream-set vhost=/
<my-host> EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o     ControlPersist=30m -o ControlPath="xxxx/.ansible/cp/ansible-ssh-%h-%p-%r" -o Port=22 -o     KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-k
eyex,hostbased,publickey -o PasswordAuthentication=no -o User=xxxx -o ConnectTimeout=10 my-    host /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=xxxxxx] password: " -u root /bin/sh -c         '"'"'echo SUDO-SUCCESS-xxxxxx; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python'"'"''
failed: [my-host] => {"failed": true, "parsed": false}
SUDO-SUCCESS-xxxxxx
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /xxxxx/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 58450
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
[sudo via ansible, key=xxxxx] password: Traceback (most recent call last):
  File "<stdin>", line 1717, in <module>
  File "<stdin>", line 142, in main
  File "<stdin>", line 104, in set
  File "<stdin>", line 88, in _exec
  File "<stdin>", line 1566, in run_command
  File "/usr/lib/python2.7/posixpath.py", line 261, in expanduser
    if not path.startswith('~'):
AttributeError: 'list' object has no attribute 'startswith'
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
```
##### Tentative solution:

From what I've seen while troubleshooting the issue, the problem comes from the rabbitmq_parameter module being passed a list to its "value" argument. It is then passed to AnsibleModule::run_command, which assumes it is a string and passes it through os.path.expanduser.
I've managed to correct this behavior by setting the value to `value if type(value) == str else json.dumps(value)`.
I can submit a more complete patch or pull request if this is indeed a bug and not an issue in my playbook.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `messaging/rabbitmq_parameter.py`
Content:
```
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 
4 # (c) 2013, Chatham Financial <oss@chathamfinancial.com>
5 #
6 # This file is part of Ansible
7 #
8 # Ansible is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Ansible is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
20 
21 DOCUMENTATION = '''
22 ---
23 module: rabbitmq_parameter
24 short_description: Adds or removes parameters to RabbitMQ
25 description:
26   - Manage dynamic, cluster-wide parameters for RabbitMQ
27 version_added: "1.1"
28 author: '"Chris Hoffman (@chrishoffman)"'
29 options:
30   component:
31     description:
32       - Name of the component of which the parameter is being set
33     required: true
34     default: null
35   name:
36     description:
37       - Name of the parameter being set
38     required: true
39     default: null
40   value:
41     description:
42       - Value of the parameter, as a JSON term
43     required: false
44     default: null
45   vhost:
46     description:
47       - vhost to apply access privileges.
48     required: false
49     default: /
50   node:
51     description:
52       - erlang node name of the rabbit we wish to configure
53     required: false
54     default: rabbit
55     version_added: "1.2"
56   state:
57     description:
58       - Specify if user is to be added or removed
59     required: false
60     default: present
61     choices: [ 'present', 'absent']
62 '''
63 
64 EXAMPLES = """
65 # Set the federation parameter 'local_username' to a value of 'guest' (in quotes)
66 - rabbitmq_parameter: component=federation
67                       name=local-username
68                       value='"guest"'
69                       state=present
70 """
71 
72 class RabbitMqParameter(object):
73     def __init__(self, module, component, name, value, vhost, node):
74         self.module = module
75         self.component = component
76         self.name = name
77         self.value = value
78         self.vhost = vhost
79         self.node = node
80 
81         self._value = None
82 
83         self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)
84 
85     def _exec(self, args, run_in_check_mode=False):
86         if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
87             cmd = [self._rabbitmqctl, '-q', '-n', self.node]
88             rc, out, err = self.module.run_command(cmd + args, check_rc=True)
89             return out.splitlines()
90         return list()
91 
92     def get(self):
93         parameters = self._exec(['list_parameters', '-p', self.vhost], True)
94 
95         for param_item in parameters:
96             component, name, value = param_item.split('\t')
97 
98             if component == self.component and name == self.name:
99                 self._value = value
100                 return True
101         return False
102 
103     def set(self):
104         self._exec(['set_parameter', '-p', self.vhost, self.component, self.name, self.value])
105 
106     def delete(self):
107         self._exec(['clear_parameter', '-p', self.vhost, self.component, self.name])
108 
109     def has_modifications(self):
110         return self.value != self._value
111 
112 def main():
113     arg_spec = dict(
114         component=dict(required=True),
115         name=dict(required=True),
116         value=dict(default=None),
117         vhost=dict(default='/'),
118         state=dict(default='present', choices=['present', 'absent']),
119         node=dict(default='rabbit')
120     )
121     module = AnsibleModule(
122         argument_spec=arg_spec,
123         supports_check_mode=True
124     )
125 
126     component = module.params['component']
127     name = module.params['name']
128     value = module.params['value']
129     vhost = module.params['vhost']
130     state = module.params['state']
131     node = module.params['node']
132 
133     rabbitmq_parameter = RabbitMqParameter(module, component, name, value, vhost, node)
134 
135     changed = False
136     if rabbitmq_parameter.get():
137         if state == 'absent':
138             rabbitmq_parameter.delete()
139             changed = True
140         else:
141             if rabbitmq_parameter.has_modifications():
142                 rabbitmq_parameter.set()
143                 changed = True
144     elif state == 'present':
145         rabbitmq_parameter.set()
146         changed = True
147 
148     module.exit_json(changed=changed, component=component, name=name, vhost=vhost, state=state)
149 
150 # import module snippets
151 from ansible.module_utils.basic import *
152 main()
153
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/messaging/rabbitmq_parameter.py b/messaging/rabbitmq_parameter.py
--- a/messaging/rabbitmq_parameter.py
+++ b/messaging/rabbitmq_parameter.py
@@ -126,6 +126,8 @@
     component = module.params['component']
     name = module.params['name']
     value = module.params['value']
+    if not isinstance(value, str):
+        value = json.dumps(value)
     vhost = module.params['vhost']
     state = module.params['state']
     node = module.params['node']

{"golden_diff": "diff --git a/messaging/rabbitmq_parameter.py b/messaging/rabbitmq_parameter.py\n--- a/messaging/rabbitmq_parameter.py\n+++ b/messaging/rabbitmq_parameter.py\n@@ -126,6 +126,8 @@\n     component = module.params['component']\n     name = module.params['name']\n     value = module.params['value']\n+    if not isinstance(value, str):\n+        value = json.dumps(value)\n     vhost = module.params['vhost']\n     state = module.params['state']\n     node = module.params['node']\n", "issue": "rabbitmq_parameter fails when passing dynamically generated json\n##### Issue Type:\n\n\u201cBug Report\u201d\n##### Ansible Version:\n\nansible 1.8.2\n  configured module search path = None\n\nTested also on ansible 1.9\nansible 1.9 (devel 8f06ba2bc1) last updated 2015/02/05 11:16:37 (GMT +200)\n  lib/ansible/modules/core: (detached HEAD 600fc15b42) last updated 2015/02/05 11:16:50 (GMT +200)\n  lib/ansible/modules/extras: (detached HEAD 77485f6c6a) last updated 2015/02/05 11:17:01 (GMT +200)\n  v2/ansible/modules/core: (detached HEAD 600fc15b42) last updated 2015/02/05 11:17:13 (GMT +200)\n  v2/ansible/modules/extras: (detached HEAD 77485f6c6a) last updated 2015/02/05 11:17:36 (GMT +200)\n  configured module search path = None\n##### Environment:\n\nOS X 10.9.5 > Ubuntu 14.04\n##### Summary:\n\nPassing non-hardcoded json (through templating) to rabbitmq_parameter's \"value\" argument raises an exception. It works when hardcoding the json though.\n##### Steps To Reproduce:\n\nHere's an example playbook with one successful task (the first one), and two failing tasks (the next two) which both raise the same exception (see below). All of them are supposed to do the same thing.\n\n```\n- hosts: my-host\n  tasks:\n        - set_fact:\n              upstream_list:\n                    - upstream: \"test\"\n                    - upstream: \"test2\"\n              json_upstreams: '[{\"upstream\":\"test1\"},{\"upstream\":\"test2\"}]'\n\n        - rabbitmq_parameter:\n              component: federation-upstream-set\n              name: test-upstream-set\n              value: '[{\"upstream\":\"test1\"},{\"upstream\":\"test2\"}]'\n           sudo: yes\n\n        - rabbitmq_parameter:\n              component: federation-upstream-set\n              name: test-upstream-set\n              value: '{{ json_upstreams }}'\n           sudo: yes\n\n        - rabbitmq_parameter:\n              component: federation-upstream-set\n              name: test-upstream-set\n              value: '{{ upstream_list|to_json }}'\n           sudo: yes\n```\n##### Expected Results:\n\nSet a federation-upstream-set parameter to the default vhost.\n##### Actual Results:\n\nThe two failing tasks raise the same exception. The output from ansible with -vvvv is as follows:\n\n```\n<my-host> ESTABLISH CONNECTION FOR USER: xxxx\n<my-host> REMOTE_MODULE rabbitmq_parameter name=test-upstream-set component=federation-upstream-set vhost=/\n<my-host> EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o     ControlPersist=30m -o ControlPath=\"xxxx/.ansible/cp/ansible-ssh-%h-%p-%r\" -o Port=22 -o     KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-k\neyex,hostbased,publickey -o PasswordAuthentication=no -o User=xxxx -o ConnectTimeout=10 my-    host /bin/sh -c 'sudo -k && sudo -H -S -p \"[sudo via ansible, key=xxxxxx] password: \" -u root /bin/sh -c         '\"'\"'echo SUDO-SUCCESS-xxxxxx; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python'\"'\"''\nfailed: [my-host] => {\"failed\": true, \"parsed\": false}\nSUDO-SUCCESS-xxxxxx\nOpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1: Reading configuration data /xxxxx/.ssh/config\ndebug1: Reading configuration data /etc/ssh_config\ndebug1: /etc/ssh_config line 20: Applying options for *\ndebug1: /etc/ssh_config line 102: Applying options for *\ndebug1: auto-mux: Trying existing master\ndebug2: fd 3 setting O_NONBLOCK\ndebug2: mux_client_hello_exchange: master version 4\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\ndebug3: mux_client_request_session: entering\ndebug3: mux_client_request_alive: entering\ndebug3: mux_client_request_alive: done pid = 58450\ndebug3: mux_client_request_session: session request sent\ndebug1: mux_client_request_session: master session id: 2\n[sudo via ansible, key=xxxxx] password: Traceback (most recent call last):\n  File \"<stdin>\", line 1717, in <module>\n  File \"<stdin>\", line 142, in main\n  File \"<stdin>\", line 104, in set\n  File \"<stdin>\", line 88, in _exec\n  File \"<stdin>\", line 1566, in run_command\n  File \"/usr/lib/python2.7/posixpath.py\", line 261, in expanduser\n    if not path.startswith('~'):\nAttributeError: 'list' object has no attribute 'startswith'\ndebug3: mux_client_read_packet: read header failed: Broken pipe\ndebug2: Received exit status from master 1\n```\n##### Tentative solution:\n\nFrom what I've seen while troubleshooting the issue, the problem comes from the rabbitmq_parameter module being passed a list to its \"value\" argument. It is then passed to AnsibleModule::run_command, which assumes it is a string and passes it through os.path.expanduser.\nI've managed to correct this behavior by setting the value to `value if type(value) == str else json.dumps(value)`.\nI can submit a more complete patch or pull request if this is indeed a bug and not an issue in my playbook.\n\n", "before_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# (c) 2013, Chatham Financial <oss@chathamfinancial.com>\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n\nDOCUMENTATION = '''\n---\nmodule: rabbitmq_parameter\nshort_description: Adds or removes parameters to RabbitMQ\ndescription:\n  - Manage dynamic, cluster-wide parameters for RabbitMQ\nversion_added: \"1.1\"\nauthor: '\"Chris Hoffman (@chrishoffman)\"'\noptions:\n  component:\n    description:\n      - Name of the component of which the parameter is being set\n    required: true\n    default: null\n  name:\n    description:\n      - Name of the parameter being set\n    required: true\n    default: null\n  value:\n    description:\n      - Value of the parameter, as a JSON term\n    required: false\n    default: null\n  vhost:\n    description:\n      - vhost to apply access privileges.\n    required: false\n    default: /\n  node:\n    description:\n      - erlang node name of the rabbit we wish to configure\n    required: false\n    default: rabbit\n    version_added: \"1.2\"\n  state:\n    description:\n      - Specify if user is to be added or removed\n    required: false\n    default: present\n    choices: [ 'present', 'absent']\n'''\n\nEXAMPLES = \"\"\"\n# Set the federation parameter 'local_username' to a value of 'guest' (in quotes)\n- rabbitmq_parameter: component=federation\n                      name=local-username\n                      value='\"guest\"'\n                      state=present\n\"\"\"\n\nclass RabbitMqParameter(object):\n    def __init__(self, module, component, name, value, vhost, node):\n        self.module = module\n        self.component = component\n        self.name = name\n        self.value = value\n        self.vhost = vhost\n        self.node = node\n\n        self._value = None\n\n        self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)\n\n    def _exec(self, args, run_in_check_mode=False):\n        if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):\n            cmd = [self._rabbitmqctl, '-q', '-n', self.node]\n            rc, out, err = self.module.run_command(cmd + args, check_rc=True)\n            return out.splitlines()\n        return list()\n\n    def get(self):\n        parameters = self._exec(['list_parameters', '-p', self.vhost], True)\n\n        for param_item in parameters:\n            component, name, value = param_item.split('\\t')\n\n            if component == self.component and name == self.name:\n                self._value = value\n                return True\n        return False\n\n    def set(self):\n        self._exec(['set_parameter', '-p', self.vhost, self.component, self.name, self.value])\n\n    def delete(self):\n        self._exec(['clear_parameter', '-p', self.vhost, self.component, self.name])\n\n    def has_modifications(self):\n        return self.value != self._value\n\ndef main():\n    arg_spec = dict(\n        component=dict(required=True),\n        name=dict(required=True),\n        value=dict(default=None),\n        vhost=dict(default='/'),\n        state=dict(default='present', choices=['present', 'absent']),\n        node=dict(default='rabbit')\n    )\n    module = AnsibleModule(\n        argument_spec=arg_spec,\n        supports_check_mode=True\n    )\n\n    component = module.params['component']\n    name = module.params['name']\n    value = module.params['value']\n    vhost = module.params['vhost']\n    state = module.params['state']\n    node = module.params['node']\n\n    rabbitmq_parameter = RabbitMqParameter(module, component, name, value, vhost, node)\n\n    changed = False\n    if rabbitmq_parameter.get():\n        if state == 'absent':\n            rabbitmq_parameter.delete()\n            changed = True\n        else:\n            if rabbitmq_parameter.has_modifications():\n                rabbitmq_parameter.set()\n                changed = True\n    elif state == 'present':\n        rabbitmq_parameter.set()\n        changed = True\n\n    module.exit_json(changed=changed, component=component, name=name, vhost=vhost, state=state)\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nmain()\n", "path": "messaging/rabbitmq_parameter.py"}], "after_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# (c) 2013, Chatham Financial <oss@chathamfinancial.com>\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n\nDOCUMENTATION = '''\n---\nmodule: rabbitmq_parameter\nshort_description: Adds or removes parameters to RabbitMQ\ndescription:\n  - Manage dynamic, cluster-wide parameters for RabbitMQ\nversion_added: \"1.1\"\nauthor: '\"Chris Hoffman (@chrishoffman)\"'\noptions:\n  component:\n    description:\n      - Name of the component of which the parameter is being set\n    required: true\n    default: null\n  name:\n    description:\n      - Name of the parameter being set\n    required: true\n    default: null\n  value:\n    description:\n      - Value of the parameter, as a JSON term\n    required: false\n    default: null\n  vhost:\n    description:\n      - vhost to apply access privileges.\n    required: false\n    default: /\n  node:\n    description:\n      - erlang node name of the rabbit we wish to configure\n    required: false\n    default: rabbit\n    version_added: \"1.2\"\n  state:\n    description:\n      - Specify if user is to be added or removed\n    required: false\n    default: present\n    choices: [ 'present', 'absent']\n'''\n\nEXAMPLES = \"\"\"\n# Set the federation parameter 'local_username' to a value of 'guest' (in quotes)\n- rabbitmq_parameter: component=federation\n                      name=local-username\n                      value='\"guest\"'\n                      state=present\n\"\"\"\n\nclass RabbitMqParameter(object):\n    def __init__(self, module, component, name, value, vhost, node):\n        self.module = module\n        self.component = component\n        self.name = name\n        self.value = value\n        self.vhost = vhost\n        self.node = node\n\n        self._value = None\n\n        self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)\n\n    def _exec(self, args, run_in_check_mode=False):\n        if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):\n            cmd = [self._rabbitmqctl, '-q', '-n', self.node]\n            rc, out, err = self.module.run_command(cmd + args, check_rc=True)\n            return out.splitlines()\n        return list()\n\n    def get(self):\n        parameters = self._exec(['list_parameters', '-p', self.vhost], True)\n\n        for param_item in parameters:\n            component, name, value = param_item.split('\\t')\n\n            if component == self.component and name == self.name:\n                self._value = value\n                return True\n        return False\n\n    def set(self):\n        self._exec(['set_parameter', '-p', self.vhost, self.component, self.name, self.value])\n\n    def delete(self):\n        self._exec(['clear_parameter', '-p', self.vhost, self.component, self.name])\n\n    def has_modifications(self):\n        return self.value != self._value\n\ndef main():\n    arg_spec = dict(\n        component=dict(required=True),\n        name=dict(required=True),\n        value=dict(default=None),\n        vhost=dict(default='/'),\n        state=dict(default='present', choices=['present', 'absent']),\n        node=dict(default='rabbit')\n    )\n    module = AnsibleModule(\n        argument_spec=arg_spec,\n        supports_check_mode=True\n    )\n\n    component = module.params['component']\n    name = module.params['name']\n    value = module.params['value']\n    if not isinstance(value, str):\n        value = json.dumps(value)\n    vhost = module.params['vhost']\n    state = module.params['state']\n    node = module.params['node']\n\n    rabbitmq_parameter = RabbitMqParameter(module, component, name, value, vhost, node)\n\n    changed = False\n    if rabbitmq_parameter.get():\n        if state == 'absent':\n            rabbitmq_parameter.delete()\n            changed = True\n        else:\n            if rabbitmq_parameter.has_modifications():\n                rabbitmq_parameter.set()\n                changed = True\n    elif state == 'present':\n        rabbitmq_parameter.set()\n        changed = True\n\n    module.exit_json(changed=changed, component=component, name=name, vhost=vhost, state=state)\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nmain()\n", "path": "messaging/rabbitmq_parameter.py"}]}