Repository: ansible/ansible-modules-extras

Issue:
Jira modules failes with "dictionary update sequence element #0 has length 1; 2 is required" in Ansible 2.0.2.0
<!--- Verify first that your issue/request is not already reported in GitHub -->
##### ISSUE TYPE

<!--- Pick one below and delete the rest: -->

Bug Report
##### COMPONENT NAME

<!--- Name of the plugin/module/task -->

Jira
##### ANSIBLE VERSION

<!--- Paste verbatim output from “ansible --version” between quotes below -->

```
ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
##### OS / ENVIRONMENT

<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->
##### SUMMARY

<!--- Explain the problem briefly -->

Using the jira module with Ansible 2.1.0.0 results in the following error message:

```
dictionary update sequence element #0 has length 1; 2 is required
```

Playbooks worked with Ansible 2.0.2.0
##### STEPS TO REPRODUCE

<!---
For bugs, show exactly how to reproduce the problem.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->

```
- hosts: xxxx

  tasks:
  - name: (JIRA) Sample ansible issue
    jira: description=something issuetype=Bug operation=create password=XXXX project=xxx summary=test uri=https://hostname.com username=XXX
```

<!--- You can also paste gist.github.com links for larger files -->
##### EXPECTED RESULTS

<!--- What did you expect to happen when running the steps above? -->
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with high verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->

```

```



Discussion:
<!-- @tuabache: Thanks for filing this bug report! -->

@tarka ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->

@tarka, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@tarka, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@tuabache For what it's worth, I had to change the syntax to yaml style key: value instead of the key=value pair syntax following migration to ansble 2.x - please could you try changing your playbook syntax too?

Proposed Fix:

change

`# Merge in any additional or overridden fields
    if params['fields']:
        createfields.update(params['fields'])
`

to

`# Merge in any additional or overridden fields
    if params['fields']:
        createfields.update(ast.literal_eval(params['fields']))
`

You also need to `import ast`

It's something to do with params['fields'] being a string and needs to be a python dict.

Tested and working on:
- ansible 2.1.1.0
- Python 2.6.6

Test case:

```
  - name: "Create a task"
    jira:
      uri: "{{server}}"
      username: "{{user}}"
      password: "{{pass}}"
      project: "{{project}}"
      operation: "create"
      summary: "Ansible Example Issue"
      description: "Created using Ansible"
      issuetype: "Task"
      fields:
        labels:
          - "autocreated"
          - "ansible"
          - "yaml"
        components:
          - name: "Linux Server"
          - name: "Linux Desktop"
        priority:
          name: "Trivial"
        fixVersions:
          - name: "rhel6.7-1.0"
          - name: "rhel7.2-1.0"

```

@tarka, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

@mohclips See also https://github.com/ansible/ansible-modules-extras/pull/2601

After reinstalling version 1.9.3 I got following more descriptive error:
ERROR: /home/tomask/ansible/group_vars/laptops must be stored as a dictionary/hash
- which clearly points to the file where it cannot parse: varName=varValue
- changing the var definition to: varName: varValue fixes the problem

versus: in 2.0.2 all the way to 2.1.2
ERROR! Unexpected Exception: dictionary update sequence element #0 has length 1; 2 is required

@tarka, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

Just used @mohclips proposed fix, which works great.. 

I believe the appropriate fix here is to appropriately designate the variable type in the module argument spec. Preparing a PR with the change now...


Resolving patch:
diff --git a/web_infrastructure/jira.py b/web_infrastructure/jira.py
--- a/web_infrastructure/jira.py
+++ b/web_infrastructure/jira.py
@@ -311,7 +311,7 @@ def main():
             comment=dict(),
             status=dict(),
             assignee=dict(),
-            fields=dict(default={})
+            fields=dict(default={}, type='dict')
         ),
         supports_check_mode=False
     )


Test patch: