Repository: ansible/ansible

Issue:
s3_bucket error - Module_six_moves_urllib_parse object is not callable.
##### SUMMARY
When trying to create s3_bucket I'm getting an error.
This is a regression. Worked in ansible 2.4.
Might be related to:
https://github.com/ansible/ansible/issues/27566
https://github.com/ansible/ansible/pull/27568

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
s3_bucket

##### ANSIBLE VERSION
```
ansible 2.6.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
```

##### CONFIGURATION
I'm using python3:
inventories/production/hosts
```
[all:vars]
ansible_python_interpreter=/usr/bin/python3
```

##### OS / ENVIRONMENT
Ubuntu 18.04.

##### STEPS TO REPRODUCE
```yaml
- name: python3-botocore package
  apt:
    name: python3-botocore
    state: latest

- name: python3-boto package
  apt:
    name: python3-boto
    state: latest

- name: create bucket
  s3_bucket:
    name: mybucket
    state: present
    aws_access_key: "{{key}}"
    aws_secret_key: "{{secret}}"
    s3_url: "{{url}}"
    ceph: true
```

##### EXPECTED RESULTS
No error

##### ACTUAL RESULTS
```
Traceback (most recent call last):
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 558, in <module> main()
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 544, in main
s3_client = get_s3_client(module, aws_connect_kwargs, location, ceph, s3_url)
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 476, in get_s3_client
ceph = urlparse(s3_url)
TypeError: 'Module_six_moves_urllib_parse' object is not callable
```
s3_bucket error - Module_six_moves_urllib_parse object is not callable.
##### SUMMARY
When trying to create s3_bucket I'm getting an error.
This is a regression. Worked in ansible 2.4.
Might be related to:
https://github.com/ansible/ansible/issues/27566
https://github.com/ansible/ansible/pull/27568

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
s3_bucket

##### ANSIBLE VERSION
```
ansible 2.6.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
```

##### CONFIGURATION
I'm using python3:
inventories/production/hosts
```
[all:vars]
ansible_python_interpreter=/usr/bin/python3
```

##### OS / ENVIRONMENT
Ubuntu 18.04.

##### STEPS TO REPRODUCE
```yaml
- name: python3-botocore package
  apt:
    name: python3-botocore
    state: latest

- name: python3-boto package
  apt:
    name: python3-boto
    state: latest

- name: create bucket
  s3_bucket:
    name: mybucket
    state: present
    aws_access_key: "{{key}}"
    aws_secret_key: "{{secret}}"
    s3_url: "{{url}}"
    ceph: true
```

##### EXPECTED RESULTS
No error

##### ACTUAL RESULTS
```
Traceback (most recent call last):
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 558, in <module> main()
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 544, in main
s3_client = get_s3_client(module, aws_connect_kwargs, location, ceph, s3_url)
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 476, in get_s3_client
ceph = urlparse(s3_url)
TypeError: 'Module_six_moves_urllib_parse' object is not callable
```


Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/s3_bucket.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/s3_bucket.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @wimnat
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/s3_bucket.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/s3_bucket.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @wimnat
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/s3_bucket.py b/lib/ansible/modules/cloud/amazon/s3_bucket.py
--- a/lib/ansible/modules/cloud/amazon/s3_bucket.py
+++ b/lib/ansible/modules/cloud/amazon/s3_bucket.py
@@ -108,7 +108,7 @@
 import os
 import time
 
-import ansible.module_utils.six.moves.urllib.parse as urlparse
+from ansible.module_utils.six.moves.urllib.parse import urlparse
 from ansible.module_utils.six import string_types
 from ansible.module_utils.basic import to_text
 from ansible.module_utils.aws.core import AnsibleAWSModule
@@ -455,7 +455,7 @@ def destroy_bucket(s3_client, module):
 def is_fakes3(s3_url):
     """ Return True if s3_url has scheme fakes3:// """
     if s3_url is not None:
-        return urlparse.urlparse(s3_url).scheme in ('fakes3', 'fakes3s')
+        return urlparse(s3_url).scheme in ('fakes3', 'fakes3s')
     else:
         return False
 
@@ -465,7 +465,7 @@ def is_walrus(s3_url):
 
     We assume anything other than *.amazonaws.com is Walrus"""
     if s3_url is not None:
-        o = urlparse.urlparse(s3_url)
+        o = urlparse(s3_url)
         return not o.hostname.endswith('amazonaws.com')
     else:
         return False


Test patch: