salt icon indicating copy to clipboard operation
salt copied to clipboard

Windows file.managed broken

Open UtahDave opened this issue 13 years ago • 11 comments

Seems to have reappeared on Windows 7 with version 0.16.3 when trying to apply a small test state 'motd' (C:\MOTD directory already exists):

salt master is a linux box, salt minion is win 7

salt '*' state.highstate test=True
machine-name-redacted:
    State: - file
    Name:      c:\motd\motd
    Function:  managed
        Result:    False
        Comment:   An exception occurred in this state: Traceback (most recent call last):
  File "salt/state.py", line 1237, in call
  File "salt/states/file.py", line 828, in managed
  File "salt/modules/file.py", line 1397, in check_managed
  File "salt/modules/file.py", line 1187, in get_managed
NameError: global name '__salt__' is not defined

UtahDave avatar Aug 14 '13 16:08 UtahDave

I just tested this on "Microsoft Windows Server 2008 R2 Enterprise" and it worked fine. I'll test on a Windows 7 machine tomorrow.

Here's what i used for testing

root@mymachine:/srv/salt/motd# cat ./init.sls 
c:\motd\motd:
  file.managed:
    - source: salt://motd/motd
    - makedirs: True
root@demo-saltmaster:/srv/salt/motd# cat ./motd 
this is teh first message
This is the second message
root@mymachine:/srv/salt/motd# salt 'davetesting' state.sls motd
davetesting:
----------
    State: - file
    Name:      c:\motd\motd
    Function:  managed
        Result:    True
        Comment:   File c:\motd\motd updated
        Changes:   diff: New file


Summary
------------
Succeeded: 1
Failed:    0
------------
Total:     1

And then we can see that the file successfully copied down:

root@mymachine:/srv/salt/motd# salt 'davetesting' cmd.run 'type c:\motd\motd'
davetesting:
    this is teh first message
    This is the second message

UtahDave avatar Aug 17 '13 22:08 UtahDave

I just tested this on Windows 7 as well and it worked correctly. The search continues...

UtahDave avatar Aug 18 '13 00:08 UtahDave

I think this has been fixed in the latest bugfix release. Please download the latest Salt 0.16.3 windows installer from SaltStack.com for the fix.

UtahDave avatar Aug 18 '13 00:08 UtahDave

Hi,

Same issue for me on 2003. I can confirm that latest revision of 0.16.3 works, not the previous ;) !

Regards Pierre

equinoxefr avatar Aug 19 '13 13:08 equinoxefr

Yup, I can confirm the latest 0.16.3 has fixed this. Thank you very much!

smithjm avatar Aug 22 '13 22:08 smithjm

Hi.

I got a similar issue with file.seed. I have 0.16.3 My sls file is

c:/test.txt: file.sed: - before: 1 - after: 0 - limit: ^enabled=

I got

Executing job with jid 20130917151159248512

ssclientWin2:

State: - file
Name:      c:/test.txt
Function:  sed
    Result:    False
    Comment:   An exception occurred in this state: Traceback (most recent call last):

File "salt/state.py", line 1239, in call File "salt/states/file.py", line 1471, in sed File "salt/modules/file.py", line 563, in sed_contains NameError: global name 'salt' is not defined

    Changes:   

qqchose avatar Sep 17 '13 19:09 qqchose

Is file.sed supported in Windows, @UtahDave? Can't remember.

In any case, this should go in a new issue.

basepi avatar Sep 17 '13 22:09 basepi

Hi @UtahDave, sorry for reviving this rather old issue, but I seem to have the same issue on 0.17.4. When i try to highstate my minion i get the following output.

salt '*' state.highstate test=True
machine-name-redacted:
----------
  State: - file
  Name:      C:\salt\conf\minion.d\minion.conf
  Function:  managed
      Result:    False
      Comment:   An exception occurred in this state: Traceback (most recent call last):
File "salt/state.py", line 1305, in call
File "salt/states/file.py", line 1116, in managed
File "salt/modules/file.py", line 1797, in check_managed
File "salt/modules/file.py", line 1620, in get_managed
NameError: global name '__salt__' is not defined

I can however ping it without problems. The minion is running a clean version of windows 7 x64.

My state looks as follows

salt-minion-configuration:
    file.managed:
        - name: C:\salt\conf\minion.d\minion.conf
        - source: salt://salt/minion/minion.conf
        - mode: 655

jpihl avatar Jan 08 '14 12:01 jpihl

I think I may now what's going on here. Testing...

UtahDave avatar Jan 08 '14 18:01 UtahDave

@jpihl OK, so I've added some commits that should fix this. For now, the Salt minion doesn't support "mode" on Windows. It will just copy the file and let it inherit whatever the directory gives it. Eventually we're going to come up with a good way to use mode with icacls, but we're not there yet.

UtahDave avatar Jan 09 '14 21:01 UtahDave

So it appears its not just the mode, I'm still seeing the same issue with just this:

jboss-log4j: file.managed: - name: d:\Apps\jboss\server\default\conf\jboss-log4j.xml - source: salt://qaex/sectran/render/jboss/server/default/conf/jboss-log4j.xml

joshFive avatar Feb 11 '14 18:02 joshFive