mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add debug parameetr and put logs in result when debug is true or module failed
This commit is contained in:
parent
42401ea2c3
commit
c671ff5fda
1 changed files with 18 additions and 5 deletions
|
@ -156,6 +156,12 @@ options:
|
||||||
- If trust_password is set, this module send a request for
|
- If trust_password is set, this module send a request for
|
||||||
authentication before sending any requests.
|
authentication before sending any requests.
|
||||||
required: false
|
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:
|
notes:
|
||||||
- Containers must have a unique name. If you attempt to create a container
|
- 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
|
with a name that already existed in the users namespace the module will
|
||||||
|
@ -263,19 +269,20 @@ lxd_container:
|
||||||
type: object
|
type: object
|
||||||
contains:
|
contains:
|
||||||
addresses:
|
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
|
returned: when state is started or restarted
|
||||||
type: object
|
type: object
|
||||||
sample: {"eth0": ["10.155.92.191"]}
|
sample: {"eth0": ["10.155.92.191"]}
|
||||||
old_state:
|
old_state:
|
||||||
description: the old state of the container
|
description: The old state of the container
|
||||||
returned: when state is started or restarted
|
returned: when state is started or restarted
|
||||||
sample: "stopped"
|
sample: "stopped"
|
||||||
logs:
|
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
|
returned: when requests are sent
|
||||||
actions:
|
actions:
|
||||||
description: list of actions performed for the container
|
description: List of actions performed for the container.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
sample: ["create", "start"]
|
sample: ["create", "start"]
|
||||||
|
@ -382,6 +389,7 @@ class LxdContainerManagement(object):
|
||||||
self.key_file = self.module.params.get('key_file', None)
|
self.key_file = self.module.params.get('key_file', None)
|
||||||
self.cert_file = self.module.params.get('cert_file', None)
|
self.cert_file = self.module.params.get('cert_file', None)
|
||||||
self.trust_password = self.module.params.get('trust_password', None)
|
self.trust_password = self.module.params.get('trust_password', None)
|
||||||
|
self.debug = self.module.params['debug']
|
||||||
if self.url is None:
|
if self.url is None:
|
||||||
self.connection = UnixHTTPConnection(self.unix_socket_path)
|
self.connection = UnixHTTPConnection(self.unix_socket_path)
|
||||||
else:
|
else:
|
||||||
|
@ -735,9 +743,10 @@ class LxdContainerManagement(object):
|
||||||
result_json = {
|
result_json = {
|
||||||
'changed': state_changed,
|
'changed': state_changed,
|
||||||
'old_state': self.old_state,
|
'old_state': self.old_state,
|
||||||
'logs': self.logs,
|
|
||||||
'actions': self.actions
|
'actions': self.actions
|
||||||
}
|
}
|
||||||
|
if self.debug:
|
||||||
|
result_json['logs'] = self.logs
|
||||||
if self.addresses is not None:
|
if self.addresses is not None:
|
||||||
result_json['addresses'] = self.addresses
|
result_json['addresses'] = self.addresses
|
||||||
self.module.exit_json(**result_json)
|
self.module.exit_json(**result_json)
|
||||||
|
@ -814,6 +823,10 @@ def main():
|
||||||
),
|
),
|
||||||
trust_password=dict(
|
trust_password=dict(
|
||||||
type='str',
|
type='str',
|
||||||
|
),
|
||||||
|
debug=dict(
|
||||||
|
type='bool',
|
||||||
|
default=False
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
supports_check_mode=False,
|
supports_check_mode=False,
|
||||||
|
|
Loading…
Reference in a new issue