summaryrefslogtreecommitdiff
path: root/cloud/lxd
diff options
context:
space:
mode:
authorHiroaki Nakamura <hnakamur@gmail.com>2016-06-30 21:14:48 +0900
committerHiroaki Nakamura <hnakamur@gmail.com>2016-06-30 21:14:48 +0900
commit308e0984f7c19aeb00d90506dd81a93ef87aa281 (patch)
treea38c34f053d200dbada2ae48554aa1f604dbf21a /cloud/lxd
parent5dc0b934eb0cac2ff75dc6b71b5f3900b113022f (diff)
downloadansible-modules-extras-308e0984f7c19aeb00d90506dd81a93ef87aa281.tar.gz
Add debug parameetr and put logs in result when debug is true or module failed
Diffstat (limited to 'cloud/lxd')
-rw-r--r--cloud/lxd/lxd_container.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/cloud/lxd/lxd_container.py b/cloud/lxd/lxd_container.py
index 9156de79..33965a83 100644
--- a/cloud/lxd/lxd_container.py
+++ b/cloud/lxd/lxd_container.py
@@ -156,6 +156,12 @@ options:
- If trust_password is set, this module send a request for
authentication before sending any requests.
required: false
+ debug:
+ description:
+ - If this flag is true, the logs key are added to the result object
+ which keeps all the requests and responses for calling APIs.
+ required: false
+ default: false
notes:
- Containers must have a unique name. If you attempt to create a container
with a name that already existed in the users namespace the module will
@@ -263,19 +269,20 @@ lxd_container:
type: object
contains:
addresses:
- description: mapping from the network device name to a list of IPv4 addresses in the container
+ description: Mapping from the network device name to a list of IPv4 addresses in the container
returned: when state is started or restarted
type: object
sample: {"eth0": ["10.155.92.191"]}
old_state:
- description: the old state of the container
+ description: The old state of the container
returned: when state is started or restarted
sample: "stopped"
logs:
- descriptions: the logs of requests and responses
+ descriptions: The logs of requests and responses. This key exists only when you set the
+ debug paramter to true or this module failed.
returned: when requests are sent
actions:
- description: list of actions performed for the container
+ description: List of actions performed for the container.
returned: success
type: list
sample: ["create", "start"]
@@ -382,6 +389,7 @@ class LxdContainerManagement(object):
self.key_file = self.module.params.get('key_file', None)
self.cert_file = self.module.params.get('cert_file', None)
self.trust_password = self.module.params.get('trust_password', None)
+ self.debug = self.module.params['debug']
if self.url is None:
self.connection = UnixHTTPConnection(self.unix_socket_path)
else:
@@ -735,9 +743,10 @@ class LxdContainerManagement(object):
result_json = {
'changed': state_changed,
'old_state': self.old_state,
- 'logs': self.logs,
'actions': self.actions
}
+ if self.debug:
+ result_json['logs'] = self.logs
if self.addresses is not None:
result_json['addresses'] = self.addresses
self.module.exit_json(**result_json)
@@ -814,6 +823,10 @@ def main():
),
trust_password=dict(
type='str',
+ ),
+ debug=dict(
+ type='bool',
+ default=False
)
),
supports_check_mode=False,