NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Installing a Salt Minion on a 9627?

Solved!
Go to solution

Has anyone successfully installed a salt minion on a RT Linux RIO?  I couldn't find any salt packages for NI-Linux through the NI repositories, and I'm enough of a Linux newb that I have no idea how to take the source code from another distribution and compile for NI-Linux.

0 Kudos
Message 1 of 22
(6,292 Views)

We don't have salt packages on our repo yet, but you can install it manually. I am assuming some level of familiarity with linux & git, if you struggle with any of the steps below, please let me know.

1.- Git clone the salt repo on your target (you can clone it on a /tmp). The repo is located at https://github.com/saltstack/salt. You probably want to checkout the latest release branch (2016.3)

2 .- Move the salt/salt (nested salt folder) cloned repo folder into  /usr/lib/python2.7/site-packages/salt

3.- Copy the init script salt/scripts/salt-minion into /etc/init.d/. You can use update-rc.d to register the script to start/stop on boot/shutdown. Starting/Stopping on 25 should do the trick.

4.- Install the packages python, python-msgpack, python-pycrypto, python-pyzmq, python-pyroute2 via "opkg install <pacakge_name>"

5.- Reboot

I am writting the steps more or less from memory, so let me know if they don't work as-is. Also, be aware that due to the way we persist network settings on /etc/natinst/share/ni-rt.ini, some of the salt execution module calls for networking might not work (or the configuration won't persist across reboots). Other stuff, such as software management (opkg), date/time, etc, should work just fine.

Message 2 of 22
(5,157 Views)

Thanks Alejandro.  I'll start working through the steps and let you know where I run into problems.

0 Kudos
Message 3 of 22
(5,157 Views)

I've followed the steps and as near as I can tell it's gone okay.  I'll play around with it more in the coming days to see if I can get a salt server configured to connect it to.

A couple notes:

1.  I couldn't clone the latest release branch onto the target--there wasn't enough room.  I cloned it to my desktop vm and used sftp to copy the relevant files over.

2.  There is no "python-pyroute2" or similar named package available.

Alejandro_del_Castillo wrote:

Also, be aware that due to the way we persist network settings on /etc/natinst/share/ni-rt.ini, some of the salt execution module calls for networking might not work (or the configuration won't persist across reboots). Other stuff, such as software management (opkg), date/time, etc, should work just fine.

I take this to mean if we try to use salt to do network configuration tasks it may not work correctly?  Am I understanding you correctly?

0 Kudos
Message 4 of 22
(5,157 Views)

I take this to mean if we try to use salt to do network configuration tasks it may not work correctly?  Am I understanding you correctly?

Yep, the problem is that we keep network settings (such as hostname, IPs, etc) on /etc/natinst/share/ni-rt.ini, which is something unique about our distribution. Salt does not currently provides full support for our disto, so, when you change network settings via Salt you change them via calls to binaries such as hostname, etc, which don't interact with ni-rt.ini. There are different ways to solve this, but they are more involved (create a custom execution module). If you can stay away from changing network settings via Salt you will be better off....but you can always try it and see how things look.

Regarding pyroute, I believe it's used by some calls in the network execution module. You can try it without it....if you get errors you can always install pyroute via pip.

0 Kudos
Message 5 of 22
(5,157 Views)

I don't expect to be doing any network configuration using salt, so we should be okay there.

It turns out the install instruction didn't work quite right.  The files are all in place, the script appears to be registered correctly, but the service isn't running.  ps doesn't show anything salt related and salt commands are not found.  I've been digging through the documentation and found a few interesting things to run by you.  I'm not familiar enough with salt, python, and the peculiarities on ni-linux to know if these matter:

https://docs.saltstack.com/en/latest/topics/tutorials/standalone_minion.html

This document mentions if a minion can't connect to a master it will fail.  Would that failure shut down the service completely?  I also found many references to the minion configuration file in /etc/salt.  You didn't mention this in your instructions, so I've copied that file from the repo and I'm poking around in the options available.  Am I on the right track?

0 Kudos
Message 6 of 22
(5,157 Views)

Yes, I forgot to mention that you do need a salt configuration file (/etc/salt/minion) where you set the master that should control the minioin.

For debugging, I usually run the minion on the foreground, with debugging enabled, which can tell you more info on what might be going wrong. To run it on the foreground you need to run "salt-minion -l debug".  For instructions on how to get started, how to connect your minion to a master, etc, you can check the tutorials on the saltstack webiste: https://docs.saltstack.com/en/getstarted/, they are really good!

Answering some of your specific questions:

- if there is a failure, the salt minion does shutdown

- Copying the /etc/salt/minion file was the right call. You just need to set the master field, the other options can be left with the defaults.

- If you want to control the minion from a master, you don't need to use the minion in standalone mode

Message 7 of 22
(5,157 Views)

Clearly something isn't right with my minion installation on the target.  Attempts to start it by entering 'salt-minion' on the command line return command not found. 

I noticed the salt-master script in the repo I cloned is very different from the salt-master script on vm I installed the master on.  I suspect my problems on the target are related to the salt-minion script I copied in step 3 of your original instructions.  Here's the entire salt-minion script.  (The salt-master script in the repo is similar.)

#!/usr/bin/env python
'''
This script is used to kick off a salt minion daemon
'''

from salt.scripts import salt_minion

from salt.utils import is_windows

from multiprocessing import freeze_support

if __name__ == '__main__':

    if is_windows():

        # Since this file does not have a '.py' extension, when running on

        # Windows, spawning any addional processes will fail due to Python

        # not being able to load this 'module' in the new process.

        # Work around this by creating a '.pyc' file which will enable the

        # spawned process to load this 'module' and proceed.

        import os.path

        import py_compile

        cfile = os.path.splitext(__file__)[0] + '.pyc'

        if not os.path.exists(cfile):

            py_compile.compile(__file__, cfile)

    # This handles the bootstrapping code that is included with frozen

    # scripts. It is a no-op on unfrozen code.

    freeze_support()

    salt_minion()

0 Kudos
Message 8 of 22
(5,157 Views)

My step #3 was wrong:

3.- Copy the init script salt/scripts/salt-minion into /etc/init.d/. You can use update-rc.d to register the script to start/stop on boot/shutdown. Starting/Stopping on 25 should do the trick.

you need to copy that script into /usr/bin since that's the main salt-minion entry point. That's the python script that will start the minion and you can start debugging salt using it directly. Unfortunately, there is no ready as-is init script that will work for our distribution....but if you are willing to take the effort to try and debug, a script that might give you a good starting point is the one used on the salt recipe on Open Embedded: http://git.yoctoproject.org/cgit/cgit.cgi/meta-cloud-services/tree/meta-openstack/recipes-support/sa....

0 Kudos
Message 9 of 22
(5,157 Views)

Just to make sure I'm correctly understanding what you're telling me to do...

I take the script from the link you posted and put it into /usr/bin/salt-minion.  I should ignore salt/scripts/salt-minion from the repository.  Correct?

0 Kudos
Message 10 of 22
(5,157 Views)