Cannot get proxy minion operating

348 views
Skip to first unread message

evt

unread,
Aug 15, 2017, 11:24:20 AM8/15/17
to Salt-users
Hi all,
I am brand new to Saltstack and I am trying to get a simple proxy minion operational to speak with a Junos device. Whenever I attempt to start the proxy, I get this:

[DEBUG   ] Could not LazyLoad junos.initialized: 'junos' __virtual__ returned False: Missing dependency: The junos proxy minion requires the 'jnpr' Python module.
[INFO    ] The following CRITICAL message may not be an error; the proxy may not be completely established yet.
[CRITICAL] Failed to load grains defined in grain file junos.facts in function <function facts at 0x7f4bacf2ea28>, error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 738, in grains
    ret = funcs[key](proxy)
  File "/usr/lib/python2.7/site-packages/salt/grains/junos.py", line 49, in facts
    if proxy is None or proxy['junos.initialized']() is False:
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1113, in __getitem__
    func = super(LazyLoader, self).__getitem__(item)
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 101, in __getitem__
    raise KeyError(key)
KeyError: 'junos.initialized'
[DEBUG   ] LazyLoaded junos.grains
[ERROR   ] Proxymodule junos is missing an init() or a shutdown() or both. Check your proxymodule.  Salt-proxy aborted.
[INFO    ] Proxy Minion Stopping the Salt ProxyMinion
[ERROR   ] Proxymodule junos is missing an init() or a shutdown() or both. Check your proxymodule.  Salt-proxy aborted.
[INFO    ] Shutting down the Salt ProxyMinion
The Salt ProxyMinion is shutdown.
Proxymodule junos is missing an init() or a shutdown() or both. Check your proxymodule.  Salt-proxy aborted.

I know I am missing something and it has to be incredibly obvious because the entire internet is devoid of this error. I do see the first message, indicating that the 'junos proxy minion requires the 'jnpr' Python module'. That seems obvious, but I have no idea what module that is, or how to install it, exactly. I have several modules installed on the proxy minion, none of which are 'jnpr':

junos-eznc (2.1.5)                             - Junos 'EZ' automation for non-programmers
  INSTALLED: 2.1.5 (latest)
jsnapy (1.2.0)                                 - Python version of Junos Snapshot Administrator
  INSTALLED: 1.2.0 (latest)
junos-netconify (1.0.2)                        - Junos console/bootstrap automation
  INSTALLED: 1.0.2 (latest)
napalm-junos (0.12.0)                          - Network Automation and Programmability Abstraction Layer with Multivendor support
  INSTALLED: 0.6.3
  LATEST:    0.12.0
pyJunosManager (0.6)                           - A simplified module to handle common Junos tasks
  INSTALLED: 0.6 (latest)

What is it that I am missing here? 

C. R. Oldham

unread,
Aug 15, 2017, 11:28:59 AM8/15/17
to salt-...@googlegroups.com
Good morning,

What version of Salt are you on?  I need to know so I can reference the right code and determine which module it's trying to import.

--cro


--cro
C. R. Oldham
Senior Platform Engineer, SaltStack

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/dc125d9a-62b5-4ac7-91e0-524e71e5d24b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

evt

unread,
Aug 15, 2017, 12:16:06 PM8/15/17
to Salt-users
Hi,
salt --version shows: 2017.7.0  (Nitrogen).
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.

C. R. Oldham

unread,
Aug 15, 2017, 12:33:53 PM8/15/17
to salt-...@googlegroups.com
[DEBUG   ] Could not LazyLoad junos.initialized: 'junos' __virtual__ returned False: Missing dependency: The junos proxy minion requires the 'jnpr' Python module.

This should be junos-eznc in 2017.7.0.
 
KeyError: 'junos.initialized'

[...]
 
I know I am missing something and it has to be incredibly obvious because the entire internet is devoid of this error. I do see the first message, indicating that the 'junos proxy minion requires the 'jnpr' Python module'. That seems obvious, but I have no idea what module that is, or how to install it, exactly. I have several modules installed on the proxy minion, none of which are 'jnpr':

junos-eznc (2.1.5)                             - Junos 'EZ' automation for non-programmers
  INSTALLED: 2.1.5 (latest)


So you do have junos-eznc installed.  Can you open a Python shell in the same context as where your Salt proxy is running (most likely just starting python as root) and try to import the same libraries that the module does?  Maybe you have a missing upstream dependency.

# python
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jnpr.junos
>>> import jnpr.junos.utils
>>> import jnpr.junos.utils.config
>>> import jnpr.junos.utils.sw

--cro

evt

unread,
Aug 15, 2017, 12:44:41 PM8/15/17
to Salt-users
Hi,
I was able to import all those without any errors:

Python 2.7.10 (default, Aug  7 2016, 20:45:01) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import jnpr.junos
>>> import jnpr.junos.utils
>>> import jnpr.junos.utils.config
>>> import jnpr.junos.utils.sw

I am assuming this needs to be done on the proxy machine, which is where I did this.

C. R. Oldham

unread,
Aug 15, 2017, 12:51:25 PM8/15/17
to salt-...@googlegroups.com
On Tue, Aug 15, 2017 at 10:44 AM, evt <ble...@gmail.com> wrote:
Hi,
I was able to import all those without any errors:

Python 2.7.10 (default, Aug  7 2016, 20:45:01) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import jnpr.junos
>>> import jnpr.junos.utils
>>> import jnpr.junos.utils.config
>>> import jnpr.junos.utils.sw

I am assuming this needs to be done on the proxy machine, which is where I did this.


That's correct.  So now I'm wondering if you have another junos proxy module besides the one in the Salt package.  Can you search your filesystem for junos.py?  You really should only have the following.

./salt/engines/junos_syslog.py
./salt/grains/junos.py
./salt/grains/junos.pyc
./salt/modules/junos.py
./salt/modules/junos.pyc
./salt/proxy/junos.py
./salt/proxy/junos.pyc
./salt/states/junos.py
./salt/states/junos.pyc

evt

unread,
Aug 15, 2017, 2:40:32 PM8/15/17
to Salt-users
Well, that's definitely different than what I have:


/usr/lib/python2.7/site-packages/salt/grains/junos.py
/usr/lib/python2.7/site-packages/salt/grains/junos.pyc
/usr/lib/python2.7/site-packages/salt/grains/junos.pyo
/usr/lib/python2.7/site-packages/salt/modules/junos.py
/usr/lib/python2.7/site-packages/salt/modules/junos.pyc
/usr/lib/python2.7/site-packages/salt/modules/junos.pyo
/usr/lib/python2.7/site-packages/salt/proxy/junos.py
/usr/lib/python2.7/site-packages/salt/proxy/junos.pyc
/usr/lib/python2.7/site-packages/salt/proxy/junos.pyo
/usr/lib/python2.7/site-packages/salt/states/junos.py
/usr/lib/python2.7/site-packages/salt/states/junos.pyc
/usr/lib/python2.7/site-packages/salt/states/junos.pyo
/usr/local/lib/python2.7/site-packages/ansible/module_utils/junos.py
/usr/local/lib/python2.7/site-packages/ansible/module_utils/junos.pyc
/usr/local/lib/python2.7/site-packages/ansible/utils/module_docs_fragments/junos.py
/usr/local/lib/python2.7/site-packages/ansible/utils/module_docs_fragments/junos.pyc
/usr/local/lib/python2.7/site-packages/napalm_junos/junos.py
/usr/local/lib/python2.7/site-packages/napalm_junos/junos.pyc
/usr/local/lib/python2.7/site-packages/ncclient/devices/junos.py
/usr/local/lib/python2.7/site-packages/ncclient/devices/junos.pyc

I seem to have three modules per salt directory. Should I uninstall the ansible and other modules?

C. R. Oldham

unread,
Aug 15, 2017, 5:36:07 PM8/15/17
to salt-...@googlegroups.com
On Tue, Aug 15, 2017 at 12:40 PM, evt <ble...@gmail.com> wrote:
Well, that's definitely different than what I have:

No, those should really not affect importing the Junos proxy module.

I just verified that I can start a 2017.7.0 Junos proxy minion, so it should work.

It seems like the root of the issue is here:

[DEBUG   ] Could not LazyLoad junos.initialized: 'junos' __virtual__ returned False: Missing dependency: The junos proxy minion requires the 'jnpr' Python module.
[INFO    ] The following CRITICAL message may not be an error; the proxy may not be completely established yet.
[CRITICAL] Failed to load grains defined in grain file junos.facts in function <function facts at 0x7f4bacf2ea28>, error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 738, in grains
    ret = funcs[key](proxy)
  File "/usr/lib/python2.7/site-packages/salt/grains/junos.py", line 49, in facts
    if proxy is None or proxy['junos.initialized']() is False:
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1113, in __getitem__
    func = super(LazyLoader, self).__getitem__(item)
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 101, in __getitem__
    raise KeyError(key)
KeyError: 'junos.initialized'

The message at the top is a red herring if you are able to import jnpr and friends from a Python command line.  Further down it seems to indicate that the proxy module might be missing the `initialized` function.  Versions of the module before 2016.3 didn't have that function.

So several things could cause that.  Stale .pyc and .pyo files are one--can you compare the dates on your Junos python files in modules, proxy, states, etc and make sure the .pyc and .pyo's have date stamps after the .py files?

Also, are you starting the proxy as root?  You can get away without running as root if you configure the other non-root options in /etc/salt/proxy, but you have to be sure that user can read all the other dependencies.  The quickest way to test is to start as root.

Finally, you might get more details if you start the proxy in the foreground with debug mode if you haven't already:

salt-proxy -l debug --proxyid junos

--cro

evt

unread,
Aug 16, 2017, 8:13:11 AM8/16/17
to Salt-users
So several things could cause that.  Stale .pyc and .pyo files are one--can you compare the dates on your Junos python files in modules, proxy, states, etc and make sure the .pyc and .pyo's have date stamps after the .py files?

They appear to, yes:


-rw-r--r-- 1 root root  14K Jul 12 14:08 junos_syslog.py
-rw-r--r-- 1 root root  12K Jul 17 15:34 junos_syslog.pyc
-rw-r--r-- 1 root root  12K Jul 17 15:34 junos_syslog.pyo
-rw-r--r-- 1 root root 1.3K Jul 12 14:08 junos.py
-rw-r--r-- 1 root root 2.0K Jul 17 15:34 junos.pyc
-rw-r--r-- 1 root root 2.0K Jul 17 15:34 junos.pyo
-rw-r--r-- 1 root root  40K Jul 12 14:08 junos.py
-rw-r--r-- 1 root root  36K Jul 17 15:34 junos.pyc
-rw-r--r-- 1 root root  36K Jul 17 15:34 junos.pyo
-rw-r--r-- 1 root root 3.6K Jul 12 14:08 junos.py
-rw-r--r-- 1 root root 4.3K Jul 17 15:34 junos.pyc
-rw-r--r-- 1 root root 4.3K Jul 17 15:34 junos.pyo
-rw-r--r-- 1 root root  17K Jul 12 14:08 junos.py
-rw-r--r-- 1 root root  18K Jul 17 15:34 junos.pyc
-rw-r--r-- 1 root root  18K Jul 17 15:34 junos.pyo 
 
Also, are you starting the proxy as root?  You can get away without running as root if you configure the other non-root options in /etc/salt/proxy, but you have to be sure that user can read all the other dependencies.  The quickest way to test is to start as root.

Yes, I am starting as root.
 
Finally, you might get more details if you start the proxy in the foreground with debug mode if you haven't already:

salt-proxy -l debug --proxyid junos

Yes, that is how I got the output above. Are there different debug levels where I can get more information?
 
Thanks for all your assistance so far.

evt

unread,
Aug 16, 2017, 2:18:02 PM8/16/17
to Salt-users
I ended up wiping my VM and starting over. I also ended up creating a second VM to act as the minion, whereas before, I was using a previously installed server. This time, it looks like I was able to get it to work:

[root@na1 salt]# salt 'vmx1' junos.facts
vmx1:
    ----------
    facts:
        ----------
        2RE:
            False
        HOME:
            /var/home/admin
        RE0:
            ----------
            last_reboot_reason:
                Router rebooted after a normal shutdown.
[...]

Thanks for your assistance, it is much appreciated. 

C. R. Oldham

unread,
Aug 16, 2017, 2:56:58 PM8/16/17
to salt-...@googlegroups.com
On Wed, Aug 16, 2017 at 12:18 PM, evt <ble...@gmail.com> wrote:
I ended up wiping my VM and starting over. I also ended up creating a second VM to act as the minion, whereas before, I was using a previously installed server. This time, it looks like I was able to get it to work:

That was probably a good idea, this was getting hard to debug.  Glad it got worked out.
Reply all
Reply to author
Forward
0 new messages