Code Monkey home page Code Monkey logo

powershell-dsc-for-linux's Issues

nxService Resource MOF Doesn't Match nxService MOF included in nx-PSModule.zip

The src MOF for nxService here: https://github.com/MSFTOSSMgmt/WPSDSCLinux/blob/master/dsc/Providers/nxService/MSFT_nxServiceResource.schema.mof doesn't match the one included in the nx-PSModule.zip file in the v1.0.0-CTP release. One references systemd and the other references serviced.

Trying to check service status as follows:

nxService DockerService
{
    Name = "docker.io"
    Controller = "serviced"
    Enabled = $true
    State = "Running"
}

But getting a SendConfigurationApply function did not succeed error. Here is a more detailed error as well:

Traceback (most recent call last):
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 21, in Set_Marshall
    retval = Set(Name, Controller, Enabled, State)
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 573, in Set
    if ServiceExistsInSystemd(sc):
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 394, in ServiceExistsInSystemd
    (process_stdout, process_stderr, retval) = Process([systemctl_path, "status", sc.Name])
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 85, in Process
    process = subprocess.Popen(params, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib/python3.4/subprocess.py", line 848, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1446, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/systemctl'

nxComputer requires Name?

I'm not sure if this is a bug or intentional but when using nxComputer to set the timezone it requires you to specify Name as well. Since the mof is compiled on a separate Windows machine, and you may not know the future machine name at compile time, this presents an issue.

I was able to work around it by writing my own script to modify the timezone using nxScript but that isn't ideal.

I think it's a problem with the rights to a custom log

4/21/2017 7:05:28.257 PM | Operation
...TimeGenerated:4/21/2017 7:05:28.257 PM
...Computer:ECDL0101
...Detail:Two successive configuration applications from OMS Settings failed – please report issue to github.com/Microsoft/PowerShell-DSC-for-Linux/issues
...OperationCategory:OMS Agent for Linux issue
...Solution:Log Management
...SourceSystem:OpsManager
...SourceComputerId:4d6189c4-4bd0-41f9-812a-035825404c8b
...OperationStatus:Warning

Mof file size limit?

When running StartDscConfiguration.py on Ubuntu 14.04 LTS the execution fails immediately with the error "/opt/omi/bin/omicli: result: MI_RESULT_FAILED"

The dsc.log does not show new entries and the omiserver.log shows this:
"WARNING: null(0): EventId=30127 Priority=WARNING Socket: 0x13a9240, Error BatchSize while reading header"

This error is happening everytime I run a .mof file bigger than 23KB.
If I just remove some comments, for example, that I have on my batch scripts to make the mof file smaller than 24KB it works fine.

Unable to invoke DSC resources

Hello I am trying to use the nxComputerManagement DSC resource, i have a win2k12r2 machine which has WMF 5.0 installed, when i try to test it out below i get the below error.

Configuration MyDSCDemo {

Import-DSCResource -Module nx
Import-DSCResource -Module nxComputerManagement
Import-DSCResource -Module nxNetworking

Node "10.18.7.22" {

    nxFile myTestFile {

        Ensure = "Present" 
        Type = "File"
        DestinationPath = "/tmp/dsctest"   
        Contents="This is my DSC Test!"

    }

   nxComputer ComputerSettings{
   Name = "mylinuxhost_dsc"
   DNSDomainName = "contoso.com"
   TimeZoneName = "US/Pacific"
}

    nxService FWD{

        Name = "firewalld"
        Enabled = $true
        State = "Running"
        Controller = "systemd"

    }



}

}

Set-Location C:\scripts
MydscDemo

$Credentials = get-credential
$CimOptions = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl -SkipRevocationCheck
$CimSession = New-CimSession -Credential $Credentials -ComputerName 10.18.7.22 -port 5986 -Authentication Basic -SessionOption $CimOptions

<#
$Credentials = get-credential
$CimOptions = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl -SkipRevocationCheck
$CimSession = New-CimSession -Credential $Credentials -ComputerName 10.18.7.22 -port 5986 -Authentication Basic -SessionOption $CimOptions

>

Get-CimInstance -CimSession $CimSession -namespace root/omi -ClassName omi_identify

Start-DscConfiguration -CimSession $CimSession -wait -Verbose -Path C:\scripts\MyDSCDemo

I have the PSDSC for linux installed from https://www.microsoft.com/en-us/download/details.aspx?id=49150

image

Fix issues around building DSC

The current process outlined in the main page doesn't work for building DSC. There is a PR #317 that captures the current process. Once the workarounds in that document are fixed, the main repo page needs to be updated with the right set of instructions.

nxService with systemd fails on CentOS / RHEL 7

ServiceExistsInSystemd fails due to wrong encoding checking due to terminal escape sequences included in the output of systemctl status service_name

Traceback (most recent call last):
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 21, in Set_Marshall
    retval = Set(Name, Controller, Enabled, State)
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 576, in Set
    if ServiceExistsInSystemd(sc):
  File "/opt/omi-1.0.8/lib/Scripts/nxService.py", line 396, in ServiceExistsInSystemd
    if sc.Name + ".service" in process_stdout:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 343: ordinal not in range(128)

ModuleName in mof file is "PSDesiredStateConfiguration", should be "nx"

When I create a DSC config from Linux Powershell (beta3 on ubuntu) using a Linux DSC resources like nxFile, the resulting mof is a not usable, because the the ModuleName is not correct

config:

Configuration LinuxDSC {
	Import-DscResource -Module nx
	node $AllNodes.nodename
	{
		nxFile "testfile"
		{
		DestinationPath = "/root/testfile_fromdsc.txt"
		Contents = "some content in the file"
		mode = "744"
		}
	}
}

mof:

@TargetNode='localhost'
@GeneratedBy=root
@GenerationDate=06/29/2017 01:10:21
@GenerationHost=linux
*/

instance of MSFT_nxFileResource as $MSFT_nxFileResource1ref
{
Mode = "744";
 Contents = "some content in the file";
 --->ModuleName = "PSDesiredStateConfiguration";<---
 SourceInfo = "/root/powershell/ScriptsAndModules/DSC_Tool/config.ps1::7::2::nxFile";
 ResourceID = "[nxFile]testfile";
 DestinationPath = "/root/testfile_fromdsc.txt";

ModuleVersion = "1.0";

 ConfigurationName = "LinuxDSC";

};
instance of OMI_ConfigurationDocument


                    {
 Version="2.0.0";


                        MinimumCompatibleVersion = "1.0.0";


                        CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};


                        Author="root";


                        GenerationDate="06/29/2017 01:10:21";


                        GenerationHost="linux";


                        Name="LinuxDSC";


                    };

Issue with using derived classes in MOF

Although I am using DSC on Windows, I am opening this issue in this Repository because a Google search for the error message I am getting only pointed me here.

The module validator is complaining when attempting to define a derived class in the MOF file because the class does not derive from either of the OMI_BaseResource or MSFT_DSCMetaConfiguration classes:

https://github.com/Microsoft/PowerShell-DSC-for-Linux/blob/4212394433c74e1194ca9059996340f1d012e6b8/dsc/LCM/dsc/engine/ModuleLoader/ModuleLibrary/ModuleValidator.c#L485

I believe the validation rule should be more like "check whether any of the classes in the MOF file derives from either of the OMI_BaseResource or MSFT_DSCMetaConfiguration classes", not "check whether every derived class derives from either of the OMI_BaseResource or MSFT_DSCMetaConfiguration classes".

In my case, I am trying to define a family of interchangeable classes where any one of the classes can be used to configure a certain property of the resource class.

MUST RE-FORK REPOSITORY (Large files in history)

I noticed when cloning a superproject that uses DSC that, while the working tree is small, the repository itself is massive. I ran a quick script to identify the files, and it looks like we have some large tarballs in the history of ext:

69481257 ext/boost/boost_1_55_0.tar.gz
16843278 ext/python/Python-3.3.4.tgz
14725931 ext/python/Python-2.7.6.tgz
13318547 ext/python/Python-2.6.6.tgz
12787688 ext/python/Python-3.2.3.tgz
11019675 ext/python/Python-2.5.tgz
9239975 ext/python/Python-2.4.2.tgz

My feeling is that we really don't want Boost and Python distributions in our history. While they've been removed at some point, we likely want to run a filter-branch to purge them (unfortunately rewriting master again).

@jeffaco What are your thoughts on this?

WaitforAll Resources for Linux

Hi,

Wondering if the WMI Resource for DesiredStateConfigurationProxy that is utilized for the WaitforAll resources for internode dependencies on the Windows side can be implemented for the OMI side to allow for similar functionality....having little experience in this space was hoping if someone would be able to answer if this was possible or on the roadmap?

Thanks
Mattt

distro-friendly build mode

Hi! I'm currently working on packaging omi and would like to get your thoughts on how to better lay out the code to build the Linux DSC provider. You currently need the OMI source code to be present to build the provider but in turn this build the full OMI project including the omiserver. I'm trying to understand whether I can package OMI and the provider as different packages, or if I need to build them as a single package. What specific files are modified or created from a filesystem standpoint when building this project vs. only building OMI? Thanks.

Error as a result of nxPackage misconfiguration not being helpfull

I closed #248 after I finally figured out I had a misconfiguration for the nxPackage resource.
By accident I configured the packagemanager to be apt-get instead of yum for my CentOS box.
The error return when applying the configuration wasn't helpful. I actually believed the problem to be with the DSC package in combination with the newer OMI versions instead of a resource error.

9de5f6a6-1bdf-11e7-84e7-eb15e582be5f

a861dd20-1bdf-11e7-974d-772b4508c4b5

High CPU usage by omiserver

Hi,

We had a problem with a VM where the cx notice high CPU usage by the omiserver process,
the cx remediate the situation by rebooting his VM.

Looking at the omiserver.log below there a lot of error message at that exact time related to getpwnam,
can you tell me what is the cause of the error, what is the impact and if there is anything that can be done to prevent it from occurring again ?

Also the cx is using omiserver v1.2, should he upgrade to 1.3 ?

$ /opt/omi/bin/omiserver --version
/opt/omi/bin/omiserver: OMI-1.2.0-35 - Thu Mar  2 17:03:20 PST 2017

Thanks,
Johan

Full log: omiserver.log

WARNING: null(0): EventId=30072 Priority=WARNING getpwnam_r filed, errno 24
WARNING: null(0): EventId=30071 Priority=WARNING get user [root] uid/gid

reference: microsoft/OMS-Agent-for-Linux#536

Loading the instance document from the pending location did not succeed.

Apologies if this is not the correct place to be posting this, however I haven't found anywhere else more appropriate to post this.

This is the command I am running, and the output (executed at approximately 2016/04/28 15:54):

`Start-DscConfiguration -CimSession $LinuxServer -Verbose -Wait -Path .\DSCLinux02
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsof
t/Windows/DesiredStateConfiguration'.
Loading the instance document from the pending location did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : OMI:MI_Result:1
    + PSComputerName        : 10.0.0.7

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.12 seconds`

The following Config File and MOF File output are below:
DSC Config File:
https://gist.github.com/anonymous/0eb1dbe2262e8e5fa512a5cb18761858
MOF File:
https://gist.github.com/anonymous/854084c85fe92dd223f762827851257b

Here are the log files from the CentOS box:
dsc.log:
http://paste.fedoraproject.org/360943/16005146/
miclient.log:
http://paste.fedoraproject.org/360946/19168391
omiagent.root.root.log:
http://paste.fedoraproject.org/360947/14619168
omiserver.log:
http://paste.fedoraproject.org/360948/46191686

Any help would be much appreciated.

Python <defunct> processes building from omsagent

I was asked to move this issue from OMSagent to here.

I am running omsagent 1.4.0-45 and I am noticing a build up of python process.

Z 47193 21645 python <defunct>
Z 47193 21648 python <defunct>
Z 47193 21651 python <defunct>
Z 47193 21654 python <defunct>
Z 47193 21660 python <defunct>
Z 47193 21680 python <defunct>

[root@localhost ~]# ps aux | grep 47193
omsagent 47193 4.4 0.1 688316 25816 ? Sl 08:52 9:15 /opt/omi/bin/omiagent 10 13 --destdir / --providerdir /opt/omi/lib --loglevel WARNING

If I kill the omsagent process , the zombie processes disappear.

The system is RHEL 7.3
this is the python rpm installed
python-2.7.5-48.el7.x86_64

In OMS we have these solutions enabled
AD Assessment
AD Replication Status
Agent Health
Alert Management
Antimalware Assessment
Activity Log Analytics
Automation Hybrid Worker
Capacity and Performance (Preview)
Change Tracking
Device Health (Preview)
Network Performance Monitor
Office 365 Analytics
System Center Operations Manager Assessment (Preview)
Security and Audit
Service Map

nxScript Resource Return Values

How should values be returned to the GetScript and TestScript properties? Below is my GetScript attempt that doesn't seem to be working (I'm aware that nxFile does this already but just testing):

DSC config snippet:

$get = Get-Content "getScript.txt"

...

GetScript = "$get"

getScript.txt contents:

#!/bin/bash

[ -f /testfile.txt ] && echo "true" || echo "false"

CIM Disconnect when Using nxScript to Retrieve Data from the Internet

Noticed that CIM sessions time out with longer running nxScript operations that download data from the Internet. Below is the WinRM error I receive after 30 seconds or so:

WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible
over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer.
By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local
subnet.
    + CategoryInfo          : ConnectionError: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : HRESULT 0x80338126
    + PSComputerName        : 

I masked the PSComputerName value from the error.

Looking to create Debian armel debs

Howdy,

I see that y'all are not accepting PRs at this time so let me highlight what I plan on doing over the next few weeks (in my spare time of course ;-) ).

  • Create Debian armel debs for OMI (1.0.8-1)
  • Create Debian armel debs for DSC
  • Poke/Prod the PowerShell folks to add armel support (hoping for dotnet to have it) and to remove self hosted builds (i.e. would like to cross compile)

Given what I've laid out, can y'all comment on any items (particular the OMI and DSC ones) that I should be aware of for adding support for a new arch?

Thanks.

No arm packages

I would like to play around with utilizing DSC on the ARM-based Linux OS -- Raspbian -- on the Raspberry Pi. Is there anything on the roadmap for cross-compiling arm packages, alongside the others?

Guidance - Linux LCM - RebootRequest

With a PowerShell script resource, a reboot request can be made to the LCM with $global:DSCMachineStatus = 1

But what about when you are using an nxScript resource? I see that the OMI_BaseResource has provision for a reboot being requested by a resource within a Pull sequence but I'm having real difficulty in finding an example of how it's done for linux.

I'd really appreciate a pointer as to how this can be gracefully achieved on Linux. :)

OMSAgent installation via OMSAgent Extension removes DSC files

The following steps causes DSC to stop working on a VM

  1. Install OMI 1.0.8 (This is installed as part of SCX provider install)
  2. Install DSC V1.1.1.-70 from here https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/tag/v1.1.1-70
  3. Install OMSAgent extension for Linux – Version 1.4

The following files are removed from /opt/omi/lib
libMSFT_nxArchiveResource.so
libMSFT_nxEnvironmentResource.so
libMSFT_nxFileLineResource.so
libMSFT_nxFileResource.so
libMSFT_nxScriptResource.so
libMSFT_nxSshAuthorizedKeysResource.so

More details on microsoft/OMS-Agent-for-Linux#549

nxScript does not execute powershell scripts

nxScript nxTestScript {
    GetScript =  @"
#!/usr/bin/powershell
"Hello World"
"@

    TestScript = @"
#!/bin/bash 
exit 1
"@

    SetScript = @"
#!/usr/bin/powershell
New-Item /root/test -ItemType File
"@
        
        } #nScript

I can apply the config but nothing happens. When I'm using powershell in the TestScript returns always 0. With bash the exit code works, but the SetScript does not execute. When running ./GetDscConfiguration.py no result is displayed

        instance of MSFT_nxScriptResource
        {
            [Key] GetScript=#!/usr/bin/powershell
"Hello World"
            [Key] SetScript=#!/usr/bin/powershell
New-Item /root/test -ItemType File
            [Key] TestScript=#!/bin/bash
exit 1
            User=
            Group=
            Result=
        }

/var/opt/omi/log/dsc.log gives no additional infos
I'm running Powershell v6.0.0-alpha.14 on Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-59-generic x86_64)

Need full Installation README.md and guidance on compiling the LCM and resources on Linux.

Per the instructions on http://blogs.technet.com/b/privatecloud/archive/2014/05/19/powershell-dsc-for-linux-step-by-step.aspx when untar'ing PSDSCLinux.tar.gz this is creating a /dsc directory in the dowload directory. After the ls -l command the author runs make reg which doesn't make sense since they didn't run configure. Please escalate full detailed instructions on correctly compiling and setting this up in the README.md

Log Analytics Information from Reports Missing key components for Log Analysis

I Enrolled the Automation Account DSC to the OMS portal through Set-AzureRmDiagnosticSetting;
Added the Windows and Linux Nodes;
Looks like that the JSON payload received from the report of the Linux Machines has way less information, resulting in lack of information on the OMS portal.
JSON payload from Windows VM:

`{"JobId":"","OperationType":"Consistency","NodeName":"WSERV16DSCDEMO","IpAddress":"","LCMVersion":"2.0","ReportFormatVersion":"2.0","StartTime":"2017-05-12T19:02:24.3160000-04:00","Errors":[],"StatusData":["{"IPV4Addresses":[""],"CurrentChecksum":"ADD2C0AEA41522D2EA2FD72A260679C8A630088487CB5D443E363B7000471A78","MACAddresses":[""],"Type":"Consistency","HostName":"WSERV16DSCDEMO","Locale":"en-US","StartDate":"2017-05-12T19:02:24.3160000-04:00","JobID":"{}","LCMVersion":"2.0","IPV6Addresses":[""]}"],"AdditionalData":[{"Key":"OSVersion","Value":"{"VersionString":"Microsoft Windows NT 10.0.14393.0","ServicePack":"","Platform":"Win32NT"}"},{"Key":"PSVersion","Value":"{"CLRVersion":"4.0.30319.42000","PSVersion":"5.1.14393.953","BuildVersion":"10.0.14393.953"}"}]}

{"JobId":"","OperationType":"Consistency","RefreshMode":"Pull","Status":"Success","ReportFormatVersion":"2.0","ConfigurationVersion":"2.0.0","StartTime":"2017-05-12T19:02:24.3160000-04:00","EndTime":"2017-05-12T19:02:24.3160000-04:00","RebootRequested":"False","Errors":[],"StatusData":["{"StartDate":"2017-05-12T19:02:24.3160000-04:00","IPV6Addresses":[""],"DurationInSeconds":"0","JobID":"{}","CurrentChecksum":"ADD2C0AEA41522D2EA2FD72A260679C8A630088487CB5D443E363B7000471A78","MetaData":"Author: Administrator; Name: GMautomationPOC; Version: 2.0.0; GenerationDate: 05/11/2017 20:02:11; GenerationHost: CLIENT;","RebootRequested":"False","Status":"Success","IPV4Addresses":["IPV4 ADDRESSES"],"LCMVersion":"2.0","NumberOfResources":"1","Type":"Consistency","HostName":"WSERV16DSCDEMO","ResourcesInDesiredState":[{"SourceInfo":"::35::9::File","ModuleName":"PSDesiredStateConfiguration","DurationInSeconds":"0.016","InstanceName":"SuperTestFile","StartDate":"2017-05-12T19:02:24.6440000-04:00","ResourceName":"File","ModuleVersion":"1.1","RebootRequested":"False","ResourceId":"[File]SuperTestFile","ConfigurationName":"GMautomationPOC","InDesiredState":"True"}],"MACAddresses":[""],"MetaConfiguration":{"AgentId":"","SignatureValidations":[],"ConfigurationDownloadManagers":[{"RegistrationKey":"","ServerURL":"","ResourceId":"[ConfigurationRepositoryWeb]AzureAutomationDSC","ConfigurationNames":["GMautomationPOC.webServer"],"SourceInfo":"C:\Packages\Plugins\Microsoft.Powershell.DSC\2.19.0.0\DSCWork\RegistrationMetaConfigV2.0\RegistrationMetaConfigV2.ps1::69::9::ConfigurationRepositoryWeb"}],"ActionAfterReboot":"ContinueConfiguration","LCMCompatibleVersions":["1.0","2.0"],"LCMState":"Idle","ResourceModuleManagers":[{"RegistrationKey":"","ServerURL":"","ResourceId":"[ResourceRepositoryWeb]AzureAutomationDSC","SourceInfo":"C:\Packages\Plugins\Microsoft.Powershell.DSC\2.19.0.0\DSCWork\RegistrationMetaConfigV2.0\RegistrationMetaConfigV2.ps1::76::9::ResourceRepositoryWeb"}],"ReportManagers":[{"RegistrationKey":"","ServerURL":"","ResourceId":"[ReportServerWeb]AzureAutomationDSC","SourceInfo":"C:\Packages\Plugins\Microsoft.Powershell.DSC\2.19.0.0\DSCWork\RegistrationMetaConfigV2.0\RegistrationMetaConfigV2.ps1::82::9::ReportServerWeb"}],"StatusRetentionTimeInDays":"10","LCMVersion":"2.0","MaximumDownloadSizeMB":"500","ConfigurationMode":"ApplyAndMonitor","RefreshFrequencyMins":"30","RebootNodeIfNeeded":"False","SignatureValidationPolicy":"NONE","RefreshMode":"Pull","DebugMode":["NONE"],"CertificateID":"","AllowModuleOverwrite":"False","ConfigurationModeFrequencyMins":"15","LCMStateDetail":""},"Locale":"en-US","Mode":"Pull"}"],"AdditionalData":[{"Key":"OSVersion","Value":"{"VersionString":"Microsoft Windows NT 10.0.14393.0","ServicePack":"","Platform":"Win32NT"}"},{"Key":"PSVersion","Value":"{"CLRVersion":"4.0.30319.42000","PSVersion":"5.1.14393.953","BuildVersion":"10.0.14393.953"}"}]}`

