1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add specific condition to convert mailto parameter to string. (String is a expected format in proxmoxer api)

This commit is contained in:
Dylan LEVERRIER 2024-06-02 11:00:17 +02:00
parent 53df0504d3
commit 900e035f65

View file

@ -80,15 +80,15 @@ options:
id: id:
description: description:
- Required if O(state=absent). - Required if O(state=absent).
- If O(state=present), it allow you to set a pattern of id (Example 0(backup-12345678-9123)) if it not set an ID will be generate automaticly. - If O(state=present), it allow you to set a pattern of ID (example V(backup-12345678-9123)). If it is not set an ID will be generate automatically.
- Rerquired if O(state=present) and you want to update a existing job. - Required if O(state=present) and you want to update a existing job.
type: str type: str
ionice: ionice:
description: description:
- Set IO priority when using the BFQ scheduler. - Set IO priority when using the BFQ scheduler.
- For snapshot and suspend mode backups of VMs, this only affects the compressor. - For snapshot and suspend mode backups of VMs, this only affects the compressor.
- A value of 8 means the idle priority is used, - A value of 8 means the idle priority is used,
- otherwise the best-effort priority is used with the specified value. otherwise the best-effort priority is used with the specified value.
type: int type: int
lockwait: lockwait:
description: description:
@ -96,13 +96,14 @@ options:
type: int type: int
mailnotification: mailnotification:
description: description:
- Specify when to send a notification mail - Specify when to send a notification mail.
choices: ['always', 'failure'] choices: ['always', 'failure']
type: str type: str
mailto: mailto:
description: description:
- Comma-separated list of email addresses or users that should receive email notifications. - List of email addresses or users that should receive email notifications.
type: str type: list
elements: str
maxfiles: maxfiles:
description: description:
- Maximal number of backup files per guest system. - Maximal number of backup files per guest system.
@ -120,7 +121,7 @@ options:
description: description:
- Template string for generating notes for the backup(s). - Template string for generating notes for the backup(s).
- It can contain variables which will be replaced by their values. - It can contain variables which will be replaced by their values.
- Currently supported are V({{cluster}}), V{({guestname}}), V({{node}}), and V({{vmid}}),but more might be added in the future. - Currently supported are V({{cluster}}), V{({guestname}}), V({{node}}), and V({{vmid}}), but more might be added in the future.
- Needs to be a single line, newline and backslash need to be escaped. - Needs to be a single line, newline and backslash need to be escaped.
type: str type: str
performance: performance:
@ -135,11 +136,11 @@ options:
pool: pool:
description: description:
- Backup all known guest systems included in the specified pool. - Backup all known guest systems included in the specified pool.
- Can not be use with vmid and pool in same job - Can not be use with vmid and pool in same job.
type: str type: str
protected: protected:
description: description:
- If true, mark backup(s) as protected. - If V(true), mark backup(s) as protected.
type: bool type: bool
prune_backups: prune_backups:
description: description:
@ -151,7 +152,7 @@ options:
type: bool type: bool
remove: remove:
description: description:
- Prune older backups according to 'prune-backups'. - Prune older backups according to O(prune_backups).
type: bool type: bool
repeat_missed: repeat_missed:
description: description:
@ -230,7 +231,7 @@ EXAMPLES = '''
vmid: "103" vmid: "103"
mode: "snapshot" mode: "snapshot"
mailnotification: "always" mailnotification: "always"
mailto: "preprod@idnow.io" mailto: "my mail address"
repeat_missed: 0 repeat_missed: 0
enabled: 1 enabled: 1
prune_backups: prune_backups:
@ -338,9 +339,10 @@ proxmox_backup:
mailto: mailto:
description: description:
- > - >
Comma-separated list of email addresses or users that should receive email notifications. List of email addresses or users that should receive email notifications.
returned: on success returned: on success
type: str type: list
elements: str
maxfiles: maxfiles:
description: Maximal number of backup files per guest system. description: Maximal number of backup files per guest system.
returned: on success returned: on success
@ -578,13 +580,16 @@ class ProxmoxBackupAnsible(ProxmoxAnsible):
def get_task_parameters(self): def get_task_parameters(self):
# Filtre pour exclure les paramètres d'authentification # Filtre pour exclure les paramètres d'authentification
auth_keys = ['api_host', 'api_user', 'api_password', 'api_token_id', exclude_keys = ['api_host', 'api_user', 'api_password', 'api_token_id',
'api_token_secret', 'validate_certs', 'state'] 'api_token_secret', 'validate_certs', 'state', 'mailto']
task_params = { task_params = {
k.replace('_', '-'): (1 if v is True else (0 if v is False else v)) k.replace('_', '-'): (1 if v is True else (0 if v is False else v))
for k, v in self.module.params.items() for k, v in self.module.params.items()
if k not in auth_keys and v is not None if k not in exclude_keys and v is not None
} }
if 'mailto' in self.module.params and self.module.params['mailto'] is not None:
task_params['mailto'] = ','.join(self.module.params['mailto'])
return task_params return task_params
@ -646,7 +651,8 @@ def proxmox_backup_argument_spec():
'choices': ['always', 'failure'] 'choices': ['always', 'failure']
}, },
'mailto': { 'mailto': {
'type': 'str' 'type': 'list',
'elements': 'str'
}, },
'maxfiles': { 'maxfiles': {
'type': 'int' 'type': 'int'