Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

wrong path in deb packages #674

Open
@graf0

Description

@graf0

Hello!

When I try to compile to mof dsc resources under powershell 7 linux, I have following error:

ParserError: /home/graf0/test.ps1:1
Line |
   1 |  Configuration ExampleConfiguration
     |                ~~~~~~~~~~~~~~~~~~~~
     | System.Management.Automation.PSArgumentException: No files matching '/etc/opt/omi/conf/dsc/configuration/BaseRegistration/BaseResource.schema.mof' were found.    at
     | Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser.GetFileContent(String fullFilePath)    at
     | Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser.ParseSchemaMof(String filePath)    at
     | Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.ImportClasses(String path, Tuple`2 moduleInfo, Collection`1 errors, Boolean
     | importInBoxResourcesImplicitly)    at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.Initialize(Collection`1 errors, List`1 modulePathList)    at
     | Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Dictionary`2 functionsToDefine, Collection`1 errors, List`1 modulePathList,
     | Boolean cacheResourcesFromMultipleModuleVersions)    at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Collection`1 errors)
     | at System.Management.Automation.Language.Parser.ConfigurationStatementRule(IEnumerable`1 customAttributes, Token configurationToken)

Files are there - but on linux file names are case sensitive.
So we have:

/etc/opt/omi/conf/dsc/configuration/baseregistration/baseresource.schema.mof

Changing this to:

/etc/opt/omi/conf/dsc/configuration/BaseRegistration/BaseResource.schema.mof

seems to solve the problem.

Activity

Artalus

Artalus commented on Feb 5, 2021

@Artalus

Still happens with RPM at least in omi-1.6.6-0.ssl_100.ulinux.x64.rpm. Renaming files indeed helps.

a30000931

a30000931 commented on May 12, 2021

@a30000931

this is still an issue with:
dsc-1.1.1-926.x86_64

had to run this:
mv /etc/opt/omi/conf/dsc/configuration/baseregistration /etc/opt/omi/conf/dsc/configuration/BaseRegistration
mv /etc/opt/omi/conf/dsc/configuration/BaseRegistration/baseresource.schema.mof /etc/opt/omi/conf/dsc/configuration/BaseRegistration/BaseResource.schema.mof

how hard is it to get case right?

sql-sith

sql-sith commented on May 23, 2021

@sql-sith

Glad to find this - I was really wondering what I was doing wrong and didn't notice the casing at all.

Another workaround is to add lower-case symbolic links that point to the mixed-case names. This seems safer to me than renaming files supplied by the vendor. As far as I can tell, you only need to link one directory and one file:

cd /etc/opt/omi/conf/dsc/configuration
ln -s baseregistration ./BaseRegistration

cd ./baseregistration
ln -s baseresource.schema.mof BaseResource.schema.mof

Not a big difference, but this does work for me, plus, as I already mentioned, I don't have to actually change the MS files. With my luck, I bet MS will fix this in the next release and then I'll be wondering why I can't get through the install package.

gaelcolas

gaelcolas commented on Jun 21, 2021

@gaelcolas

Maybe something for @anmenaga to comment on, but in PSDSCv3 the BaseResource have changed to be within the PSDSC module.
I also suspect that this was fixed in PSDSCv2.0.5, but I don't know what this OMI package is shipping.

anmenaga

anmenaga commented on Jun 24, 2021

@anmenaga

This is a de-sync between v2 DSC code in SMA dll/PowerShell and whatever is deploying lower-cased files to /etc/opt/omi/conf/dsc/configuration - casing is hardcoded in v2 DSC code and will break when run on lower-cased files.

v2.0.5 PSDesiredStateConfiguration module on PS Gallery ships with baseregistrations in expected case, so theoretically another workaround that should work with v2.0.5 is to setup DSC_HOME env variable before starting configuration compilation. Something like this (assuming v2.0.5 PSDesiredStateConfiguration module is visible through $env:PSModulePath)

# to get v2.0.5 from PS Gallery run
# Install-Module -Name PSDesiredStateConfiguration -Repository PSGallery -MaximumVersion 2.99
#
$modulebase = Split-Path (Get-Module -ListAvailable -Name PsDesiredStateConfiguration | Select-Object -First 1 | ? {$_.Version -le '2.99'}).Path
$env:DSC_HOME = Join-Path $modulebase "Configuration"
if (Test-Path $env:DSC_HOME) { Write-Verbose -Verbose "Using DSC BaseRegistrations from $env:DSC_HOME" } else { Write-Error "DSC BaseRegistrations not found in $env:DSC_HOME" }
# now start configuration compilation
piotrminkina

piotrminkina commented on Nov 12, 2023

@piotrminkina

To work with PowerShell + DSC scripts on Ubuntu Linux, I had to do such patches, after installing OMI.

        echo 'Configuring LD Cache for OMI...'
        echo '/opt/omi/lib' >/etc/ld.so.conf.d/omi.conf
        ldconfig >/dev/null
        ldconfig --print-cache | grep 'libmi\.so' >/dev/null \
            && echo 'OMI libraries are available.' \
            || { echo 'OMI libraries are NOT available!'; return 1; }

        echo 'Fixing default OMI installation...'
        ln --symbolic --force --no-dereference \
            /etc/opt/omi/conf/dsc/configuration/baseregistration/ \
            /etc/opt/omi/conf/dsc/configuration/BaseRegistration
        ln --symbolic --force --no-dereference \
            /etc/opt/omi/conf/dsc/configuration/baseregistration/baseresource.schema.mof \
            /etc/opt/omi/conf/dsc/configuration/BaseRegistration/BaseResource.schema.mof

Scripts from DSC validates nicely in VSCode :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @graf0@sql-sith@piotrminkina@gaelcolas@Artalus

        Issue actions

          wrong path in deb packages · Issue #674 · microsoft/PowerShell-DSC-for-Linux