From 80af46117876dad8f9598027e380b4d76dffc31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Fri, 11 Nov 2016 14:03:43 +0100 Subject: cloudstack: add additional CLOUDSTACK_VPC env var (#18467) --- docsite/rst/guide_cloudstack.rst | 2 +- lib/ansible/module_utils/cloudstack.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docsite/rst/guide_cloudstack.rst b/docsite/rst/guide_cloudstack.rst index d3e72e3b23..ac293f8ee1 100644 --- a/docsite/rst/guide_cloudstack.rst +++ b/docsite/rst/guide_cloudstack.rst @@ -101,7 +101,7 @@ Environment Variables ````````````````````` .. versionadded:: 2.3 -Since Ansible 2.3 it is possible to use environment variables for domain (``CLOUDSTACK_DOMAIN``), account (``CLOUDSTACK_ACCOUNT``), project (``CLOUDSTACK_PROJECT``) and zone (``CLOUDSTACK_ZONE``). This simplifies the tasks by not repeating the arguments for every tasks. +Since Ansible 2.3 it is possible to use environment variables for domain (``CLOUDSTACK_DOMAIN``), account (``CLOUDSTACK_ACCOUNT``), project (``CLOUDSTACK_PROJECT``), VPC (``CLOUDSTACK_VPC``) and zone (``CLOUDSTACK_ZONE``). This simplifies the tasks by not repeating the arguments for every tasks. Below you see an example how it can be used in combination with Ansible's block feature: diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index 6a6f4dd527..a2535877a5 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -216,6 +216,8 @@ class AnsibleCloudStack(object): return self._get_by_key(key, self.vpc) vpc = self.module.params.get('vpc') + if not vpc: + vpc = os.environ.get('CLOUDSTACK_VPC') if not vpc: return None -- cgit v1.2.1