deploying salt in a virtualenv

922 views
Skip to first unread message

schlag

unread,
Apr 13, 2013, 9:24:15 AM4/13/13
to salt-...@googlegroups.com
Hi,

I predominantly run Debian Squeeze on my servers and am trying to make my own packages with a stable version of pyzmq.  I know there is work being done on a saltstack debian repo, but I've basically had my fill of 0mq communication issues and want to use salt to it's full potential today.  My current approach is to install salt into a virtualenv and package it up using fpm.  My steps are as follows:

cd /usr/src
mkdir /usr/local/salt-0.14.0-437-g0dc0e12
virtualenv /usr/local/salt-0.14.0-437-g0dc0e12   
source /usr/local/salt-0.14.0-437-g0dc0e12/bin/activate
pip install M2Crypto && pip install pyzmq PyYAML pycrypto msgpack-python jinja2 psutil
pip install -e salt

I verify all of the pkgs are installed and whatnot, then package it up using fpm  eg

fpm -s dir -t deb -n "salt-master" -v 0.14.0-437-g0dc0e12 /usr/local/salt-0.14.0-437-g0dc0e12/ /etc/init.d/salt-master   # the init script was already in place

I install the deb on my build server, verify that it runs/works, toss it into my repo and install it on my salt master.  i've verified that all of the files are in place and whatnot, and that python2.6 is installed.

however, when i run it, i get this:

/etc/init.d/salt-master start
Starting salt-master daemon: :Traceback (most recent call last):
  File "/usr/local/salt-0.14.0-437-g0dc0e12/bin/salt-master", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 2603, in <module>
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 666, in require
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: salt==0.14.0-437-g0dc0e12
 failed!

i've also tried activating the virtualenv, and running it like this:

/usr/local/salt-0.14.0-437-g0dc0e12/bin# ./python ./salt-master 
Traceback (most recent call last):
  File "./salt-master", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 2603, in <module>
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 666, in require
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: salt==0.14.0-437-g0dc0e12


same with simply rsync'ing the directory over and taking fpm out of the equation.  i'm somehow not encapsulating the virtualenv properly.  i basically want all of the requirements baked into the virtualenv, with minimal dependencies on my system stuff/site-packages.   am I missing something obvious?


thanks in advance




Joe Healy

unread,
Apr 13, 2013, 9:34:20 AM4/13/13
to salt-...@googlegroups.com
I'm not completely on top of virtualenvs, but what is the #! line from
your /usr/local/salt-0.14.0-437-g0dc0e12/bin/salt-master file?
> --
> 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+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

schlag

unread,
Apr 13, 2013, 9:55:27 AM4/13/13
to salt-...@googlegroups.com
sure, thanks, it's this:

#!/usr/local/salt-0.14.0-437-g0dc0e12/bin/python



Joe Healy

unread,
Apr 13, 2013, 9:56:16 AM4/13/13
to salt-...@googlegroups.com
does that exist on your minions and other machines?

On Sat, Apr 13, 2013 at 11:55 PM, schlag <teknop...@gmail.com> wrote:
> sure, thanks, it's this:
>
> #!/usr/local/salt-0.14.0-437-g0dc0e12/bin/python
>
>
>>

Joe Healy

unread,
Apr 13, 2013, 9:58:18 AM4/13/13
to salt-...@googlegroups.com
On Sat, Apr 13, 2013 at 11:24 PM, schlag <teknop...@gmail.com> wrote:
> Hi,
>
> I predominantly run Debian Squeeze on my servers and am trying to make my
> own packages with a stable version of pyzmq. I know there is work being
> done on a saltstack debian repo, but I've basically had my fill of 0mq
> communication issues and want to use salt to it's full potential today. My
> current approach is to install salt into a virtualenv and package it up
> using fpm. My steps are as follows:
>
> cd /usr/src
> git clone https://github.com/saltstack/salt
> mkdir /usr/local/salt-0.14.0-437-g0dc0e12
> virtualenv /usr/local/salt-0.14.0-437-g0dc0e12
> source /usr/local/salt-0.14.0-437-g0dc0e12/bin/activate
> pip install M2Crypto && pip install pyzmq PyYAML pycrypto msgpack-python
> jinja2 psutil

Does this actually install zmq3.2?

From my quick test, I get the following warning:

Warning: Detected ZMQ version: 2.2.0, but pyzmq targets ZMQ 3.2.2.
Warning: libzmq features and fixes introduced after 2.2.0 will be unavailable.
ZMQ version detected: 2.2.0

