Repository: ansible/ansible

Issue:
sysctl module fails on python3
##### ISSUE TYPE

 - Bug Report


##### COMPONENT NAME
sysctl module

##### ANSIBLE VERSION
```
devel
```

##### CONFIGURATION
N/A

##### OS / ENVIRONMENT
Ubuntu with python3 container

##### SUMMARY
```
2017-05-04 01:13:20 The full traceback is:
2017-05-04 01:13:20 Traceback (most recent call last):
2017-05-04 01:13:20   File "/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py", line 397, in <module>
2017-05-04 01:13:20     main()
2017-05-04 01:13:20   File "/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py", line 391, in main
2017-05-04 01:13:20     result = SysctlModule(module)
2017-05-04 01:13:20   File "/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py", line 142, in __init__
2017-05-04 01:13:20     self.process()
2017-05-04 01:13:20   File "/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py", line 154, in process
2017-05-04 01:13:20     self.args['value'] = self._parse_value(self.args['value'])
2017-05-04 01:13:20   File "/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py", line 219, in _parse_value
2017-05-04 01:13:20     elif isinstance(value, basestring):
2017-05-04 01:13:20 NameError: name 'basestring' is not defined
2017-05-04 01:13:20 
2017-05-04 01:13:20 fatal: [testhost]: FAILED! => {
2017-05-04 01:13:20     "changed": false,
2017-05-04 01:13:20     "failed": true,
2017-05-04 01:13:20     "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py\", line 397, in <module>\n    main()\n  File \"/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py\", line 391, in main\n    result = SysctlModule(module)\n  File \"/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py\", line 142, in __init__\n    self.process()\n  File \"/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py\", line 154, in process\n    self.args['value'] = self._parse_value(self.args['value'])\n  File \"/tmp/ansible_2cdc4_pp/ansible_module_sysctl.py\", line 219, in _parse_value\n    elif isinstance(value, basestring):\nNameError: name 'basestring' is not defined\n",
2017-05-04 01:13:20     "module_stdout": "",
2017-05-04 01:13:20     "msg": "MODULE FAILURE",
2017-05-04 01:13:20     "rc": 0
2017-05-04 01:13:20 }
```

##### STEPS TO REPRODUCE

##### EXPECTED RESULTS

##### ACTUAL RESULTS




Discussion:
cc @davixx
[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/system/sysctl.py b/lib/ansible/modules/system/sysctl.py
--- a/lib/ansible/modules/system/sysctl.py
+++ b/lib/ansible/modules/system/sysctl.py
@@ -119,6 +119,7 @@
 import os
 import tempfile
 from ansible.module_utils.basic import get_platform, get_exception, AnsibleModule, BOOLEANS_TRUE, BOOLEANS_FALSE
+from ansible.module_utils.six import string_types
 
 
 class SysctlModule(object):
@@ -216,7 +217,7 @@ def _parse_value(self, value):
                 return '1'
             else:
                 return '0'
-        elif isinstance(value, basestring):
+        elif isinstance(value, string_types):
             if value.lower() in BOOLEANS_TRUE:
                 return '1'
             elif value.lower() in BOOLEANS_FALSE:


Test patch: