-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os10_config backup option not working #113
Comments
I can confirm this. sample playbook: - hosts: switch
connection: network_cli
gather_facts: false
strategy: linear
tasks:
- name: fetch dellos10 config
dellos10_config:
backup: true
save: false
update: check
backup_options:
dir_path: /tmp/
filename: "{{ backup_filename }}"
when:
- ansible_network_os == "dellos10" a sample debug output:
The expected cfg ist not saved to the file! |
maybe related / duplicate of #102 |
as far as I can bisect this at a first try: 2.9
2.10
|
Finally leaves me with no good feeling in relying on this collection (unfortunately I have to!) ... |
just for the record in case it helps someone: my interim fix --- a/switch.yml
+++ b/switch.yml
@@ -35,43 +35,51 @@
- name: "save config to {{ switch_cfg_backup_dir }}"
vars:
ansible_become: yes
dellos6_config:
backup: yes
save: no
update: check
backup_options:
dir_path: "{{ switch_cfg_backup_dir }}"
filename: "{{ backup_filename }}.orig"
when:
- ansible_network_os == "dellemc.os6.os6"
- not ansible_check_mode
tags: always
+ register: r6
- name: "save config to {{ switch_cfg_backup_dir }}"
dellos10_config:
backup: yes
save: no
update: check
backup_options:
dir_path: "{{ switch_cfg_backup_dir }}"
filename: "{{ backup_filename }}.orig"
when:
- ansible_network_os == "dellemc.os10.os10"
- not ansible_check_mode
tags: always
+ register: r10
+ - name: save cfg to file
+ local_action:
+ module: copy
+ content: "{{ r6['__backup__'] if ansible_network_os == 'dellemc.os6.os6' else r10['__backup__'] }}"
+ dest: "{{ switch_cfg_backup_dir }}/{{ backup_filename }}"
+ tags: always |
@zerwes, i am checking on this, pls give me some time. will update once validated. |
@zerwes, I have executed the playbook on both ansible versions (ansible [core 2.12.0] & ansible 2.9.26) and its working for me. The Configuration changes are done and the configurations are saved in the specified file(junk.txt) on the ansible control system in the specified path(/tmp/bkups) Find the sample playbook which i have executed: |
|
Find the config file (junk.txt) on the ansible control system (/tmp/bkups) after executing the playbook: |
ansible 2.9.26: Find the execution log for reference
|
ansible [core 2.12.0]: Find the execution log for reference:
|
For me it does not work on ansible 2.12.1. Looks like you tested on ansible-core 2.12.0. Assuming you do retest on version 2.12.1 and it works for you, where do we go from here? I'm running ansible in a python virtual environment and installed ansible-core using pip install ansible-core. ansible-core 2.12.1 |
@allan-silverstein, yes mine also VM machine with Ubuntu. I have tested with ansible version 2.12.0 and ansible 2.9.26 and for both the version its working fine for me.
|
@allan-silverstein, i will try to execute on ansible version 2.12.1 also. meanwhile please can you share your playbook which you are testing. |
I included the playbook in the original post (see above under steps to reproduce) |
Hello @prasadapr. Thank you for looking into this. ---
- name: Configuration Retrieval Teseting
connection: ansible.netcommon.network_cli
gather_facts: false
hosts: all
collections:
- dellemc.os10
vars:
ansible_command_timeout: 120
dir_path: /tmp/bkups
filename: junk.txt
fp2b_filename: "{{ [dir_path, filename,] | path_join }}"
tasks:
- name: ensure old backup file is deleted
file:
path: "{{ fp2b_filename }}"
state: absent
- name: Retrieve Configuration
dellemc.os10.os10_config:
backup: true
backup_options:
dir_path: "{{ dir_path }}"
filename: "{{ filename }}"
lines:
- ip host junk1 1.1.1.1
- no ip host junk1
save: yes
- name: check if the backup file exists
stat:
path: "{{ fp2b_filename }}"
register: _statr
- name: assert the backup file exists
assert:
that: _statr.stat.exists
fail_msg: "gosh darn it! {{ fp2b_filename }} not found!"
success_msg: "yeah! {{ fp2b_filename }} is there!"
... And the result is for me:
Are you testing against a real device or a gns3 simulation? If I find the time, I will try to setup a molecule test with the combination of different OS, ansible and python versions. |
@allan-silverstein, as you mentioned i have tested on ansible 2.12.1 and its working fine for me. we have to declare
Please execute my below playbook in your ansible server with EX:
|
hello @prasadapr |
@zerwes, the presence of the desired backup file is not mandatory. without providing the Possible can you provide output log of the |
@zerwes, Please find the playbook without filename and dir_path.
Playbook execution and log:
|
https://github.com/ansible-collections/dellemc.os10/blob/master/plugins/modules/os10_config.py#L287 |
Hello @prasadapr ---
- name: Configuration Retrieval Teseting
connection: ansible.netcommon.network_cli
gather_facts: false
hosts: all
collections:
- dellemc.os10
vars:
ansible_command_timeout: 120
dir_path: /tmp/bkups
filename: junk.txt
fp2b_filename: "{{ [dir_path, filename,] | path_join }}"
tasks:
- name: ensure old backup file is deleted
file:
path: "{{ fp2b_filename }}"
state: absent
- name: Retrieve Configuration
dellemc.os10.os10_config:
backup: true
backup_options:
dir_path: "{{ dir_path }}"
filename: "{{ filename }}"
lines:
- ip host junk1 1.1.1.1
- no ip host junk1
save: yes
- name: check if the backup file exists
stat:
path: "{{ fp2b_filename }}"
register: _statr
- name: assert the backup file exists
assert:
that: _statr.stat.exists
fail_msg: "gosh darn it! {{ fp2b_filename }} not found!"
success_msg: "yeah! {{ fp2b_filename }} is there!"
... output:
|
- name: Retrieve Configuration
- dellemc.os10.os10_config:
+ os10_config:
backup: true output:
|
@zerwes, now with the collections and os10_config its working fine right. |
Sure @zerwes, will look in to the
|
@prasadapr yes, this can be closed; thank you for the clarification. |
Thanks @zerwes for the confirmation, so i am closing this issue. |
Thank you @prasadapr , this now works for me also. |
Thanks @allan-silverstein for the update. |
SUMMARY
Setting the backup option in the os10_config module does not work. The configuration file is not written to the playbook root directory or any other directory if the backup_options are specfied.
ISSUE TYPE
COMPONENT NAME
os10_config
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
This returned nothing
OS / ENVIRONMENT
fra02-wls01-msw01# show version
Dell EMC Networking OS10 Enterprise
Copyright (c) 1999-2020 by Dell Inc. All Rights Reserved.
OS Version: 10.5.2.2
Build Version: 10.5.2.2.258
Build Time: 2020-12-12T02:56:02+0000
System Type: S4148T-ON
Architecture: x86_64
Up Time: 17 weeks 1 day 17:15:01
fra02-wls01-msw01#
STEPS TO REPRODUCE
Running a simple playbook with the following command line:
ansible-playbook -vvv -i inventory -k config_bkups2.yaml
EXPECTED RESULTS
Configuration changes should be made and the the configuration should be saved to a file on the control system (The system that is executing the playbook).
ACTUAL RESULTS
The configuration of the device is changed but the configuration is never saved to the control system.
The text was updated successfully, but these errors were encountered: