Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

tower_credential

ANSIBLE VERSION

ansible 2.4.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/lmadsen/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.13 (default, Sep 5 2017, 08:53:59) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]

CONFIGURATION

DEFAULT_HOST_LIST(/home/lmadsen/src/github/leifmadsen/awx-builder/ansible.cfg) = [u'/home/lmadsen/src/github/leifmadsen/awx-builder/inventory']
HOST_KEY_CHECKING(/home/lmadsen/src/github/leifmadsen/awx-builder/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/lmadsen/src/github/leifmadsen/awx-builder/ansible.cfg) = False

OS / ENVIRONMENT

Fedora 26

SUMMARY

Use of the tower_credential module fails to post to the API

STEPS TO REPRODUCE

Run the following play against AWX and you'll be returned the following failure:

Sample play

- name: Configure SCM Credential
tower_credential:
name: Git
description: Git default credential
organization: null
kind: scm
tower_verify_ssl: False

EXPECTED RESULTS

No failure.

ACTUAL RESULTS

The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_GcQSWf/ansible_module_tower_credential.py", line 292, in <module>
main()
File "/tmp/ansible_GcQSWf/ansible_module_tower_credential.py", line 277, in main
result = credential.modify(**params)
File "/home/lmadsen/.local/lib/python2.7/site-packages/tower_cli/models/base.py", line 961, in modify
force_on_exists=True, **kwargs)
File "/home/lmadsen/.local/lib/python2.7/site-packages/tower_cli/models/base.py", line 345, in write
r = getattr(client, method.lower())(url, data=kwargs)
File "/home/lmadsen/.local/lib/python2.7/site-packages/requests/sessions.py", line 577, in patch
return self.request('PATCH', url, data=data, **kwargs)
File "/home/lmadsen/.local/lib/python2.7/site-packages/tower_cli/api.py", line 235, in request
kwargs.get('data', None), r.content.decode('utf8'))
tower_cli.exceptions.BadRequest: The Tower server claims it was sent a bad request.

PATCH http://awx.nfvpe.site/api/v1/credentials/6/
Params: None
Data: {"authorize": false, "state": "present", "description": "Git default credential", "kind": "scm", "name": "Git", "tower_verify_ssl": false}

Response: {"detail":["'state' is not a valid field for Source Control"]}

fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_GcQSWf/ansible_module_tower_credential.py\", line 292, in <module>\n main()\n File \"/tmp/ansible_GcQSWf/ansible_module_tower_credential.py\", line 277, in main\n result = credential.modify(**params)\n File \"/home/lmadsen/.local/lib/python2.7/site-packages/tower_cli/models/base.py\", line 961, in modify\n force_on_exists=True, **kwargs)\n File \"/home/lmadsen/.local/lib/python2.7/site-packages/tower_cli/models/base.py\", line 345, in write\n r = getattr(client, method.lower())(url, data=kwargs)\n File \"/home/lmadsen/.local/lib/python2.7/site-packages/requests/sessions.py\", line 577, in patch\n return self.request('PATCH', url, data=data, **kwargs)\n File \"/home/lmadsen/.local/lib/python2.7/site-packages/tower_cli/api.py\", line 235, in request\n kwargs.get('data', None), r.content.decode('utf8'))\ntower_cli.exceptions.BadRequest: The Tower server claims it was sent a bad request.\n\nPATCH http://awx.nfvpe.site/api/v1/credentials/6/\nParams: None\nData: {\"authorize\": false, \"state\": \"present\", \"description\": \"Git default credential\", \"kind\": \"scm\", \"name\": \"Git\", \"tower_verify_ssl\": false}\n\nResponse: {\"detail\":[\"'state' is not a valid field for Source Control\"]}\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

tower_credential

tower_*

ANSIBLE VERSION

ansible 2.4.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/notting/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.13 (default, Sep 5 2017, 08:53:59) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]

CONFIGURATION

ANSIBLE_SSH_PIPELINING(/etc/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30

OS / ENVIRONMENT

Fedora 26

SUMMARY

With tower_cli 3.2.0 installed, assorted Tower modules fail:

[notting@nostromo: ~]$ ansible -m tower_credential localhost -a "kind=ssh username=wow password=wow name=frobozznicate organization=TGP"
[WARNING]: Could not match supplied host pattern, ignoring: all

[WARNING]: provided hosts list is empty, only localhost is available

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: tower_cli.exceptions.BadRequest: Missing required fields: credential-type
localhost | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_imDa8H/ansible_module_tower_credential.py\", line 292, in <module>\n main()\n File \"/tmp/ansible_imDa8H/ansible_module_tower_credential.py\", line 277, in main\n result = credential.modify(**params)\n File \"/usr/lib/python2.7/site-packages/tower_cli/models/base.py\", line 659, in modify\n return self.write(pk, create_on_missing=create_on_missing, force_on_exists=True, **kwargs)\n File \"/usr/lib/python2.7/site-packages/tower_cli/models/base.py\", line 357, in write\n raise exc.BadRequest('Missing required fields: %s' % ', '.join(missing_fields).replace('_', '-'))\ntower_cli.exceptions.BadRequest: Missing required fields: credential-type\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}

STEPS TO REPRODUCE

see above

EXPECTED RESULTS

works

ACTUAL RESULTS

attempts to use /api/v1 parameters from 3.1 and earlier with tower-cli 3.2's /api/v2 usage. Things go kablooie.