saltstack / salt-winrepo

Salt Windows Software Package Manager Repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

torn between winrepo.genrepo syntax and sls syntax - can't "please" both

TheBigBear opened this issue · comments

Not sure how to navigate around this one. It might be a python quoting issue, but here goes.
when trying to run winrepo.genrepo on the master I get

Failed to compile /srv/salt/win/repo/sums/init.sls: while parsing a block mapping
  in "<string>", line 3, column 5:
        installer: 'http://www.nfllab.co ... 
        ^
expected <block end>, but found '<scalar>'
  in "<string>", line 6, column 157:
     ... tion ; $zip = $shell.NameSpace('c:\salt\var\cache\salt\minion\ex ... 
                                         ^

the sums.sls alpha quality sls file is:

sums:
  6.11:
    installer: 'http://www.nfllab.com/sums/sums611.zip'
    full_name: 'GNU coreutils sums (md5 sha1 sha224 sha256 sha384 sha512) ver. 6.11'
    reboot: False
    install_flags: ' ; @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$shell = new-object -com shell.application ; $zip = $shell.NameSpace('c:\salt\var\cache\salt\minion\extrn_files\base\nfllab.com\sums\sums611.zip') ; foreach($item in $zip.items()) { $shell.Namespace('c:\windows').copyhere($item,0x14) }"'
    uninstaller: 'cmd'
    uninstall_flags: '/c del /q /f %SystemRoot%\readme & del /q /f %SystemRoot%\copying & del /q /f %SystemRoot%\md5sum.exe & del /q /f %SystemRoot%\sha1sum.exe & del /q /f %SystemRoot%\sha224sum.exe & del /q /f %SystemRoot%\sha256sum.exe & del /q /f %SystemRoot%\sha384sum.exe & del /q /f %SystemRoot%\sha512sum.exe & exit 0'

The problem would appear to be the single quote in install_flags: line column 157. The open single quote before the c:\salt\var\cache\salt\minion\ex ...

What do I do? I tested it on the windows Powershell cmd line and powershell does need a single quote there, or it will give me an error, but the winrepo.genrepo chokes on it?

This issue is mostly interested in the syntax required to satisfy both winrepo.genrepo on the linux master and powershell on the windows minion.

Please ignore the silly attempt, to run an installer inside the 'install_flags:' parameter, afaik it probably won't work since the 'installer:" will fail as it is not an executable or actual installer, but merely a zip file. But I was hoping I coudl trick the salt into downloading the zip file for me into the local cache, and I coud then go fetch it from there and unpack it. But if you have a way to achive this, then please do point me to it. ;-)

Have you tried the multiline yaml syntax?

installer: |
  $zip = $shell.NameSpace('c:\salt\var\cache\salt\minion\ex...

I'm not 100% sure it will work, but it's worth a shot.

Great idea, thanks!

sums:
  6.11:
    installer: 'http://www.nfllab.com/sums/sums611.zip'
    full_name: 'GNU coreutils sums (md5 sha1 sha224 sha256 sha384 sha512) ver. 6.11'
    reboot: False
    install_flags: |
                   '@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$shell = new-object -com shell.application
                   $zip = $shell.NameSpace('c:\salt\var\cache\salt\minion\extrn_files\base\nfllab.com\sums\sums611.zip')
                   foreach($item in $zip.items()) { $shell.Namespace('c:\windows').copyhere($item,0x14) }"'
    uninstaller: 'cmd'
    uninstall_flags: |
                   '/c del /q /f %SystemRoot%\readme &
                   del /q /f %SystemRoot%\copying &
                   del /q /f %SystemRoot%\md5sum.exe &
                   del /q /f %SystemRoot%\sha1sum.exe &
                   del /q /f %SystemRoot%\sha224sum.exe &
                   del /q /f %SystemRoot%\sha256sum.exe &
                   del /q /f %SystemRoot%\sha384sum.exe &
                   del /q /f %SystemRoot%\sha512sum.exe &
                   exit 0'

Much, much more readable, and winrepo.genrepo compiles the blocks correctly again. ;-) Great teacher.

Can I run powershell code in the "installer:" block? Simply adding some PS download code to get the zip file and then unpack it?

Hm. When I wrote that, I didn't have in mind putting code directly in the installer section, but then again, neither did I forsee what you're doing with the uninstall_flags option either! lol :) So I'd say go ahead and try it.

I do want to go in and polish the windows package manager this year and the use cases you're coming up with will be at the top of my list.

Let me know how it goes putting code in the installer field.

Yes, this works great issue can be closed, as the solution is to use the multiline yaml syntax.