Saltstack [SOLVED]: saltstack: run powershell script in a state

Saltstack [SOLVED]: saltstack: run powershell script in a state

Home Forums Automation Tools Saltstack Tutorials Saltstack [SOLVED]: saltstack: run powershell script in a state

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #161740

    Cloudy Point
    Keymaster

    QuestionQuestion

    I’m trying to download uru from bitbucket and try to install using vagrant with default login credentials. I’m able to download the archive. When ever I try to run the script see this error – Invalidly-formated env parameter. See documentation. I’m able to run the script without any errors. I’m running this locally using vagrant in masterless mode. Any help is really appreciated.

    download_uru:
      file.managed:
        - name: c:uru-0.8.3-windows-x86.7z
        - source: https://bitbucket.org/jonforums/uru/downloads/uru-0.8.3-windows-x86.7z
        - source_hash: sha256=f2a7b4ed8ef6b02613b134da19a31293c7423e8fbbd8e49ec5c1c86c5f3a0815
    
    install_uru:
      cmd.run:
        - source: salt://ruby/files/install_uru.ps1
        - shell: powershell
        - env: "-ExecutionPolicy bypass"
        - runas: "vagrant"
        - password: "vagrant"
        - require:
          - file: download_uru
    

    $cat install_uru.ps1

    set-alias sz "$env:ProgramFiles7-Zip7z.exe"
    
    sz x -oC: C:uru-0.8.3-windows-x86.7z -r ;
    

    c:saltsalt-call.bat –version

    salt-call 2016.11.3 (Carbon)

    #161741

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    Your problem is due to the wrong format of the -env parameter. As described in the official documentation it must be a list and you are setting a string.

    Fix the install_uru state like the code below and it will run correctly.

    install_uru:
      cmd.run:
        - source: salt://ruby/install_uru.ps1
        - shell: powershell
        - env: 
          - ExecutionPolicy: "bypass"
        - runas: "vagrant"
        - password: "vagrant"
        - require:
          - file: download_uru
    

    Source: https://stackoverflow.com/questions/45361995/saltstack-run-powershell-script-in-a-state
    Author: alejdg
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.