Code Monkey home page Code Monkey logo

Comments (5)

punisherVX avatar punisherVX commented on July 20, 2024

Access ports can only have 1 VLAN assigned to them (as you know), so you will need to delete the vlan assignment before you push the config. It acts the same as if you were on the cmd line.
I would just add that to the Configuration File in your example, so it deletes the vlan stanza and then adds in the stanza that you want. I haven't tested this but it should be something similar to the following:

interfaces {
    ge-0/0/7 {
        description TEST;
        unit 0 {
            family ethernet-switching {
                port-mode access;
                delete: vlan; 
                vlan {
                    members VL0002;
                }
            }
        }
    }
}

This would be easier with the set command if you want to go that route.

from ansible-junos-stdlib.

cvicente avatar cvicente commented on July 20, 2024

Or use XML instead for your config format. It allows you to clearly specify which sections need to be merged, replaced or deleted. E.g.

<configuration>
  <interfaces>
      <name>ge-0/0/7</name>
          <description>TEST</description>
            <unit>
                <name>0</name>
                <family>
                    <ethernet-switching>
                        <port-mode>access</port-mode>
                        <vlan operation="replace">
                            <members>VL0002</members>
                        </vlan>
                    </ethernet-switching>
                </family>
            </unit>
      </interfaces>
</configuration>

XML has the added benefit of being more easily parsed, so you can do policy checks after your build all your configs.

from ansible-junos-stdlib.

punisherVX avatar punisherVX commented on July 20, 2024

Completely agree. Heck, for that matter even the set notation would be much easier, but the XML is the preferred method if you want to make it "smart"

from ansible-junos-stdlib.

gtrxcbdev avatar gtrxcbdev commented on July 20, 2024

Thanks I will give the XML a shot. I have previously tried using the
delete: vlan; statement with both the Ansible module and with a custom
python script using the junos-eznc module and neither worked (though it is
possible I did something wrong).

On Mon, Jun 15, 2015 at 12:01 PM, sdndude [email protected] wrote:

Completely agree. Heck, for that matter even the set notation would be
much easier, but the XML is the preferred method if you want to make it
"smart"


Reply to this email directly or view it on GitHub
#65 (comment)
.

from ansible-junos-stdlib.

shermdog avatar shermdog commented on July 20, 2024

Load Replace support provided by #71

from ansible-junos-stdlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.