JSON payload from Linux VM:

{"JobId":"","OperationType":"Consistency","NodeName":"tsLinuxdsc","IpAddress":"","ReportFormatVersion":"2.0","LCMVersion":"2.0","StartTime":"2017-05-30T23:00:01.303623551+00:00","Errors":[],"StatusData":["{"Locale":"en-US"}"]} {"JobId":"","ConfigurationVersion":"2.0.0","ReportFormatVersion":"2.0","LCMVersion":"2.0","EndTime":"2017-05-30T23:00:02.069403144+00:00","Errors":["{"Locale":"en-US","ErrorCode":"1","ErrorMessage":"Completed processing test operation. The operation returned False.","ResourceId":"DSCEngine","ErrorSource":"DSCEngine"}"],"StatusData":["{"Locale":"en-US","ResourcesNotInDesiredState":[{"SourceInfo":"(null)","ModuleName":"(null)","DurationInSeconds":"0","InstanceName":"[nxFile]getWildFly","StartDate":"2017-05-30T23:00:02.069403144+00:00","ResourceName":"MSFT_nxFileResource","ModuleVersion":"(null)","RebootRequested":"False","ResourceId":"[nxFile]getWildFly","ConfigurationName":"","InDesiredState":"False"}],"Error":"Completed processing test operation. The operation returned False."}"]}

The information that we get from the Linux VM is very limited, therefore there's not enough information from the Linux Based nodes to analyze from the OMS portal.
The Linux Box that I Shared the payload is a CentOS 6.9 box registered with the following script:

`dscKey=$1
dscUrl=$2
ConfigName=$3

#download packages
wget https://github.com/Microsoft/omi/releases/download/v1.2.0-35/omi-1.2.0-35.ssl_100.x64.rpm
wget https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/download/v1.1.1-294/dsc-1.1.1-294.ssl_100.x64.rpm

#install Packages
sudo rpm -Uvh omi-1.2.0-35.ssl_100.x64.rpm
sudo rpm -Uvh dsc-1.1.1-294.ssl_100.x64.rpm

#OnboardVM
cd /opt/microsoft/dsc/Scripts/
sudo ./Register.py --RegistrationKey $dscKey --ServerURL $dscUrl --ConfigurationName $ConfigName`

Suggestion : Ubuntu Repository

The deployment currently involves using a manual dpkg installation. A big improvement would be to have the packages setup as an additional repository. This way an addinistrator could add it to the repository list, and "just" do (for example) "apt-get install dsc". Afterwards (s)he can follow-up on the lifecycle in general, by doing the regular "apt-get update && apt-get upgrade".

Thanks in advance

nxScript resource may fail if script definition is starting with empty lines.

When authoring configuration items using nxScript resource in the current version you have to avoid empty lines at the beginning of Get/Test/Set. Simple change in the way resource creates scripts on remote end should prevent (e.g. removing any whitespace characters).

Problem is caused by absence of shebang and is affecting any scripting language that requires it's presence (e.g. python).

Build-Powershell-DSC-for-Linux Problem

I am working with the Build-Powershell-DSC-for-Linux repo, and am hoping someone watching these issues can help. I am trying to build on a recent CentOS 7 release, following instructions as posted, using master branch for all git modules. Everything goes well until the omicli binary is being linked, where I get some undefineds. See output below. Is there a fix or workaround for this issue? I tried adding a configure option to not build for openssl 0.9.8, but I get the same undefineds when building only for 1.0.x. Any thoughts on how to get past the errors? Thanks.

mkdir -p /home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/bin
g++ -o /home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/bin/omicli /home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/obj/home/glsutter/bld-dsc/omi/Unix/cli/cli_c.o /home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/obj/home/glsutter/bld-dsc/omi/Unix/cli/climain_c.o -L/home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/lib -L -lmi -lpal -lxmlserializer -lbase -lmicodec -lmofparser -lmi -lpal -lxmlserializer -lbase -lmicodec -lmofparser -lpthread -ldl -lpam -L/home/glsutter/bld-dsc/dsc/ext/curl/current_platform/lib -Wl,-rpath=/opt/omi/lib
/home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/obj/home/glsutter/bld-dsc/omi/Unix/cli/cli_c.o: In function ConsumeInstanceResults': cli_c.c:(.text+0x190e): undefined reference to MI_Application_InitializeV1'
cli_c.c:(.text+0x1abe): undefined reference to MI_Application_InitializeV1' /home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/obj/home/glsutter/bld-dsc/omi/Unix/cli/cli_c.o: In function climain':
cli_c.c:(.text+0x2b85): undefined reference to MI_Application_InitializeV1' /home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/lib/libmi.so: undefined reference to mi_clientFT_V1'
collect2: error: ld returned 1 exit status
make[5]: *** [/home/glsutter/bld-dsc/dsc/omi-1.0.8/output_openssl_0.9.8/bin/omicli] Error 1
make[5]: Leaving directory /home/glsutter/bld-dsc/omi/Unix/cli' make[4]: *** [all] Error 2 make[4]: Leaving directory /home/glsutter/bld-dsc/omi/Unix'
make[3]: *** [all] Error 2
make[3]: Leaving directory /home/glsutter/bld-dsc/omi/Unix' make[2]: *** [omi098] Error 2 make[2]: Leaving directory /home/glsutter/bld-dsc/dsc'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/glsutter/bld-dsc/dsc'
make: *** [all] Error 2

Guide for creating custom Dsc resources for linux

Please could we get the docs for Linux DSC updated to include a guide on making custom resources. Would be great to start using it in earnest and maybe contributing to the pool of available resources.

Can we use .net core to create custom resources? As a .net guy that would be fantastic, although I suppose I need to dip my toe in the water with python at some point anyway.

Compilation fails with inherited `-Werror`

make[3]: Entering directory `/home/andrew/src/dsc/LCM/dsc/engine/EngineHelper'
gcc -c -o /home/andrew/src/omi/Unix/output/obj/home/andrew/src/dsc/LCM/dsc/engine/EngineHelper/EngineHelper.o -g -fPIC -Werror -Wall -fvisibility=hidden -fno-strict-aliasing -D_GNU_SOURCE -D_XOPEN_SOURCE=600 -D_BSD_SOURCE  -I/home/andrew/src/omi/Unix/output/include -I../../../../omi-1.0.8 -I../../../../omi-1.0.8/common -I../../common/inc -I../../../codec/common -I../../../../omi-1.0.8/nits/base -I../../engine -DMI_CONST= -DHOOK_BUILD EngineHelper.c
EngineHelper.c: In function ‘ValidateDirectoryHasFiles’:
EngineHelper.c:978:5: error: implicit declaration of function ‘ExpandPath’ [-Werror=implicit-function-declaration]
     result = ExpandPath(directoryName, &pwConfigDir, &cimErrorDetails);
     ^
In file included from EngineHelper.h:34:0,
                 from EngineHelper.c:18:
EngineHelper.c: In function ‘StripBracesFromGuid’:
EngineHelperInternal.h:89:19: error: label ‘_eh_unwind’ defined but not used [-Werror=unused-label]
 #define EH_UNWIND _eh_unwind
                   ^
EngineHelper.c:1112:1: note: in expansion of macro ‘EH_UNWIND’
 EH_UNWIND:
 ^
EngineHelper.c: In function ‘ShouldUseV1Protocol’:
EngineHelper.c:1125:12: error: operation on ‘result’ may be undefined [-Werror=sequence-point]
     result = result = DSC_MI_Instance_GetElement((MI_Instance*)g_metaConfig, MSFT_DSCMetaConfiguration_ConfigurationID, &value, NULL, &flags, NULL);
            ^
EngineHelper.c: In function ‘GetAgentInformation’:
EngineHelper.c:1144:15: error: unused variable ‘count’ [-Werror=unused-variable]
     MI_Uint32 count = 0;
               ^
EngineHelper.c:1143:14: error: unused variable ‘ipAddress’ [-Werror=unused-variable]
     MI_Char *ipAddress = NULL;
              ^
EngineHelper.c:1142:14: error: unused variable ‘value’ [-Werror=unused-variable]
     MI_Value value;
              ^
EngineHelper.c:1139:16: error: variable ‘applicationInitialized’ set but not used [-Werror=unused-but-set-variable]
     MI_Boolean applicationInitialized = MI_FALSE;
                ^

Using gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4.

@johnkord I'm working on fixing some of these, but the DSC build fails with -Werror.

Consistency Invoker is not installed in correct path and doesn't update system state.

Applying DSC configuration to Linux node adds following line to /etc/crontab:

*/30 * * * * root /opt/omi-1.0.8/bin/ConsistencyInvoker

Actual path depends on --bindir specified when your run ./configure script.
It has some issues:

  • Compiled file is not copied to destination
  • File has different name (all lower case)
  • When run, it doesn't update state regardless of settings on LCM

The only workaround is to invoke method responsible for testing/ setting state remotely from PowerShell:

$refreshConfig = @{
    ClassName = 'MSFT_DscLocalConfigurationManager' 
    Namespace = 'root\microsoft\windows\desiredStateConfiguration' 
    MethodName = 'PerformRequiredConfigurationChecks' 
    Arguments = @{ 
        Flags = [uint32]1
    }
}

Invoke-CimMethod -CimSession $cimSession @refreshConfig

Failure happens when LCM is processing configuration

First: I have installed OMI server and PSDSC in April this year on my Raspberry Pi 2 with Raspbian (Debian Wheezy) and everything worked fine from my Win 8.1 box.

Today I have reinstalled the Raspi with Raspbian and I have downloaded and compiled the new OMI package and PSDSC:

su root
mkdir /root/downloads
cd /root/downloads
wget https://collaboration.opengroup.org/omi/documents/32721/omi-1.0.8-1.tar.gz
tar -xvf omi-1.0.8-1.tar.gz
cd omi-1.0.8/
sed -i "s/IX86/$(uname -m)/g" buildtool
sed -i "s/i686/$(uname -m)/g" buildtool
./configure && make 
./output/install
 [...]
 Successfully installed under: ///opt/omi-1.0.8

Then I installed PSDSC:

cd /root/downloads
wget https://github.com/MSFTOSSMgmt/WPSDSCLinux/releases/download/V1.0.0-320/PSDSC.tar
tar -xvf PSDSC.tar
mv ./dsc/* ./
./configure && make
make reg

I started the OMI server with:

/opt/omi-1.0.8/bin/omiserver -d

Then I tried to start my first configuration from my Win8.1 box which worked perfectly in April. Before
I have exchanged the nx Module in %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules with the new one: https://github.com/MSFTOSSMgmt/WPSDSCLinux/releases/download/V1.0.0-320/nx.zip

$username = "root"
$hostname = "10.42.0.14"
$port = 5985

$Cred = Get-Credential -UserName root -Message "Enter root password"
$CimOptions = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck 
$cimSession = New-CimSession -Credential $Cred -ComputerName $hostname -Port $port -Authentication Basic -SessionOption $CimOptions
$cimSession

Id : 1
Name : CimSession1
InstanceId : 03517cd4-5cd8-499c-9818-602b7ad34a6c
ComputerName : 10.42.0.14
Protocol : WSMAN

Configuration HalloWelt
{
param (
    [String]$ComputerName,
    [String]$Filename,
    [String]$Message
)
    Import-DscResource -ModuleName nx
    node $ComputerName
    {
    nxFile Welt
        {
            Ensure = "Present"
            Type = "File"
            DestinationPath = "/root/$Filename"
            Contents=" Welt!"
        }
    nxScript Hallo {
                TestScript = ''
                SetScript  = @'
#!/bin/bash
exit 0
'@
                GetScript  = @"
#!/bin/bash
echo $Message            
cat /root/$Filename 
rm /root/$Filename
exit 0
"@
        }
    }
}
$null = md C:\dscconfig -ErrorAction SilentlyContinue 
HalloWelt -ComputerName 10.42.0.14 -Message "Hallo" -Filename "Welt" -OutputPath:"C:\dscconfig"
Start-DscConfiguration -CimSession:$cimSession -Path:"C:\dscconfig" -Wait

Failed to apply the configuration. These resources produced errors: [nxFile]Welt, [nxScript]Hallo. Detailed error information can be found in the
log file.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : OMI:MI_Result:1
+ PSComputerName : 10.42.0.14

In dsc.log I found this:

This event indicates that failure happens when LCM is processing the configuration. ErrorId is 1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [nxFile]Welt and SourceInfo is C:\Users\christian\SkyDrive\PowerShell\DSC\HalloWelt.ps1::11::5::nxFile. ErrorMessage is A general error occurred, not covered by a more specific error code..
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Displaying messages from the engine:
WMI channel 1
ResourceID: [nxScript]Hallo
Message : [raspberrypi]: LCM: [ Start Resource ] [[nxScript]Hallo]
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Getting a registration instance for MSFT_nxScriptResource
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Moving the resource [nxScript]Hallo of class MSFT_nxScriptResource to desired state.
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Method Exec_WMIv2Provider started with parameters
Class name: MSFT_nxScriptResource
Resource ID: [nxScript]Hallo
Flags: 0
Execution Mode: 192
DSC resource Namespace: null
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Executing operations for WMIv2 DSC resource MSFT_nxScriptResource with resource name [nxScript]Hallo
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Invoking session and getting result for namespace root/Microsoft/DesiredStateConfiguration, classname MSFT_nxScriptResource for method TestTargetResource
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Displaying messages from the engine:
WMI channel 1
ResourceID: [nxScript]Hallo
Message : [raspberrypi]: LCM: [ Start Test ] [[nxScript]Hallo]
1965/07/20 06:18:49: ERROR: null(0): EventId=1 Priority=ERROR Job :
This event indicates that failure happens when LCM is processing the configuration. ErrorId is 1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [nxScript]Hallo and SourceInfo is C:\Users\christian\SkyDrive\PowerShell\DSC\HalloWelt.ps1::18::5::nxScript. ErrorMessage is A general error occurred, not covered by a more specific error code..
1965/07/20 06:18:49: ERROR: null(0): EventId=1 Priority=ERROR Job :
DSC Engine Error :
Error Message Failed to apply the configuration. These resources produced errors: [nxFile]Welt, [nxScript]Hallo. Detailed error information can be found in the log file.
Error Code : 1
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Deleting file from /opt/omi-1.0.8/etc/dsc/configuration/Pending.mof
1965/07/20 06:18:49: INFO: null(0): EventId=3 Priority=INFO Job :
Method CallSetConfiguration ended successfully

I have no idea, what went wrong.

nxService is not identifying services status if Linux is not configured for en_US locale.

nxService (init) is parsing output of 'chkconfig' and 'service' commands to test if given service is enabled/running. Unfortunately, it looks for English strings, and doesn't force environment to be en_US. As a result if environment is not en_US, test will always return false. Fixing it would require one of the two:

  • check system locale and modify tests accordingly
  • force environment to be en_US

Latter seems easier, but 'service' may ignore current locale, so it may be necessary to use /etc/init.d/ServiceName to check status instead. This behavior (ignoring changed locale) can be observed with following commands on Linux with locale other than en_US:

LANG=en_US chkconfig --list sshd

LANG=en_US service sshd status

LANG=en_US /etc/init.d/sshd status

Build DSC in developer mode fails

I follow the "Building and using DSC and OMI from source" procedure. I'm working on RHEL 6. When I run "make -j" command for DSC I receive the below errors:

gcc -c -o /root/PowerShell-DSC-for-Linux/omi-1.0.8/output/obj/root/PowerShell-DSC-for-Linux/LCM/dsc/engine/ConfigurationManager/LocalConfigManagerHelper.o -g -fPIC -Wall -fvisibility=hidden -fno-strict-aliasing -D_GNU_SOURCE -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -I/root/PowerShell-DSC-for-Linux/omi-1.0.8/output/include -I../../../../omi-1.0.8 -I../../../../omi-1.0.8/common -I../../common/inc -I../../engine/EngineHelper -I../../engine -I../../engine/ca/CAInfrastructure -I../../engine/ModuleLoader/ModuleLibrary -I../../../codec/common -I../../../../omi-1.0.8/nits/base -DMI_CONST= -DHOOK_BUILD
LocalConfigManagerHelper.c:3395: error: ‘MI_ConstStringPtr’ undeclared (first use in this function)
LocalConfigManagerHelper.c:3395: error: (Each undeclared identifier is reported only once
LocalConfigManagerHelper.c:3395: error: for each function it appears in.)
LocalConfigManagerHelper.c:3395: error: expected ‘;’ before ‘errorMessage’
LocalConfigManagerHelper.c:3396: error: expected ‘;’ before ‘messageId’
LocalConfigManagerHelper.c:3397: error: expected ‘;’ before ‘errorType’
LocalConfigManagerHelper.c:3399: warning: implicit declaration of function ‘ExtractCimErrorFields’
LocalConfigManagerHelper.c:3399: error: ‘errorMessage’ undeclared (first use in this function)
LocalConfigManagerHelper.c:3399: error: ‘messageId’ undeclared (first use in this function)
LocalConfigManagerHelper.c:3399: error: ‘errorType’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4187: error: expected declaration specifiers or ‘...’ before ‘MI_ConstStringPtr’
LocalConfigManagerHelper.c:4188: error: expected declaration specifiers or ‘...’ before ‘MI_ConstStringPtr’
LocalConfigManagerHelper.c:4189: error: expected declaration specifiers or ‘...’ before ‘MI_ConstStringPtr’
LocalConfigManagerHelper.c:4198: error: ‘MI_ConstStringPtr’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4198: error: expected ‘;’ before ‘emptyString’
LocalConfigManagerHelper.c:4202: error: ‘errorMessage’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4202: error: ‘emptyString’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4203: error: ‘messageId’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4204: error: ‘errorType’ undeclared (first use in this function)
LocalConfigManagerHelper.c: In function ‘LCM_FinishOperation’:
LocalConfigManagerHelper.c:4822: error: ‘MI_ConstStringPtr’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4822: error: expected ‘;’ before ‘errorMessage’
LocalConfigManagerHelper.c:4823: error: expected ‘;’ before ‘messageId’
LocalConfigManagerHelper.c:4824: error: expected ‘;’ before ‘errorType’
LocalConfigManagerHelper.c:4828: error: ‘errorMessage’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4828: error: ‘messageId’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4828: error: ‘errorType’ undeclared (first use in this function)
LocalConfigManagerHelper.c:4828: error: too many arguments to function ‘ExtractCimErrorFields’
make[3]: *** [/root/PowerShell-DSC-for-Linux/omi-1.0.8/output/obj/root/PowerShell-DSC-for-Linux/LCM/dsc/engine/ConfigurationManager/LocalConfigManagerHelper.o] Error 1
make[3]: Leaving directory /root/PowerShell-DSC-for-Linux/LCM/dsc/engine/ConfigurationManager' make[2]: *** [all] Error 2 make[2]: Leaving directory/root/PowerShell-DSC-for-Linux/LCM'
make[1]: *** [lcm] Error 2
make[1]: Leaving directory `/root/PowerShell-DSC-for-Linux'
make: *** [all] Error 2

Linux DSC v1 throws exceptions when MOF is in UTF8.

When configuration contains characters outside of standard character set (e.g. Polish characters) Windows will compile MOF in UCS-2 Little Endian encoding. Example configuration:

configuration BrokenFile {
    param (
        [String]$ComputerName
    )

    Import-DscResource -ModuleName nx

    node $ComputerName {

        nxFile PolishChars {
            DestinationPath = '/tmp/krzaczory.txt'
            Contents = @'
PowerShell will mess this up - Zażółć gęślą jaźń!
'@

        }
    }
}

In CTP it was enough to change encoding post-compile to UTF-8. Unfortunately, in current release configuration crashes. Python error observed when omiserver is called interactively:

socket: 5
using python version 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)]
/lib/Scripts/2.6x-2.7x

Exception: (<type 'exceptions.UnicodeEncodeError'>, UnicodeEncodeError('ascii', u'PowerShell will mess this up - Za\u017c\xf3\u0142\u0107 g\u0119\u015bl\u0105 ja\u017a\u0144!', 33, 37, 'ordinal not in range(128)'), <traceback object at 0x1452e18>)
  File "/opt/omi//lib/Scripts/client.py", line 186, in <module>
    main (sys.argv)
  File "/opt/omi//lib/Scripts/client.py", line 138, in main
    req = read_request (fd)
  File "/opt/omi//lib/Scripts/client.py", line 44, in read_request
    d = protocol.read_values (fd)
  File "../protocol.py", line 91, in read_values
    arg_val = MI_Value.read(fd)
  File "../protocol.py", line 193, in read
    val = MI_String.read(fd, type)
  File "../protocol.py", line 865, in read
    rval = MI_String(strg)
  File "../protocol.py", line 841, in __init__
    self.value = str(val)

Exiting - closing socket
error on socket: (104) "Connection reset by peer"
unable to read value

Suggestion I found online is that one should not use construct:

            if type(val) is not str:
                self.value = str(val)
            else:
                self.value = val

I tried to replace str(val) with val.encode('utf-8') as suggested on StackOverflow but it just blows up later.

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.