Repository: ansible/ansible

Issue:
tower_user set organisation field has no effect.  
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
module: tower_user

##### ANSIBLE VERSION
```
ansible 2.3.0.0
  config file = /Users/xxxxxxx/.ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Mar  3 2017, 11:49:06) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
```

- Tower CLI 3.1.3
- Tower 3.1.3
- Tower 3.03

##### CONFIGURATION
N/A

##### OS / ENVIRONMENT
Ansible : OSX El Capitan 
Tower 3.1 : RHEL7.3
Tower 3.0 : RHEL 6.6

##### SUMMARY
The tower-user module suggests that when adding a user it should be added to an organisation when the organization option is set on the task : "Organization the user should be made a member of."  This fails and user is not made a member of the specified organisation.  

##### STEPS TO REPRODUCE
```
- hosts: localhost
  gather_facts: false

  tasks:
    - name: create the tower orgs
      tower_organization:
        name: project2
        description: "Org for Project2"
        state: present
        tower_config_file: "./tower_cli_data/192.168.133.153.cfg"
        
    - name: create the users
      tower_user:
        organization: project2
        username: testuser
        password: password
        email: user@example.com
        first_name: Testy
        last_name: McTestFace
        state: present
        tower_config_file: "./tower_cli_data/192.168.133.153.cfg"
```

##### EXPECTED RESULTS
testuser should be a member of organization project2

##### ACTUAL RESULTS
testuser exists and can login but is not a member of any organisations 



Discussion:
It looks like the organization field doesn't exist in the tower_cli function here : https://github.com/ansible/tower-cli/blob/c5d246a1bfa5dcc56f716c7d5b0cac8acb4ad7cd/tower_cli/resources/user.py

This might just be a documentation bug and need removing, if so I can prepare a pull request to remove the organization field from the documentation and calling code. 
cc @ghjm @jlaska @matburt @wwitzel3
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Users are no longer directly associated with organizations and must be given the `member` role.
You can use the `tower_role` module to perform this action.

```
- name: Add testuser to project2 org
  tower_role:
    user: testuser
    organization: project2
    role: member
```
Marvellous, thank you @wwitzel3, is organisation there to support older versions of Tower?   Either way, thanks for the solution.  
Yeah, that documentation line needs to be removed, it was mistaken added by me when copying parameters from an older version of Tower CLI.

Resolving patch:
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
@@ -54,11 +54,6 @@
         - Password of the user.
       required: False
       default: null
-    organization:
-      description:
-        - Organization the user should be made a member of.
-      required: False
-      default: null
     superuser:
       description:
         - User is a system wide administator.
@@ -149,7 +144,6 @@ def main():
             last_name=dict(),
             password=dict(no_log=True),
             email=dict(required=True),
-            organization=dict(),
             superuser=dict(type='bool', default=False),
             auditor=dict(type='bool', default=False),
             tower_host=dict(),
@@ -170,7 +164,6 @@ def main():
     last_name = module.params.get('last_name')
     password = module.params.get('password')
     email = module.params.get('email')
-    organization = module.params.get('organization')
     superuser = module.params.get('superuser')
     auditor = module.params.get('auditor')
     state = module.params.get('state')
@@ -184,8 +177,8 @@ def main():
         try:
             if state == 'present':
                 result = user.modify(username=username, first_name=first_name, last_name=last_name,
-                                     email=email, password=password, organization=organization,
-                                     is_superuser=superuser, is_auditor=auditor, create_on_missing=True)
+                                     email=email, password=password, is_superuser=superuser,
+                                     is_auditor=auditor, create_on_missing=True)
                 json_output['id'] = result['id']
             elif state == 'absent':
                 result = user.delete(username=username)


Test patch: