Repository: ansible/ansible-modules-extras

Issue:
os_project requires python-shade 1.8.1 or higher
<!--- 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 -->

os_project
##### ANSIBLE VERSION

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

```
ansible 2.1.1.0
```
##### 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.
-->

Ubuntu 16.04
##### SUMMARY

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

With ansible 2.1.1.0 the os_project module requires python-shade 1.8 or higher. But ubuntu ships python-shade 1.5, so this module does not work anymore. The os_project module is working correctly with ansible 2.1.0.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 -->

```
- name: Create OpenStack project
  os_project:
    cloud: my_cloud
    name: projectname
    description: Test Project
    domain_id: default
    endpoint_type: internal
```

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

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

A new project in OpenStack
##### ACTUAL RESULTS

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

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

```
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_g7eGSB/ansible_module_os_project.py", line 222, in <module>
    main()
  File "/tmp/ansible_g7eGSB/ansible_module_os_project.py", line 183, in main
    project = cloud.get_project(name, domain_id=domain)
TypeError: get_project() got an unexpected keyword argument 'domain_id'
```



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

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

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


Resolving patch:
diff --git a/cloud/openstack/os_project.py b/cloud/openstack/os_project.py
--- a/cloud/openstack/os_project.py
+++ b/cloud/openstack/os_project.py
@@ -21,6 +21,8 @@
 except ImportError:
     HAS_SHADE = False
 
+from distutils.version import StrictVersion
+
 DOCUMENTATION = '''
 ---
 module: os_project
@@ -46,7 +48,8 @@
      default: None
    domain_id:
      description:
-        - Domain id to create the project in if the cloud supports domains
+        - Domain id to create the project in if the cloud supports domains.
+          The domain_id parameter requires shade >= 1.8.0
      required: false
      default: None
      aliases: ['domain']
@@ -160,6 +163,9 @@ def main():
     enabled = module.params['enabled']
     state = module.params['state']
 
+    if domain and StrictVersion(shade.__version__) < StrictVersion('1.8.0'):
+        module.fail_json(msg="The domain argument requires shade >=1.8.0")
+
     try:
         if domain:
             opcloud = shade.operator_cloud(**module.params)


Test patch: