napalm-automation / napalm-salt

Modules for event-driven network automation and orchestration using Salt
Apache License 2.0
127 stars 36 forks source link

Request about usage #54

Open misch42 opened 5 years ago

misch42 commented 5 years ago

Hi,

I followed you setup in the README. A salt 'mydevice' test.ping works. Also all functions work. Nice work. Thanks.

But when I want to test a state, I get an error. According to the doc I add the ntp.peers to the device pillar:

cat /srv/pillar/mydevice.sls proxy:
proxytype: napalm
driver: junos
host: 192.168.1.2
username: admin

ntp.peers:

The answer of salt is: salt 'mydevice' state.sls mydevice.ntp
mydevice:
Data failed to compile:

No matching sls found for 'mydevice.ntp' in env 'base'

Any idea, what I got wrong?

Michael

misch42 commented 5 years ago

salt -V Salt Version: Salt: 2018.3.3

Dependency Versions: cffi: 1.11.5 cherrypy: Not Installed dateutil: 2.6.1 docker-py: Not Installed gitdb: 2.0.3 gitpython: 2.1.8 ioflo: Not Installed Jinja2: 2.10 libgit2: 0.26.0 libnacl: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.5.6 mysql-python: Not Installed pycparser: 2.19 pycrypto: 3.7.2 pycryptodome: Not Installed pygit2: 0.26.2 Python: 3.6.7 (default, Oct 22 2018, 11:32:17) python-gnupg: 0.4.1 PyYAML: 3.12 PyZMQ: 16.0.2 RAET: Not Installed smmap: 2.0.3 timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.2.5

System Versions: dist: Ubuntu 18.04 bionic locale: UTF-8 machine: x86_64 release: 4.15.0-43-generic system: Linux version: Ubuntu 18.04 bionic

mirceaulinic commented 5 years ago

Hi @misch42.

It is probably good to have the following distinction in mind: data goes into the Pillar, automation logic does into the State files (+ templates, when applicable). In the above you have correctly defined the Pillar data, however the State file is missing: when you execute state.sls mydevice.ntp, the State system is looking for a file named ntp.sls, under a directory named mydevice, physically located under one of the file_roots paths on the Master.

For example, if you have the following configuration on your Master:

file_roots:
  base:
    - /srv/salt
    - /srv/salt/states

If you place this State SLS file: https://github.com/napalm-automation/napalm-salt/blob/master/examples/router/ntp.sls under /srv/salt/states/ntp.sls you should be able to execute: salt 'mydevice' state.sls ntp.

misch42 commented 5 years ago

Thanks. That was the problem. But I think it will be easiery to work with formulas (napalm-ntp-formula) in real deployments.

mirceaulinic commented 5 years ago

I agree, the napalm-ntp-formula is probably the best (and in similar ways with anything else). The native NTP State is good enough, but can fall short in some particular cases, and it may be deprecated at some point.