I think you also need an updated libzmq.

I get 2.2.0+dfsg-2~bpo60+1 from backports.

This is the next aim after we get "official" builds next week.

Joe

schlag

unread,
Apr 13, 2013, 10:20:30 AM4/13/13
to salt-...@googlegroups.com
re zmpq.. yeah, it looks like it.  i took another approach by creating the virtualenv (using virtualenv :  /usr/local/bin/virtualenv /usr/local/salt-0.14.0-437-g0dc0e12 --no-site-packages), and installed the latest salt using 'pip install salt' instead of from source.  this is what my environment has:

pip freeze
Jinja2==2.6
M2Crypto==0.21.1
PyYAML==3.10
distribute==0.6.34
msgpack-python==0.3.0
pycrypto==2.6
pyzmq==13.0.2
salt==0.14.0
wsgiref==0.1.2

it runs fine on the build server.   if i toss this directory onto another server, activate the venv (i'm not even sure this is required?), i now get this when trying to start the daemons up:


(salt-0.14.0-437-g0dc0e12)root@testserver:/usr/local/salt-0.14.0-437-g0dc0e12/bin# ./salt-master 
Traceback (most recent call last):
  File "./salt-master", line 9, in <module>
    load_entry_point('salt==0.14.0', 'console_scripts', 'salt-master')()
  File "/usr/local/salt-0.14.0-437-g0dc0e12/lib/python2.6/site-packages/distribute-0.6.34-py2.6.egg/pkg_resources.py", line 343, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/salt-0.14.0-437-g0dc0e12/lib/python2.6/site-packages/distribute-0.6.34-py2.6.egg/pkg_resources.py", line 2307, in load_entry_point
    return ep.load()
  File "/usr/local/salt-0.14.0-437-g0dc0e12/lib/python2.6/site-packages/distribute-0.6.34-py2.6.egg/pkg_resources.py", line 2013, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/salt-0.14.0-437-g0dc0e12/lib/python2.6/site-packages/salt/__init__.py", line 13, in <module>
    from salt.utils import migrations
  File "/usr/local/salt-0.14.0-437-g0dc0e12/lib/python2.6/site-packages/salt/utils/__init__.py", line 23, in <module>
    import zmq
  File "/usr/local/salt-0.14.0-437-g0dc0e12/lib/python2.6/site-packages/zmq/__init__.py", line 44, in <module>
    raise ImportError("%s\nAre you trying to `import zmq` from the pyzmq source dir?" % e)
ImportError: libzmq.so.1: cannot open shared object file: No such file or directory
Are you trying to `import zmq` from the pyzmq source dir?

head -1 salt-master 
#!/usr/local/salt-0.14.0-437-g0dc0e12/bin/python

i'm using the latest version of virtualenv (1.9.1) fwiw

schlag

unread,
Apr 13, 2013, 10:25:21 AM4/13/13
to salt-...@googlegroups.com
i wasn't sure if this would be helpful, but here is a file listing of everything in teh venv  http://pastebin.com/NeKkP7GX

Joe Healy

unread,
Apr 13, 2013, 10:26:29 AM4/13/13
to salt-...@googlegroups.com
Do you put your venv on the minions you install to?

Also, how is the master/minion run in your init.d file?


On Sun, Apr 14, 2013 at 12:25 AM, schlag <teknop...@gmail.com> wrote:
> i wasn't sure if this would be helpful, but here is a file listing of
> everything in teh venv http://pastebin.com/NeKkP7GX
>

schlag

unread,
Apr 13, 2013, 11:12:46 AM4/13/13
to salt-...@googlegroups.com
i wasn't even messing with minions yet.  just trying to get any of the salt daemons to run at all on a host separate from my build box.   

i think i figured my problem out, though.  my build server had an old version of libzmq1 & libzmq-dev (which my test server does not have), and so pip/easy_install wasn't doing a complete install into the virtualenv.  i purged those pkgs and rebuilt the venv, rsync'ed it over to my test box and now both the master and minion daemons are able to run.  i'd assumed that if i specified --no-site-packages that the build process would compile & install everything in a container with all required deps.  note to self:  use build servers that have only the bare necessities.   now i need to figure out a plan to roll this out w/o breaking all my minions.

Joe Healy

unread,
Apr 13, 2013, 11:14:14 AM4/13/13
to salt-...@googlegroups.com
Good to see.

Joe
Reply all
Reply to author
Forward
0 new messages