salt icon indicating copy to clipboard operation
salt copied to clipboard

salt masterless windows own modules do not work

Open belawaeckerlig opened this issue 12 years ago • 7 comments

Hi,

i have a problem using salt masterless on a windows minion. I have my own modules in the salt://_modules dir, but they will never copied to the cache directory.

I'm using the salt-call --local state.highstate command. but i don't think it performs a saltutil.sync_all, so the modules won't be copied. If i perform the sync_all manually, it hangs at MinionEvent PUB socket URI: ... like described here https://github.com/saltstack/salt/issues/8058

OS: Windows Server 2008 R2 x64 versions-report:

             Salt: 2014.1.5
           Python: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
           Jinja2: 2.7.1
         M2Crypto: 0.21.1
   msgpack-python: 0.4.2
     msgpack-pure: Not Installed
         pycrypto: 2.6
           PyYAML: 3.11
            PyZMQ: 14.1.1
              ZMQ: 4.0.4

belawaeckerlig avatar Jul 09 '14 10:07 belawaeckerlig

Thanks for the report!

@UtahDave have you seen behavior like this recently?

basepi avatar Jul 09 '14 22:07 basepi

I'd like to second this issue. I have a masterless Windows minion, and it does not load my custom modules from the salt://_modules location. I also tested a custom grain, and it was affected as well. I know the custom modules/grains are good, because they work as expected if I drop it directly in the main salt module/grain directory. I also mentioned the issue in the salt-users group in this thread, https://groups.google.com/d/msg/salt-users/klSf3MO8ruA/YBMaM_1FpA0J.

lorengordon avatar Aug 21 '14 15:08 lorengordon

I suffer from the same issue, but with the _states folder as described in this guide: http://docs.saltstack.com/en/latest/ref/states/writing.html#using-custom-state-modules. Masterless Windows minion as well. The minion debug log says:

[INFO ] Creating module dir 'c:\salt\var\cache\salt\minion\extmods\states' [INFO ] Syncing states for environment 'flagspeed' [INFO ] Loading cache from salt://_states, for flagspeed) [INFO ] Caching directory '_states/' for environment 'flagspeed' [DEBUG ] Local cache dir: 'c:\salt\var\cache\salt\minion\files\flagspeed_states'

However, after running state.highstate on the minion, the first cache folder mentioned is empty and the second one doesn't exist.

Zero3 avatar Sep 05 '14 22:09 Zero3

I tried digging around in the source to find the cause of this. From what I can see, the problem might be caused by this line not returning any files to be cached: https://github.com/saltstack/salt/blob/develop/salt/modules/saltutil.py#L95.

Rationale: If it did, this line would print stuff to the log which I'm not seeing: 123: log.info('Copying {0!r} to {1!r}'.format(fn_, dest))

Zero3 avatar Sep 05 '14 23:09 Zero3

Thanks for the updates. We haven't had time to look into this just yet, but it's on our radar!

basepi avatar Sep 08 '14 21:09 basepi

I think i've found the cause of this bug.

The fileclient is assuming files always come from the master:

https://github.com/saltstack/salt/blob/develop/salt/fileclient.py#L211

if not path.endswith('/'):
    path = path + '/'

Causing custom local grains, modules, etc. paths on Windows to never match this filter:

https://github.com/saltstack/salt/blob/develop/salt/fileclient.py#L222

if fn_.strip() and fn_.startswith(path):

eg. '_grains\\my_grains.py'.startswith('_grains/') == false

malfario avatar Oct 15 '14 11:10 malfario

This problem is still (or again) in 2015.2.0rc2 - see: #22796

obestwalter avatar Apr 16 '15 14:04 obestwalter