--- - debug: msg="START common/save_config.yaml on connection={{ ansible_connection }}" - name: Setup by creating VLAN exos_config: lines: - create vlan 200 - name: Saving modified configuration in primary.cfg for the next startup exos_config: save_when: modified register: result - assert: that: - "result.changed == True" - name: Get the config file exos_command: commands: show switch register: result - name: Get the startup config file set_fact: config_selected='{{ result.stdout[0] | regex_search('(Config Selected:)\s+(\w+)', '\\2')}}' - name: Check if the primary config file has the changes exos_command: commands: "debug cfgmgr show configuration file {{ config_selected.0 }}" register: result - assert: that: - "result.stdout[0] is search('configure vlan VLAN_0200 tag 200')" - name: Idempotent save configuration exos_config: save_when: modified register: result - assert: that: - "result.changed == False" - name: Restore initial state by deleting vlan exos_config: lines: delete vlan 200 - name: Restore orignal primary cfg exos_config: save_when: modified - debug: msg="END common/save_config.yaml on connection={{ ansible_connection }}"