mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add backup filename and dir path option for config network modules (#50801)
* Add configurable backup path option for network config modules Fixes #50283 Fixes #32724 * Add back_options in network config module argspec * Handle backup path options in network action plugin * Fix review comments * Add integration tests * Update changelog
This commit is contained in:
parent
fe8412128b
commit
70bf9b9919
41 changed files with 2228 additions and 119 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- Add configurable backup path option support for network config modules
|
|
@ -65,9 +65,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
running_config:
|
running_config:
|
||||||
|
@ -131,6 +131,28 @@ options:
|
||||||
of the current device's configuration against. When specifying this
|
of the current device's configuration against. When specifying this
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -150,6 +172,14 @@ EXAMPLES = """
|
||||||
- acl rule protocol testACL 1 any
|
- acl rule protocol testACL 1 any
|
||||||
- acl rule direction testACL 3 in
|
- acl rule direction testACL 3 in
|
||||||
before: acl delete testACL
|
before: acl delete testACL
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
aireos_config:
|
||||||
|
backup: yes
|
||||||
|
lines: sysname testDevice
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -209,6 +239,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -223,6 +257,7 @@ def main():
|
||||||
intended_config=dict(),
|
intended_config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
# save is deprecated as of 2.7, use save_when instead
|
# save is deprecated as of 2.7, use save_when instead
|
||||||
save=dict(type='bool', default=False, removed_in_version='2.11'),
|
save=dict(type='bool', default=False, removed_in_version='2.11'),
|
||||||
|
|
|
@ -84,9 +84,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
running_config:
|
running_config:
|
||||||
|
@ -152,6 +152,28 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: 'yes'
|
default: 'yes'
|
||||||
version_added: "2.5"
|
version_added: "2.5"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -179,6 +201,14 @@ EXAMPLES = """
|
||||||
parents: ip access-list standard 1
|
parents: ip access-list standard 1
|
||||||
before: no ip access-list standard 1
|
before: no ip access-list standard 1
|
||||||
match: exact
|
match: exact
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
aruba_config:
|
||||||
|
backup: yes
|
||||||
|
lines: hostname {{ inventory_hostname }}
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -241,6 +271,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -257,6 +291,7 @@ def main():
|
||||||
intended_config=dict(),
|
intended_config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the
|
||||||
exist, it is created.
|
playbook root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
config:
|
config:
|
||||||
|
@ -119,6 +119,28 @@ options:
|
||||||
running. If check mode is specified, this argument is ignored.
|
running. If check mode is specified, this argument is ignored.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -207,6 +229,15 @@ vars:
|
||||||
debug:
|
debug:
|
||||||
var: interface
|
var: interface
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
asa_config:
|
||||||
|
lines:
|
||||||
|
- access-group cloud-acl_access_in in interface cloud13
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -282,6 +313,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -293,6 +328,7 @@ def main():
|
||||||
|
|
||||||
match=dict(default='line', choices=['line', 'strict', 'exact', 'none']),
|
match=dict(default='line', choices=['line', 'strict', 'exact', 'none']),
|
||||||
replace=dict(default='line', choices=['line', 'block']),
|
replace=dict(default='line', choices=['line', 'block']),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
config=dict(),
|
config=dict(),
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
|
|
|
@ -49,10 +49,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current running config from the remote device before any
|
the current running config from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
|
@ -118,6 +118,28 @@ options:
|
||||||
a list of regular expressions or exact line matches.
|
a list of regular expressions or exact line matches.
|
||||||
Note that this parameter will be ignored if the platform has onbox
|
Note that this parameter will be ignored if the platform has onbox
|
||||||
diff support.
|
diff support.
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -143,6 +165,14 @@ EXAMPLES = """
|
||||||
cli_config:
|
cli_config:
|
||||||
config: set system host-name foo
|
config: set system host-name foo
|
||||||
commit_comment: this is a test
|
commit_comment: this is a test
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
cli_config:
|
||||||
|
config: "{{ lookup('template', 'basic/config.j2') }}"
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -298,8 +328,13 @@ def run(module, capabilities, connection, candidate, running, rollback_id):
|
||||||
def main():
|
def main():
|
||||||
"""main entry point for execution
|
"""main entry point for execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
backup=dict(default=False, type='bool'),
|
backup=dict(default=False, type='bool'),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
config=dict(type='str'),
|
config=dict(type='str'),
|
||||||
commit=dict(type='bool'),
|
commit=dict(type='bool'),
|
||||||
replace=dict(type='str'),
|
replace=dict(type='str'),
|
||||||
|
|
|
@ -92,9 +92,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(current-configuration) from the remote device before any
|
the current C(current-configuration) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
config:
|
config:
|
||||||
|
@ -125,6 +125,28 @@ options:
|
||||||
return changed.
|
return changed.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -174,6 +196,15 @@ EXAMPLES = """
|
||||||
before: undo acl 2000
|
before: undo acl 2000
|
||||||
replace: block
|
replace: block
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
ce_config:
|
||||||
|
lines: sysname {{ inventory_hostname }}
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -254,6 +285,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -269,6 +304,7 @@ def main():
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -148,9 +148,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
comment:
|
comment:
|
||||||
|
@ -165,6 +165,28 @@ options:
|
||||||
changes to the device.
|
changes to the device.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -185,6 +207,14 @@ Tasks: The following are examples of using the module cnos_config.
|
||||||
cnos_config:
|
cnos_config:
|
||||||
src: config.cfg
|
src: config.cfg
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
cnos_config:
|
||||||
|
src: config.cfg
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -266,6 +296,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
"""main entry point for module execution
|
"""main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -281,6 +315,7 @@ def main():
|
||||||
|
|
||||||
config=dict(),
|
config=dict(),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
comment=dict(default=DEFAULT_COMMIT_COMMENT),
|
comment=dict(default=DEFAULT_COMMIT_COMMENT),
|
||||||
admin=dict(type='bool', default=False)
|
admin=dict(type='bool', default=False)
|
||||||
)
|
)
|
||||||
|
|
|
@ -114,11 +114,33 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -145,6 +167,13 @@ EXAMPLES = """
|
||||||
parents: ['ip access-list test']
|
parents: ['ip access-list test']
|
||||||
before: ['no ip access-list test']
|
before: ['no ip access-list test']
|
||||||
replace: block
|
replace: block
|
||||||
|
|
||||||
|
- dellos10_config:
|
||||||
|
lines: ['hostname {{ inventory_hostname }}']
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -203,6 +232,10 @@ def get_running_config(module):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
lines=dict(aliases=['commands'], type='list'),
|
lines=dict(aliases=['commands'], type='list'),
|
||||||
parents=dict(type='list'),
|
parents=dict(type='list'),
|
||||||
|
@ -219,7 +252,8 @@ def main():
|
||||||
update=dict(choices=['merge', 'check'], default='merge'),
|
update=dict(choices=['merge', 'check'], default='merge'),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
config=dict(),
|
config=dict(),
|
||||||
backup=dict(type='bool', default=False)
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec)
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(dellos10_argument_spec)
|
argument_spec.update(dellos10_argument_spec)
|
||||||
|
|
|
@ -112,11 +112,33 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -144,6 +166,12 @@ EXAMPLES = """
|
||||||
before: ['no ip access-list test']
|
before: ['no ip access-list test']
|
||||||
replace: block
|
replace: block
|
||||||
|
|
||||||
|
- dellos6_config:
|
||||||
|
lines: ['hostname {{ inventory_hostname }}']
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -205,6 +233,10 @@ def get_running_config(module):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
lines=dict(aliases=['commands'], type='list'),
|
lines=dict(aliases=['commands'], type='list'),
|
||||||
parents=dict(type='list'),
|
parents=dict(type='list'),
|
||||||
|
@ -221,7 +253,8 @@ def main():
|
||||||
update=dict(choices=['merge', 'check'], default='merge'),
|
update=dict(choices=['merge', 'check'], default='merge'),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
config=dict(),
|
config=dict(),
|
||||||
backup=dict(type='bool', default=False)
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec)
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(dellos6_argument_spec)
|
argument_spec.update(dellos6_argument_spec)
|
||||||
|
|
|
@ -113,11 +113,33 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
notes:
|
notes:
|
||||||
- This module requires Dell OS9 version 9.10.0.1P13 or above.
|
- This module requires Dell OS9 version 9.10.0.1P13 or above.
|
||||||
|
|
||||||
|
@ -152,6 +174,14 @@ EXAMPLES = """
|
||||||
parents: ['ip access-list extended test']
|
parents: ['ip access-list extended test']
|
||||||
before: ['no ip access-list extended test']
|
before: ['no ip access-list extended test']
|
||||||
replace: block
|
replace: block
|
||||||
|
|
||||||
|
- dellos9_config:
|
||||||
|
lines: ['hostname {{ inventory_hostname }}']
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -210,6 +240,10 @@ def get_running_config(module):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
lines=dict(aliases=['commands'], type='list'),
|
lines=dict(aliases=['commands'], type='list'),
|
||||||
parents=dict(type='list'),
|
parents=dict(type='list'),
|
||||||
|
@ -226,7 +260,8 @@ def main():
|
||||||
update=dict(choices=['merge', 'check'], default='merge'),
|
update=dict(choices=['merge', 'check'], default='merge'),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
config=dict(),
|
config=dict(),
|
||||||
backup=dict(type='bool', default=False)
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec)
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(dellos9_argument_spec)
|
argument_spec.update(dellos9_argument_spec)
|
||||||
|
|
|
@ -59,10 +59,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- The C(backup) argument will backup the current device's active
|
- The C(backup) argument will backup the current device's active
|
||||||
configuration to the Ansible control host prior to making any
|
configuration to the Ansible control host prior to making any
|
||||||
changes. The backup file will be located in the backup folder
|
changes. If the C(backup_options) value is not given, the backup
|
||||||
in the playbook root directory or role root directory if the
|
file will be located in the backup folder in the playbook root
|
||||||
playbook is part of an ansible role. If the directory does not
|
directory or role root directory if the playbook is part of an
|
||||||
exist, it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
comment:
|
comment:
|
||||||
|
@ -85,6 +85,28 @@ options:
|
||||||
active configuration is saved.
|
active configuration is saved.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -99,6 +121,14 @@ EXAMPLES = """
|
||||||
edgeos_config:
|
edgeos_config:
|
||||||
src: edgeos.cfg
|
src: edgeos.cfg
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
edgeos_config:
|
||||||
|
src: edgeos.cfg
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -241,6 +271,11 @@ def run(module, result):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
spec = dict(
|
spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
lines=dict(type='list'),
|
lines=dict(type='list'),
|
||||||
|
@ -252,6 +287,7 @@ def main():
|
||||||
config=dict(),
|
config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -109,9 +109,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
comment:
|
comment:
|
||||||
|
@ -126,6 +126,28 @@ options:
|
||||||
changes to the device.
|
changes to the device.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -144,6 +166,14 @@ EXAMPLES = """
|
||||||
enos_config:
|
enos_config:
|
||||||
src: config.cfg
|
src: config.cfg
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
enos_config:
|
||||||
|
src: config.cfg
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -225,6 +255,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
"""main entry point for module execution
|
"""main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -239,6 +273,7 @@ def main():
|
||||||
|
|
||||||
config=dict(),
|
config=dict(),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
comment=dict(default=DEFAULT_COMMIT_COMMENT),
|
comment=dict(default=DEFAULT_COMMIT_COMMENT),
|
||||||
admin=dict(type='bool', default=False)
|
admin=dict(type='bool', default=False)
|
||||||
)
|
)
|
||||||
|
|
|
@ -103,10 +103,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
@ -182,6 +182,28 @@ options:
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
version_added: "2.4"
|
version_added: "2.4"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -221,6 +243,14 @@ EXAMPLES = """
|
||||||
- shutdown
|
- shutdown
|
||||||
# parents: int eth1
|
# parents: int eth1
|
||||||
parents: interface Ethernet1
|
parents: interface Ethernet1
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
eos_config:
|
||||||
|
src: eos_template.j2
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -286,6 +316,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -300,6 +334,7 @@ def main():
|
||||||
|
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
running_config:
|
running_config:
|
||||||
|
@ -142,6 +142,28 @@ options:
|
||||||
of the current device's configuration against. When specifying this
|
of the current device's configuration against. When specifying this
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -169,6 +191,15 @@ EXAMPLES = """
|
||||||
- name: save running to startup when modified
|
- name: save running to startup when modified
|
||||||
exos_config:
|
exos_config:
|
||||||
save_when: modified
|
save_when: modified
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
exos_config:
|
||||||
|
lines:
|
||||||
|
- configure ports 2 description-string "Master Uplink"
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -256,6 +287,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -272,6 +307,7 @@ def main():
|
||||||
|
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,28 @@ options:
|
||||||
configuration against.
|
configuration against.
|
||||||
- When specifying this argument, the task should also modify the
|
- When specifying this argument, the task should also modify the
|
||||||
C(diff_against) value and set it to I(intended).
|
C(diff_against) value and set it to I(intended).
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
notes:
|
notes:
|
||||||
- Abbreviated commands are NOT idempotent, see
|
- Abbreviated commands are NOT idempotent, see
|
||||||
L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
|
L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
|
||||||
|
@ -224,6 +246,19 @@ EXAMPLES = r'''
|
||||||
password: secret
|
password: secret
|
||||||
server: lb.mydomain.com
|
server: lb.mydomain.com
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
bigip_imish_config:
|
||||||
|
lines: bfd slow-timer 2000
|
||||||
|
backup: yes
|
||||||
|
provider:
|
||||||
|
user: admin
|
||||||
|
password: secret
|
||||||
|
server: lb.mydomain.com
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
|
delegate_to: localhost
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = r'''
|
RETURN = r'''
|
||||||
|
@ -707,6 +742,10 @@ class ModuleManager(object):
|
||||||
class ArgumentSpec(object):
|
class ArgumentSpec(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.supports_check_mode = True
|
self.supports_check_mode = True
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
route_domain=dict(default=0),
|
route_domain=dict(default=0),
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
@ -723,6 +762,7 @@ class ArgumentSpec(object):
|
||||||
intended_config=dict(),
|
intended_config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
@ -182,6 +182,28 @@ options:
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
version_added: "2.4"
|
version_added: "2.4"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -266,6 +288,14 @@ EXAMPLES = """
|
||||||
ios_config:
|
ios_config:
|
||||||
backup: yes
|
backup: yes
|
||||||
src: ios_template.j2
|
src: ios_template.j2
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
ios_config:
|
||||||
|
src: ios_template.j2
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -350,6 +380,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -368,7 +402,7 @@ def main():
|
||||||
|
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
diff_against=dict(choices=['startup', 'intended', 'running']),
|
diff_against=dict(choices=['startup', 'intended', 'running']),
|
||||||
|
|
|
@ -114,10 +114,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
@ -143,6 +143,28 @@ options:
|
||||||
underscores are allowed. If the configuration is not changed or
|
underscores are allowed. If the configuration is not changed or
|
||||||
committed, this argument is ignored.
|
committed, this argument is ignored.
|
||||||
version_added: "2.7"
|
version_added: "2.7"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -170,6 +192,14 @@ EXAMPLES = """
|
||||||
- shutdown
|
- shutdown
|
||||||
# parents: int g0/0/0/1
|
# parents: int g0/0/0/1
|
||||||
parents: interface GigabitEthernet0/0/0/1
|
parents: interface GigabitEthernet0/0/0/1
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
iosxr_config:
|
||||||
|
src: config.cfg
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -312,6 +342,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
"""main entry point for module execution
|
"""main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -330,6 +364,7 @@ def main():
|
||||||
|
|
||||||
config=dict(),
|
config=dict(),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
comment=dict(default=DEFAULT_COMMIT_COMMENT),
|
comment=dict(default=DEFAULT_COMMIT_COMMENT),
|
||||||
admin=dict(type='bool', default=False),
|
admin=dict(type='bool', default=False),
|
||||||
label=dict()
|
label=dict()
|
||||||
|
|
|
@ -105,9 +105,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
config:
|
config:
|
||||||
|
@ -131,6 +131,28 @@ options:
|
||||||
default: never
|
default: never
|
||||||
choices: ['always', 'never', 'modified']
|
choices: ['always', 'never', 'modified']
|
||||||
version_added: "2.4"
|
version_added: "2.4"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -217,6 +239,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -232,6 +258,7 @@ def main():
|
||||||
config=dict(),
|
config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save_when=dict(choices=['always', 'never', 'modified'], default='never')
|
save_when=dict(choices=['always', 'never', 'modified'], default='never')
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -92,10 +92,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
@ -130,6 +130,28 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
requirements:
|
requirements:
|
||||||
- ncclient (>=v0.5.2)
|
- ncclient (>=v0.5.2)
|
||||||
notes:
|
notes:
|
||||||
|
@ -193,6 +215,14 @@ EXAMPLES = """
|
||||||
lines:
|
lines:
|
||||||
# - set int ge-0/0/1 unit 0 desc "Test interface"
|
# - set int ge-0/0/1 unit 0 desc "Test interface"
|
||||||
- set interfaces ge-0/0/1 unit 0 description "Test interface"
|
- set interfaces ge-0/0/1 unit 0 description "Test interface"
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
junos_config:
|
||||||
|
src: srx.cfg
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -310,6 +340,10 @@ def configure_device(module, warnings, candidate):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
lines=dict(type='list'),
|
lines=dict(type='list'),
|
||||||
|
|
||||||
|
@ -329,6 +363,7 @@ def main():
|
||||||
|
|
||||||
# config operations
|
# config operations
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
rollback=dict(type='int'),
|
rollback=dict(type='int'),
|
||||||
|
|
||||||
zeroize=dict(default=False, type='bool'),
|
zeroize=dict(default=False, type='bool'),
|
||||||
|
|
|
@ -108,10 +108,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.7"
|
version_added: "2.7"
|
||||||
|
@ -143,6 +143,28 @@ options:
|
||||||
to load. The path to the source file can either be the full path on the Ansible control host or
|
to load. The path to the source file can either be the full path on the Ansible control host or
|
||||||
a relative path from the playbook or role root directory. This argument is mutually exclusive with I(xml).
|
a relative path from the playbook or role root directory. This argument is mutually exclusive with I(xml).
|
||||||
version_added: "2.4"
|
version_added: "2.4"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
requirements:
|
requirements:
|
||||||
- "ncclient"
|
- "ncclient"
|
||||||
notes:
|
notes:
|
||||||
|
@ -193,6 +215,13 @@ EXAMPLES = '''
|
||||||
register: backup_junos_location
|
register: backup_junos_location
|
||||||
vars:
|
vars:
|
||||||
ansible_private_key_file: /home/admin/.ssh/newprivatekeyfile
|
ansible_private_key_file: /home/admin/.ssh/newprivatekeyfile
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
netconf_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
@ -225,6 +254,10 @@ from ansible.module_utils.network.netconf.netconf import get_capabilities, get_c
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
content=dict(aliases=['xml']),
|
content=dict(aliases=['xml']),
|
||||||
target=dict(choices=['auto', 'candidate', 'running'], default='auto', aliases=['datastore']),
|
target=dict(choices=['auto', 'candidate', 'running'], default='auto', aliases=['datastore']),
|
||||||
|
@ -236,6 +269,7 @@ def main():
|
||||||
confirm_commit=dict(type='bool', default=False),
|
confirm_commit=dict(type='bool', default=False),
|
||||||
error_option=dict(choices=['stop-on-error', 'continue-on-error', 'rollback-on-error'], default='stop-on-error'),
|
error_option=dict(choices=['stop-on-error', 'continue-on-error', 'rollback-on-error'], default='stop-on-error'),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
delete=dict(type='bool', default=False),
|
delete=dict(type='bool', default=False),
|
||||||
commit=dict(type='bool', default=True),
|
commit=dict(type='bool', default=True),
|
||||||
|
|
|
@ -90,9 +90,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
running_config:
|
running_config:
|
||||||
|
@ -131,6 +131,28 @@ options:
|
||||||
of the current device's configuration against. When specifying this
|
of the current device's configuration against. When specifying this
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -171,6 +193,14 @@ EXAMPLES = """
|
||||||
nos_config:
|
nos_config:
|
||||||
diff_against: intended
|
diff_against: intended
|
||||||
intended_config: "{{ lookup('file', 'master.cfg') }}"
|
intended_config: "{{ lookup('file', 'master.cfg') }}"
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
nos_config:
|
||||||
|
lines: logging raslog console INFO
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -232,6 +262,10 @@ def get_candidate(module):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -249,6 +283,7 @@ def main():
|
||||||
intended_config=dict(),
|
intended_config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
diff_against=dict(choices=['intended', 'running']),
|
diff_against=dict(choices=['intended', 'running']),
|
||||||
diff_ignore_lines=dict(type='list'),
|
diff_ignore_lines=dict(type='list'),
|
||||||
|
|
|
@ -107,10 +107,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
@ -184,6 +184,28 @@ options:
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
version_added: "2.4"
|
version_added: "2.4"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(True), if C(backup) is set
|
||||||
|
to I(false) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exit it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
notes:
|
notes:
|
||||||
- Abbreviated commands are NOT idempotent, see
|
- Abbreviated commands are NOT idempotent, see
|
||||||
L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
|
L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
|
||||||
|
@ -234,6 +256,13 @@ EXAMPLES = """
|
||||||
- shutdown
|
- shutdown
|
||||||
# parents: int eth1/1
|
# parents: int eth1/1
|
||||||
parents: interface Ethernet1/1
|
parents: interface Ethernet1/1
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
nxos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -313,6 +342,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
replace_src=dict(),
|
replace_src=dict(),
|
||||||
|
@ -330,6 +363,7 @@ def main():
|
||||||
|
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -83,9 +83,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
default: no
|
default: no
|
||||||
type: bool
|
type: bool
|
||||||
config:
|
config:
|
||||||
|
@ -101,6 +101,28 @@ options:
|
||||||
running. If check mode is specified, this argument is ignored.
|
running. If check mode is specified, this argument is ignored.
|
||||||
default: no
|
default: no
|
||||||
type: bool
|
type: bool
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -184,6 +206,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -199,6 +225,7 @@ def main():
|
||||||
config=dict(),
|
config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -90,9 +90,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
running_config:
|
running_config:
|
||||||
|
@ -156,6 +156,28 @@ options:
|
||||||
of the current device's configuration against. When specifying this
|
of the current device's configuration against. When specifying this
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -205,6 +227,14 @@ EXAMPLES = """
|
||||||
- name: save running to startup when modified
|
- name: save running to startup when modified
|
||||||
slxos_config:
|
slxos_config:
|
||||||
save_when: modified
|
save_when: modified
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
slxos_config:
|
||||||
|
lines: hostname {{ inventory_hostname }}
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -282,6 +312,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -300,6 +334,7 @@ def main():
|
||||||
|
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -96,9 +96,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. f the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory. If the directory does not
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
exist, it is created.
|
root directory. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
@ -127,6 +127,28 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -184,6 +206,13 @@ vars:
|
||||||
- service
|
- service
|
||||||
- vpls 1000 customer foo 1 create
|
- vpls 1000 customer foo 1 create
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
sros_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -258,6 +287,10 @@ def run(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -270,6 +303,7 @@ def main():
|
||||||
defaults=dict(type='bool', default=False, aliases=['detail']),
|
defaults=dict(type='bool', default=False, aliases=['detail']),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- This argument will cause the module to create a full backup of
|
- This argument will cause the module to create a full backup of
|
||||||
the current C(running-config) from the remote device before any
|
the current C(running-config) from the remote device before any
|
||||||
changes are made. The backup file is written to the C(backup)
|
changes are made. If the C(backup_options) value is not given,
|
||||||
folder in the playbook root directory or role root directory, if
|
the backup file is written to the C(backup) folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not exist,
|
root directory or role root directory, if playbook is part of an
|
||||||
it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
running_config:
|
running_config:
|
||||||
|
@ -151,6 +151,28 @@ options:
|
||||||
of the current device's configuration against. When specifying this
|
of the current device's configuration against. When specifying this
|
||||||
argument, the task should also modify the C(diff_against) value and
|
argument, the task should also modify the C(diff_against) value and
|
||||||
set it to I(intended).
|
set it to I(intended).
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -179,6 +201,13 @@ EXAMPLES = """
|
||||||
- name: save running to startup when modified
|
- name: save running to startup when modified
|
||||||
voss_config:
|
voss_config:
|
||||||
save_when: modified
|
save_when: modified
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
voss_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -247,6 +276,10 @@ def save_config(module, result):
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
|
|
||||||
|
@ -264,6 +297,7 @@ def main():
|
||||||
|
|
||||||
defaults=dict(type='bool', default=False),
|
defaults=dict(type='bool', default=False),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
|
|
||||||
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
save_when=dict(choices=['always', 'never', 'modified', 'changed'], default='never'),
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- The C(backup) argument will backup the current devices active
|
- The C(backup) argument will backup the current devices active
|
||||||
configuration to the Ansible control host prior to making any
|
configuration to the Ansible control host prior to making any
|
||||||
changes. The backup file will be located in the backup folder
|
changes. If the C(backup_options) value is not given, the
|
||||||
in the playbook root directory or role root directory, if
|
backup file will be located in the backup folder in the playbook
|
||||||
playbook is part of an ansible role. If the directory does not
|
root directory or role root directory, if playbook is part of an
|
||||||
exist, it is created.
|
ansible role. If the directory does not exist, it is created.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
comment:
|
comment:
|
||||||
|
@ -90,6 +90,28 @@ options:
|
||||||
active configuration is saved.
|
active configuration is saved.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
backup_options:
|
||||||
|
description:
|
||||||
|
- This is a dict object containing configurable options related to backup file path.
|
||||||
|
The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
|
||||||
|
to I(no) this option will be silently ignored.
|
||||||
|
suboptions:
|
||||||
|
filename:
|
||||||
|
description:
|
||||||
|
- The filename to be used to store the backup configuration. If the the filename
|
||||||
|
is not given it will be generated based on the hostname, current time and date
|
||||||
|
in format defined by <hostname>_config.<current-date>@<current-time>
|
||||||
|
dir_path:
|
||||||
|
description:
|
||||||
|
- This option provides the path ending with directory name in which the backup
|
||||||
|
configuration file will be stored. If the directory does not exist it will be first
|
||||||
|
created and the filename is either the value of C(filename) or default filename
|
||||||
|
as described in C(filename) options description. If the path value is not given
|
||||||
|
in that case a I(backup) directory will be created in the current working directory
|
||||||
|
and backup configuration will be copied in C(filename) within I(backup) directory.
|
||||||
|
type: path
|
||||||
|
type: dict
|
||||||
|
version_added: "2.8"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -114,6 +136,13 @@ EXAMPLES = """
|
||||||
lines:
|
lines:
|
||||||
# - set int eth eth2 description 'OUTSIDE'
|
# - set int eth eth2 description 'OUTSIDE'
|
||||||
- set interface ethernet eth2 description 'OUTSIDE'
|
- set interface ethernet eth2 description 'OUTSIDE'
|
||||||
|
|
||||||
|
- name: configurable backup path
|
||||||
|
vyos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: /home/user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -242,6 +271,10 @@ def run(module, result):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
backup_spec = dict(
|
||||||
|
filename=dict(),
|
||||||
|
dir_path=dict(type='path')
|
||||||
|
)
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
lines=dict(type='list'),
|
lines=dict(type='list'),
|
||||||
|
@ -253,6 +286,7 @@ def main():
|
||||||
config=dict(),
|
config=dict(),
|
||||||
|
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
|
backup_options=dict(type='dict', options=backup_spec),
|
||||||
save=dict(type='bool', default=False),
|
save=dict(type='bool', default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ display = Display()
|
||||||
class ActionModule(ActionNetworkModule):
|
class ActionModule(ActionNetworkModule):
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=None):
|
def run(self, tmp=None, task_vars=None):
|
||||||
|
del tmp # tmp no longer has any effect
|
||||||
|
|
||||||
self._config_module = True if self._task.action == 'bigip_imish_config' else False
|
self._config_module = True if self._task.action == 'bigip_imish_config' else False
|
||||||
socket_path = None
|
socket_path = None
|
||||||
|
|
|
@ -25,7 +25,7 @@ import glob
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text, to_bytes
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||||
from ansible.plugins.action.normal import ActionModule as _ActionModule
|
from ansible.plugins.action.normal import ActionModule as _ActionModule
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
|
@ -44,8 +44,8 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||||
|
|
||||||
if config_module and self._task.args.get('backup'):
|
if config_module and self._task.args.get('backup') and not result.get('failed'):
|
||||||
self._handle_backup_option(result, task_vars['inventory_hostname'], result.get('__backup__', False))
|
self._handle_backup_option(result, task_vars)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -55,12 +55,60 @@ class ActionModule(_ActionModule):
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
return dict(failed=True, msg=to_text(exc))
|
return dict(failed=True, msg=to_text(exc))
|
||||||
|
|
||||||
def _handle_backup_option(self, result, hostname, backup):
|
def _handle_backup_option(self, result, task_vars):
|
||||||
if backup:
|
|
||||||
# User requested backup and no error occurred in module.
|
filename = None
|
||||||
# NOTE: If there is a parameter error, _backup key may not be in results.
|
backup_path = None
|
||||||
filepath = self._write_backup(hostname, backup)
|
try:
|
||||||
result['backup_path'] = filepath
|
content = result['__backup__']
|
||||||
|
except KeyError:
|
||||||
|
raise AnsibleError('Failed while reading configuration backup')
|
||||||
|
|
||||||
|
backup_options = self._task.args.get('backup_options')
|
||||||
|
if backup_options:
|
||||||
|
filename = backup_options.get('filename')
|
||||||
|
backup_path = backup_options.get('dir_path')
|
||||||
|
|
||||||
|
if not backup_path:
|
||||||
|
cwd = self._get_working_path()
|
||||||
|
backup_path = os.path.join(cwd, 'backup')
|
||||||
|
if not filename:
|
||||||
|
tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time()))
|
||||||
|
filename = '%s_config.%s' % (task_vars['inventory_hostname'], tstamp)
|
||||||
|
|
||||||
|
dest = os.path.join(backup_path, filename)
|
||||||
|
backup_path = os.path.expanduser(os.path.expandvars(to_bytes(backup_path, errors='surrogate_or_strict')))
|
||||||
|
|
||||||
|
if not os.path.exists(backup_path):
|
||||||
|
os.makedirs(backup_path)
|
||||||
|
|
||||||
|
new_task = self._task.copy()
|
||||||
|
for item in self._task.args:
|
||||||
|
if not item.startswith('_'):
|
||||||
|
new_task.args.pop(item, None)
|
||||||
|
|
||||||
|
new_task.args.update(
|
||||||
|
dict(
|
||||||
|
content=content,
|
||||||
|
dest=dest,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
copy_action = self._shared_loader_obj.action_loader.get('copy',
|
||||||
|
task=new_task,
|
||||||
|
connection=self._connection,
|
||||||
|
play_context=self._play_context,
|
||||||
|
loader=self._loader,
|
||||||
|
templar=self._templar,
|
||||||
|
shared_loader_obj=self._shared_loader_obj)
|
||||||
|
copy_result = copy_action.run(task_vars=task_vars)
|
||||||
|
if copy_result.get('failed'):
|
||||||
|
result['failed'] = copy_result['failed']
|
||||||
|
result['msg'] = copy_result.get('msg')
|
||||||
|
return
|
||||||
|
|
||||||
|
result['backup_path'] = copy_result['dest']
|
||||||
|
if copy_result.get('changed', False):
|
||||||
|
result['changed'] = copy_result['changed']
|
||||||
|
|
||||||
# strip out any keys that have two leading and two trailing
|
# strip out any keys that have two leading and two trailing
|
||||||
# underscore characters
|
# underscore characters
|
||||||
|
@ -74,20 +122,6 @@ class ActionModule(_ActionModule):
|
||||||
cwd = self._task._role._role_path
|
cwd = self._task._role._role_path
|
||||||
return cwd
|
return cwd
|
||||||
|
|
||||||
def _write_backup(self, host, contents, encoding='utf-8'):
|
|
||||||
cwd = self._get_working_path()
|
|
||||||
|
|
||||||
backup_path = os.path.join(cwd, 'backup')
|
|
||||||
if not os.path.exists(backup_path):
|
|
||||||
os.mkdir(backup_path)
|
|
||||||
for existing_backup in glob.glob('%s/%s_config.*' % (backup_path, host)):
|
|
||||||
os.remove(existing_backup)
|
|
||||||
tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time()))
|
|
||||||
filename = '%s/%s_config.%s' % (backup_path, host, tstamp)
|
|
||||||
open(filename, 'w').write(to_text(contents, encoding=encoding))
|
|
||||||
|
|
||||||
return filename
|
|
||||||
|
|
||||||
def _handle_template(self, convert_data=True):
|
def _handle_template(self, convert_data=True):
|
||||||
src = self._task.args.get('src')
|
src = self._task.args.get('src')
|
||||||
working_path = self._get_working_path()
|
working_path = self._get_working_path()
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}"
|
- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
eos_config:
|
eos_config:
|
||||||
commands:
|
commands:
|
||||||
|
@ -47,4 +55,80 @@
|
||||||
that:
|
that:
|
||||||
- "backup_files.files is defined"
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
eos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
eos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
eos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take config backup
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}"
|
- debug: msg="START cli/cli_backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -46,4 +46,80 @@
|
||||||
that:
|
that:
|
||||||
- "backup_files.files is defined"
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
ios_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
ios_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
ios_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli/cli_backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take config backup
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
|
@ -45,4 +45,79 @@
|
||||||
that:
|
that:
|
||||||
- "backup_files.files is defined"
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
iosxr_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
iosxr_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
iosxr_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take config backup
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
|
@ -0,0 +1,113 @@
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take config backup
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
|
@ -45,4 +45,80 @@
|
||||||
that:
|
that:
|
||||||
- "backup_files.files is defined"
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
junos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
junos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
junos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
- debug: msg="END netconf/backup.yaml on connection={{ ansible_connection }}"
|
- debug: msg="END netconf/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take config backup
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
|
@ -52,4 +52,80 @@
|
||||||
that:
|
that:
|
||||||
- "backup_files.files is defined"
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
nxos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
nxos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
nxos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
- debug: msg="END common/backup.yaml on connection={{ ansible_connection }}"
|
- debug: msg="END common/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
113
test/integration/targets/vyos_config/tests/cli/backup.yaml
Normal file
113
test/integration/targets/vyos_config/tests/cli/backup.yaml
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take configure backup
|
||||||
|
vyos_config:
|
||||||
|
backup: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
vyos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
vyos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
vyos_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}"
|
|
@ -0,0 +1,113 @@
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: delete configurable backup file path
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ role_path }}/backup_test_dir/"
|
||||||
|
- "{{ role_path }}/backup/backup.cfg"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- name: delete backup files
|
||||||
|
file:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{backup_files.files|default([])}}"
|
||||||
|
|
||||||
|
- name: take config backup
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: collect any backup files
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_files
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename and directory path
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-1 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
filename: backup.cfg
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-2 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup/backup.cfg"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- name: take configuration backup in custom path and default filename
|
||||||
|
cli_config:
|
||||||
|
backup: yes
|
||||||
|
backup_options:
|
||||||
|
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: check if the backup file-3 exist
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
|
||||||
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
|
register: backup_file
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "backup_file.files is defined"
|
||||||
|
|
||||||
|
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
|
Loading…
Reference in a new issue