diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2019-01-24 09:36:16 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 09:36:16 +0530 |
commit | 70bf9b9919cd633938419f530ebfa8ec881dedfc (patch) | |
tree | 5aa434cd74cc44c0566554e09a730ac557cdc5fd /lib/ansible/modules/network/dellos9/dellos9_config.py | |
parent | fe8412128b843003d4e25d1976635708286f2e04 (diff) | |
download | ansible-70bf9b9919cd633938419f530ebfa8ec881dedfc.tar.gz |
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
Diffstat (limited to 'lib/ansible/modules/network/dellos9/dellos9_config.py')
-rw-r--r-- | lib/ansible/modules/network/dellos9/dellos9_config.py | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/lib/ansible/modules/network/dellos9/dellos9_config.py b/lib/ansible/modules/network/dellos9/dellos9_config.py index c63a651cdc..01a944a9b4 100644 --- a/lib/ansible/modules/network/dellos9/dellos9_config.py +++ b/lib/ansible/modules/network/dellos9/dellos9_config.py @@ -113,11 +113,33 @@ options: description: - This argument will cause the module to create a full backup of the current C(running-config) from the remote device before any - changes are made. The backup file is written to the C(backup) - folder in the playbook root directory. If the directory does not - exist, it is created. + changes are made. If the C(backup_options) value is not given, + the backup file is written to the C(backup) folder in the playbook + root directory. If the directory does not exist, it is created. type: bool 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: - This module requires Dell OS9 version 9.10.0.1P13 or above. @@ -152,6 +174,14 @@ EXAMPLES = """ parents: ['ip access-list extended test'] before: ['no ip access-list extended test'] replace: block + +- dellos9_config: + lines: ['hostname {{ inventory_hostname }}'] + provider: "{{ cli }}" + backup: yes + backup_options: + filename: backup.cfg + dir_path: /home/user """ RETURN = """ @@ -210,6 +240,10 @@ def get_running_config(module): def main(): + backup_spec = dict( + filename=dict(), + dir_path=dict(type='path') + ) argument_spec = dict( lines=dict(aliases=['commands'], type='list'), parents=dict(type='list'), @@ -226,7 +260,8 @@ def main(): update=dict(choices=['merge', 'check'], default='merge'), save=dict(type='bool', default=False), 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) |