Re: [BangPypers] generating cisco config using templates?
Thanks for the example Nitin. This would work if yaml config file is a simple dictionary. In my case it is a bit complicated with dictionary and dictionary of list. What I have ended up doing is convert the create an object of the yaml data and pass on individual dictionaries and lists to template.rendrer. Works for me as I can now access individual dictionaries using the object in a pythonic way. I'll post the example on github once I am done with the code. (There are still a couple of challenges related to snmp user configuration of cisco devices. Cheers, Atul On Wed, Sep 30, 2015 at 10:07 PM, Nitin Kumarwrote: > Hi Atul, > > You can refer below link. This is an example which is used to configure > Juniper devices. > the code is using YAML and Jinja2 as you are looking for. > > https://github.com/vnitinv/pyez-examples/blob/master/6_load_temp_conf.py > > corresponding yaml and jinja2 template can be found at > https://github.com/vnitinv/pyez-examples > > > Nitin Kr > > On Wed, Sep 30, 2015 at 9:35 PM, Atul Tyagi wrote: > > > As I said I have not explored salt for network devices yet. It's more for > > system build automation. For this network device requirement I ended up > > writing my own python script to push the config to device. We can > probably > > use salt-ssh to integrate that into salt but I haven't explored it yet. > > > > On Wed, Sep 30, 2015 at 9:24 PM, kracekumar ramaraju < > > kracethekingma...@gmail.com> wrote: > > > > > On Wed, Sep 30, 2015 at 8:26 PM, Atul Tyagi > > wrote: > > > > > > > By the way I use salt here but it does not have a out of the box way > to > > > > manage network devices. Proxy stuff seemed too complicated to me so > > > haven't > > > > even given it a shot. > > > > > > > > > > > I am using Salt, if you can share some sample code, we can help. > > > ___ > > > BangPypers mailing list > > > BangPypers@python.org > > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > ___ > > BangPypers mailing list > > BangPypers@python.org > > https://mail.python.org/mailman/listinfo/bangpypers > > > ___ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] generating cisco config using templates?
Hi All, Has anyone tried to generate the cisco switch config using yaml + jinja. Any experience, best practices or ideas that you might want to share? I am trying to do this. It seems simple with a very basic yaml but it's getting extremely confusing as I expand by yaml and make it more readable (other than just key/value pairs Any suggestions please? Thanks, Atul ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] generating cisco config using templates?
Can you please specify what configuration you are trying to generate? Are you trying to configure multiple devices? If yes, you can try using the Ansible module, provided you aim for configuring devices issuing the master slave model. On Sep 30, 2015 19:11, "Atul Tyagi"wrote: > Hi All, > > Has anyone tried to generate the cisco switch config using yaml + jinja. > Any experience, best practices or ideas that you might want to share? > > I am trying to do this. It seems simple with a very basic yaml but it's > getting extremely confusing as I expand by yaml and make it more readable > (other than just key/value pairs > > Any suggestions please? > > Thanks, > Atul > ___ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] generating cisco config using templates?
Idea is to provision mds switches based on datacenter specifications. Since the template would be consistent I can generate multiple configs depending on what dc yaml is passed. We dont use ansible here so I have already written a python script usin netmiko to connect, scp the config to startup-config and the reload the device. Only missing peice right now is generating thw config. On 30 Sep 2015 19:58, "sayantan bhattacharya"wrote: > Can you please specify what configuration you are trying to generate? Are > you trying to configure multiple devices? > > If yes, you can try using the Ansible module, provided you aim for > configuring devices issuing the master slave model. > On Sep 30, 2015 19:11, "Atul Tyagi" wrote: > > > Hi All, > > > > Has anyone tried to generate the cisco switch config using yaml + jinja. > > Any experience, best practices or ideas that you might want to share? > > > > I am trying to do this. It seems simple with a very basic yaml but it's > > getting extremely confusing as I expand by yaml and make it more readable > > (other than just key/value pairs > > > > Any suggestions please? > > > > Thanks, > > Atul > > ___ > > BangPypers mailing list > > BangPypers@python.org > > https://mail.python.org/mailman/listinfo/bangpypers > > > ___ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] generating cisco config using templates?
By the way I use salt here but it does not have a out of the box way to manage network devices. Proxy stuff seemed too complicated to me so haven't even given it a shot. On 30 Sep 2015 20:23, "Atul Tyagi"wrote: > Idea is to provision mds switches based on datacenter specifications. > Since the template would be consistent I can generate multiple configs > depending on what dc yaml is passed. > > We dont use ansible here so I have already written a python script usin > netmiko to connect, scp the config to startup-config and the reload the > device. > > Only missing peice right now is generating thw config. > On 30 Sep 2015 19:58, "sayantan bhattacharya" wrote: > >> Can you please specify what configuration you are trying to generate? Are >> you trying to configure multiple devices? >> >> If yes, you can try using the Ansible module, provided you aim for >> configuring devices issuing the master slave model. >> On Sep 30, 2015 19:11, "Atul Tyagi" wrote: >> >> > Hi All, >> > >> > Has anyone tried to generate the cisco switch config using yaml + jinja. >> > Any experience, best practices or ideas that you might want to share? >> > >> > I am trying to do this. It seems simple with a very basic yaml but it's >> > getting extremely confusing as I expand by yaml and make it more >> readable >> > (other than just key/value pairs >> > >> > Any suggestions please? >> > >> > Thanks, >> > Atul >> > ___ >> > BangPypers mailing list >> > BangPypers@python.org >> > https://mail.python.org/mailman/listinfo/bangpypers >> > >> ___ >> BangPypers mailing list >> BangPypers@python.org >> https://mail.python.org/mailman/listinfo/bangpypers >> > ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] generating cisco config using templates?
Hi Atul, You can refer below link. This is an example which is used to configure Juniper devices. the code is using YAML and Jinja2 as you are looking for. https://github.com/vnitinv/pyez-examples/blob/master/6_load_temp_conf.py corresponding yaml and jinja2 template can be found at https://github.com/vnitinv/pyez-examples Nitin Kr On Wed, Sep 30, 2015 at 9:35 PM, Atul Tyagiwrote: > As I said I have not explored salt for network devices yet. It's more for > system build automation. For this network device requirement I ended up > writing my own python script to push the config to device. We can probably > use salt-ssh to integrate that into salt but I haven't explored it yet. > > On Wed, Sep 30, 2015 at 9:24 PM, kracekumar ramaraju < > kracethekingma...@gmail.com> wrote: > > > On Wed, Sep 30, 2015 at 8:26 PM, Atul Tyagi > wrote: > > > > > By the way I use salt here but it does not have a out of the box way to > > > manage network devices. Proxy stuff seemed too complicated to me so > > haven't > > > even given it a shot. > > > > > > > > I am using Salt, if you can share some sample code, we can help. > > ___ > > BangPypers mailing list > > BangPypers@python.org > > https://mail.python.org/mailman/listinfo/bangpypers > > > ___ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] generating cisco config using templates?
As I said I have not explored salt for network devices yet. It's more for system build automation. For this network device requirement I ended up writing my own python script to push the config to device. We can probably use salt-ssh to integrate that into salt but I haven't explored it yet. On Wed, Sep 30, 2015 at 9:24 PM, kracekumar ramaraju < kracethekingma...@gmail.com> wrote: > On Wed, Sep 30, 2015 at 8:26 PM, Atul Tyagiwrote: > > > By the way I use salt here but it does not have a out of the box way to > > manage network devices. Proxy stuff seemed too complicated to me so > haven't > > even given it a shot. > > > > > I am using Salt, if you can share some sample code, we can help. > ___ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] generating cisco config using templates?
On Wed, Sep 30, 2015 at 8:26 PM, Atul Tyagiwrote: > By the way I use salt here but it does not have a out of the box way to > manage network devices. Proxy stuff seemed too complicated to me so haven't > even given it a shot. > > I am using Salt, if you can share some sample code, we can help. ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers