Hello, This use case can be achieved through the new Resource Modules (*_vlans). The following tasks should give you an idea on how to implement it:
``` - name: Gather VLAN information as structured data ios_facts: gather_subset: - '!all' - '!min' gather_network_resources: - 'vlans' - name: Store VLAN facts to host_vars copy: content: "{{ ansible_network_resources | to_nice_yaml }}" dest: "{{ playbook_dir }}/host_vars/{{ inventory_hostname }}" ``` Now that you have the VLAN configuration preserved on the Ansible controller, you can update it and feed it to a task by referencing the `vlans` keys. ``` - name: Make VLAN config changes by updating stored facts on the controller. ios_vlans: config: "{{ vlans }}" state: merged tags: update_config ``` Thanks! -- Nilashish Chakraborty Senior Software Engineer, Ansible Network On Wed, Aug 5, 2020 at 10:56 PM Chui Hui Chiu <chiuchui...@gmail.com> wrote: > Hello, > > I'm trying to do the followings for a network switch. > (1) retrieve the current configuration of a VLAN. > (2) preserve the current VLAN configuration on the Ansible host. > (3) push the new configuration to the VLAN. > > However, the existing network modules for VLAN configuration can only push > the new configuration and return the current configuration in a single > module execution. For example, Module ios_vlans, junos_vlans, etc. > > Can I achieve what I am trying to do using any existing network modules? > If not, I would like to enhance the existing modules to allow retrieving > current configuration only. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to ansible-devel+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-devel/675a9293-2a12-4c6d-9a14-a83515e76f7co%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-devel/675a9293-2a12-4c6d-9a14-a83515e76f7co%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/CAODNBSHhLwkS2UufDpTUB5UFEJ%2BGrbkctgmHc%2B9mT_1x%3DHtw0w%40mail.gmail.com.