Coder Social home page Coder Social logo

dscr_application's People

Contributors

mkht avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

taliesins

dscr_application's Issues

Version handling

Hi,

Amazing DSC module, I really appreciate the hard work and the thoroughness you've put into it! 👍
I'm trying to build automated dev/test/staging/prod environments using DSC.
We need to control the .NET hosting bundle version (.NET, .NET Core, ASP.NET + Core) versions in the environments, so we don't run on version i.e. 6.0.8 in Dev, 6.0.11 in Test and 6.0.13 in Staging/Prod.

So I check and uninstall any "wrong" versions in a PreAction script - works perfect!

But the installed version consists of 4 versions fields, Major, Minor, Build and Revision.

We would like developers to specific i.e. "6.0.8" in the variable and leave the rest of script to handle rest - which works fine.
This would look like:
image

But the actual installed version looks like this:
image

So when the DSC tries to compare versions, they don't match, because of the Revision field.
And we have to match on the Major, Minor and Build versions only.

Any idea how I can do this with the Version and UseSemVer checks?

cApplication dotnetHostingBundle {
    Name            = "Microsoft .NET [\.\d]+ - Windows Server Hosting"
    Fuzzy           = $true
    UseSemVer       = $true
    PreAction       = $VersionCheckScriptBlock
    Version         = "=$InputVer"
    InstallerPath   = $dotNetURL
    Arguments       = '/install /passive /norestart'
    Credential      = $domainAdminCredentialNetBios
    ReturnCode      = 0,3010
    NoRestart       = $true
}

As this way it comes back with:
[[cApplication]dotnetHostingBundle] The application "Microsoft .NET [.\d]+ - Windows Server Hosting" is installed. but NOT match your desired version. (Desired version: "6.0.8", Installed version: "6.0.8.22363")

And I can't use ">=$InputVer" and that would also make the check think 6.0.9+ is OK.

.Revision is updated during normal patching and this version change is accepted by the test department.

So I need to do an exact version match, but only on Major.Minor.Build.

In the PreAction script I do it like this:
If ([Version]::new($RequestedVer.Major,$RequestedVer.Minor,$RequestedVer.Build) -ne [Version]::new($InstalledVer.Major,$InstalledVer.Minor,$InstalledVer.Build)) {

Any idea how I can achieve this, without having to

Errors may occur in environments with few installed applications

HKLMにインストールされたソフトが1つしかない環境でTest-TargetResource実行時に以下の例外が発生する

[System.Management.Automation.PSObject] に 'op_Addition' という名前のメソッドが含まれないため、メソッドの呼び出しに失敗しました。
発生場所 行:7 文字:9
+         $local:InstalledPrograms += Get-ChildItem $UninstallRegUser | ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Addition:String) []、RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

Application names including regex/wildcard characters

$local:InstalledPrograms += Get-ChildItem $UninstallRegMachine | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_.DisplayName }
if (Test-Path $UninstallRegUser) {
$local:InstalledPrograms += Get-ChildItem $UninstallRegUser | ForEach-Object { Get-ItemProperty $_.PSPath } | Where-Object { $_.DisplayName }
}

I have an application which is named like MyApp [domain.com-5EF64F32]. This is an application from a relatively popular vendor and I have no influence over the naming. I believe it updates the CRC32 every update.

Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard character pattern is not valid: MyApp [domain.com-5EF64F32]
At line:4 char:83
+ ... stallRegMachine | ForEach-Object { Get-ItemProperty $_.PSPath } | Whe ...
+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
    + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand

Changing the above instances to a literalpath resolves this issue:

Get-ItemProperty -LiteralPath $_.PSPath

Error occurred when a FTP URL is specified to InstallerPath

DSC configuration for reproduce

cApplication AcrobatReader_Installed
    {
        Ensure = 'Present'
        Name = '^Adobe Acrobat Reader DC'
        Fuzzy = $true
        InstallerPath = 'ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1900820071/AcroRdrDC1900820071_ja_JP.exe'
        Arguments = '/sAll /rps /msi DISABLEDESKTOPSHORTCUT=1'
        NoRestart = $true
    }

Error ouput

詳細: [DESKTOP-17N8DUH]:                            [[cApplication]AcrobatReader_Installed] The application "^Adobe
Acrobat Reader DC" is not installed.
詳細: [DESKTOP-17N8DUH]:                            [[cApplication]AcrobatReader_Installed] Mismatch desired state &
current state. Return "False"
詳細: [DESKTOP-17N8DUH]: LCM:  [ 終了     テスト      ]  [[cApplication]AcrobatReader_Installed]  (0.0470 秒)。
詳細: [DESKTOP-17N8DUH]: LCM:  [ 開始     設定       ]  [[cApplication]AcrobatReader_Installed]
詳細: [DESKTOP-17N8DUH]:                            [[cApplication]AcrobatReader_Installed] Ensure = "Present". Try to
install an application.
詳細: [DESKTOP-17N8DUH]:                            [[cApplication]AcrobatReader_Installed] Use Installer
("ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1900820071/AcroRdrDC1900820071_ja_JP.exe") for Install. (if the
path of installer as http/https/ftp. will download it)
Microsoft.PowerShell.Commands.WriteErrorException: System.Management.Automation.RuntimeException: このオブジェクトにプ
ロパティ 'AllowAutoRedirect' が見つかりません。プロパティが存在し、設定可能であることを確認してください。
   場所 System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception
exception)
   場所 System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   場所 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   場所 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   場所 System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   場所 System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   場所 System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToPro
cess)
   場所 System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
   場所 System.Management.Automation.CommandProcessorBase.Complete()
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-TargetResource
    + PSComputerName        : localhost

詳細: [DESKTOP-17N8DUH]: LCM:  [ 終了     設定       ]  [[cApplication]AcrobatReader_Installed]  (0.0930 秒)。

InstallerPathのURLがダイレクトリンクではない場合にダウンロードに失敗する

例えば、

InstallerPath = 'http://hoge.local/install.exe'

のようにファイルへの直接リンクであれば問題ないが、

InstallerPath = 'https://download.mozilla.org/?product=firefox-54.0.1&os=win&lang=ja'

のようなリダイレクトされるタイプのURLを指定するとダウンロードに失敗してエラーになる

詳細: [DESKTOP-MHVP83I]: [[cApplication]Install::[cFirefox]FireFox_Install] Use Installer ("https://download.mozilla.org/?product=firefox-54.0.1&os=win&lang=ja") for Install. (if the path of installer as http/https/ftp. will download it)
詳細: [DESKTOP-MHVP83I]: [[cApplication]Install::[cFirefox]FireFox_Install] Download file from 'https://download.mozilla.org/?product=firefox-54.0.1&os=win&lang=ja' to 'C:\Windows\TEMP\?product=firefox-54.0.1&os=win&lang=ja'
指定されたファイルが見つかりません。
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-TargetResource
    + PSComputerName        : localhost
 
引数が空の文字列であるため、パラメーター 'Path' にバインドできません。
    + CategoryInfo          : InvalidData: (:) []、CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
    + PSComputerName        : localhost

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.