Coder Social home page Coder Social logo

microsoft / powershell-dsc-for-linux Goto Github PK

View Code? Open in Web Editor NEW
331.0 93.0 131.0 505.82 MB

PowerShell Desired State Configuration - for Linux

License: Other

Makefile 1.55% C 56.77% C++ 5.70% PowerShell 1.05% Python 29.60% Yacc 0.28% C# 0.68% Shell 0.42% HTML 1.28% CMake 0.11% Ruby 2.51% Pawn 0.01% PHP 0.01% BitBake 0.04%

powershell-dsc-for-linux's Introduction

PowerShell Desired State Configuration for Linux

Build Status

Copyright (c) Microsoft Corporation ver. 1.1.1

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Getting Started

Latest Release

The latest release packages for PowerShell DSC for Linux can be downloaded here: Releases

Current status and roadmap for Linux DSC

DSC has shifted to a cross-platform implementation that is developed in the PSDesiredStateConfiguration repo. Unless you have specific needs that require version 1, please navigate to the new location to view the current work on version 3.

For more information, please see the doumentation for Desired State Configuration.

This repo has been archived and will no longer accept new issues or pull requests.

Three solutions were originally released from this repo:


The codebase in this repo has been updated with fixes based on customer incidents reported for Microsoft Monitoring Agent. Therefore, the Microsoft Monitoring Agent already utilizes the latest release. Unfortunately, it has not been possible to publish new releases for either standalone installations or DSC extension. If you encounter challenges with either scenario and would like to evaluate if the latest code will resolve your issue, the best option is to download the latest release, then distribute it using custom tools (such as Azure Custom Script Extension). This is not intended to expand upon the supported OS coverage.

Please note that per the documentation for DSC Linux Extension, the extensions for DSC Linux and Monitoring cannot be used together on the same machine.

Supported Linux operating systems

The following Linux operating system versions are supported by DSC for Linux.

  • CentOS 5, 6, and 7 (x86/x64)
  • Debian GNU/Linux 6, 7 and 8 (x86/x64)
  • Oracle Linux 5, 6 and 7 (x86/x64)
  • Red Hat Enterprise Linux Server 5, 6 and 7 (x86/x64)
  • SUSE Linux Enterprise Server 10, 11 and 12 (x86/x64)
  • Ubuntu Server 12.04 LTS, 14.04 LTS, 16.04 LTS (x86/x64)

Requirements

The following table describes the required package dependencies for DSC for Linux.

Required package Description Minimum version
glibc GNU C Library 2.4 - 31.30
python Python 2.4 - 3.4
omi Open Management Infrastructure 1.0.8-4
openssl OpenSSL Libraries 0.9.8e or 1.0
python-ctypes Python CTypes library Must match Python version
libcurl cURL http client library 7.15.1

OMI Packages can be found at OMI.

Installing DSC Packages

OMI and DSC packages are available in RPM and Debian packages, for x86 and x64 architectures, and for systems with OpenSSL version 0.9.8 and version 1.0.x. To install DSC, select determine the packages that are correct for your operating system, and install them.

Examples Red Hat Enterprise Linux, CentOS, or Oracle Linux 7:

wget https://github.com/Microsoft/omi/releases/download/v1.1.0-0/omi-1.1.0.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

sudo rpm -Uvh omi-1.1.0.ssl_100.x64.rpm dsc-1.1.1-294.ssl_100.x64.rpm

Ubuntu 14.04 LTS, 16.04 LTS, or Debian GNU/Linux 8, x64:

wget https://github.com/Microsoft/omi/releases/download/v1.1.0-0/omi-1.1.0.ssl_100.x64.deb
wget https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/download/v1.1.1-294/dsc-1.1.1-294.ssl_100.x64.deb

sudo dpkg -i omi-1.1.0.ssl_100.x64.deb dsc-1.1.1-294.ssl_100.x64.deb

For more information, review the latest release notes and product documentation.

To author DSC MOF configuration for Linux on a Windows computer:


Prerequisites

  • A Windows computer with:
    • Adminstrative privileges
    • Windows PowerShell (>=4.0)

or

  • A Linux computer with:

  • Install the Linux Resource Provider MOF module:

    • The "nx" module can be installed from the PowerShell Gallery with: install-module nx
    • In order to compile a Configuration MOF that uses the DSC for Linux resources, use Import-DscResource -Module nx inside a DSC Configuration block.
  • Remotely managing a Linux system with DSC

    • You need a compiled configuration MOF to apply a new configuration to a system.
      Start-DscConfiguration -CimSession:$myCimSession -Path:"C:\path_to_compiled_mof_directory\" -Wait -Verbose
    • You can get the current configuration of the system by running: Get-DscConfiguration -CimSession:$myCimSession
    • You can test the current configuration of the system by running: Test-DscConfiguration -CimSession:$myCimSession
    • For more information on creating a CimSession for use with the -CimSession parameter, see: http://technet.microsoft.com/en-us/library/jj590760.aspx
  • Locally managing a Linux system with DSC

Building the Desired State Configuration (DSC) Local Configuration Manager and Linux Resource Providers

Prerequisites


  • At least one modern Linux system with:
    • root login capability
    • These build tools:
      • GNU Make
      • g++
      • Python version 2.5 or later, the package python-devel
    • Open Management Infrastructure (OMI) 1.0.8. http://theopengroup.org/software/omi
      • pam-devel
      • openssl-devel

Building and installing the Local Configuration Manager and Linux Resource Providers


  1. Extract PSDSC.tar into a directory that you will build it from.
  2. Download and extract OMI 1.0.8 into a directory named omi-1.0.8 in a directory parallel to the LCM and Providers directory. The directory tree should look something like:
   ./configure
   ./LCM
   ./license.txt
   ./omi-1.0.8
   ./omi-1.0.8/agent
   ./omi-1.0.8/base
   ...
  1. Building

    • Configuring OMI and building
      • Configure OMI with desired options (refer to OMI documentation for this step).
        • The default configuration installs to /opt/omi-1.0.8
        • To use the default configuration, run: cd omi-1.0.8 && ./configure
      • Run: make
    • Installing OMI:
      • Run: cd omi-1.0.8 && sudo ./output/install
    • Registering the LCM + nxProviders with OMI:
      • Run: sudo make reg
  2. Running OMI

    • On the Linux system, run omiserver with environment variable OMI_HOME set to OMI's installed directory
      • Run as root: OMI_HOME=<PATH_TO_INSTALLED_OMI_DIR> $OMI_HOME/bin/omiserver
      • The default installation for OMI 1.0.8 is /opt/omi-1.0.8. Thus, for default installations, part 4Ai above becomes: OMI_HOME=/opt/omi-1.0.8 $OMI_HOME/bin/omiserver

    Note: In order to run following reboots, it is recommended to configure OMI as a System-V, Upstart, or SystemD daemon

Building and using DSC and OMI from source

DSC and OMI can also be built together entirely from source in a self-contained directory. This is useful primarily for developers.

# Clone DSC source
git clone https://github.com/Microsoft/PowerShell-DSC-for-Linux.git
cd PowerShell-DSC-for-Linux

# Place the OMI source where DSC expects it
# Alternatively clone from Git and symlink to omi/Unix
wget https://collaboration.opengroup.org/omi/documents/33715/omi-1.0.8.tar.gz
tar xf omi-1.0.8.tar.gz

# Build OMI in developer mode
cd omi-1.0.8
./configure --dev
make -j
cd ..

# Build DSC in developer mode
./configure --no-rpm --no-dpkg --local
make -j
make reg

# Start the OMI server
./omi-1.0.8/output/bin/omiserver

Use Azure Automation as a DSC Pull Server

Note: For more information on Azure Automation’s DSC features, reference the documentation.
Linux computers can be onboarded to Azure Automation DSC, as long as they have outbound access to the internet, via a few simple steps:

Make sure version 1.1 or later of the DSC Linux agent is installed on the machines you want to onboard to Azure Automation DSC.

To configure Azure Automation as a DSC Pull Server from the Linux computer:

  • On each Linux machine to onboard to Azure Automation DSC, use Register.py to onboard using the PowerShell DSC Local Configuration Manager defaults:

For python2

sudo /opt/microsoft/dsc/Scripts/Register.py <Automation account registration key> <Automation account registration URL>

For python3

sudo /opt/microsoft/dsc/Scripts/python3/Register.py <Automation account registration key> <Automation account registration URL>

  • To find the registration key and registration URL for your Automation account, see the Secure Registration section below.
  • Using the Azure portal or cmdlets, check that the machines to onboard now show up as DSC nodes registered in your Azure Automation account.

Additional configuration options:

  • --ConfigurationName: the name of the configuration to apply
  • --RefreshFrequencyMins: Specifies how often (in minutes) LCM attempts to obtain the configuration from the pull server. If configuration on the pull server differs from the current one on the target node, it is copied to the pending store and applied.
  • --ConfigurationModeFrequencyMins: Specifies how often (in minutes) LCM ensures that the configuration is in the desired state.
  • --ConfigurationMode: Specifies how LCM should apply the configuration. Valid values are: ApplyOnly, ApplyAndMonitor, ApplyAndAutoCorrect, MonitorOnly

To configure Azure Automation as a DSC Pull Server with a metaconfiguration MOF:

  • Open the PowerShell console or PowerShell ISE as an administrator on a Windows machine in your local environment. This machine must have the latest version of WMF 5 installed
  • Connect to Azure Resource Manager using the Azure PowerShell module:
Add-AzureAccount 
Switch-AzureMode AzureResourceManager
  • Download, from the Automation account you want to onboard nodes to, the PowerShell DSC metaconfigurations for the machines you want to onboard: Get-AzureAutomationDscOnboardingMetaconfig -ResourceGroupName MyResourceGroup AutomationAccountName MyAutomationAccount -ComputerName MyServer1, MyServer2 OutputFolder C:\Users\joe\Desktop

  • Optionally, view and update the metaconfigurations in the output folder as needed to match the PowerShell DSC Local Configuration Manager fields and values you want, if the defaults do not match your use case.

  • Remotely apply the PowerShell DSC metaconfiguration to the machines you want to onboard:

$SecurePass = ConvertTo -SecureString -string "<root password>" -AsPlainText Force 
$Cred = New-Object System.Management.Automation.PSCredential "root" , $SecurePass 
$Opt = New-CimSessionOption -UseSsl: $true -SkipCACheck: $true -SkipCNCheck: $true -SkipRevocationCheck: $true 
 
$Session = New-CimSession -Credential: $Cred -ComputerName: <your Linux machine > -Port: 5986 -Authentication: basic -SessionOption: $Opt 
Set-DscLocalConfigurationManager -CimSession $Session –Path C:\Users\joe\Desktop\DscMetaConfigs
  • If you cannot apply the PowerShell DSC metaconfigurations remotely, for each Linux machine to onboard, copy the metaconfiguration corresponding to that machine from the folder in step 5 onto the Linux machine. Then call SetDscLocalConfigurationManager.py locally on each Linux machine to onboard to Azure Automation DSC:

For python2

/opt/microsoft/dsc/Scripts/SetDscLocalConfigurationManager.py –configurationmof <path to metaconfiguration file> 

For python3

/opt/microsoft/dsc/Scripts/python3/SetDscLocalConfigurationManager.py –configurationmof <path to metaconfiguration file> 
  • Using the Azure portal or cmdlets, check that the machines to onboard now show up as DSC nodes registered in your Azure Automation account.

Importing resource modules to Azure Automation

The supplied resource modules with this release (nxNetworking, nxComputerManagement) can be imported to Azure Automation for distribution with DSC configurations. To import to Azure Automation, rename the .zip files to remove the _X.Y version string from the file name. Such as: nxNetworking.zip and nxComputerManagement.zip.

Performing DSC Operations from the Linux Computer

DSC for Linux includes scripts to work with configuration from the local Linux computer. These scripts are located in /opt/microsoft/dsc/Scripts for python2 and /opt/microsoft/dsc/Scripts/python3 for python3 and include the following:

GetDscConfiguration.py Returns the current configuration applied to the computer. Similar to the Windows PowerShell cmdlet Get-DscConfiguration cmdlet. sudo ./GetDscConfiguration.py

GetDscLocalConfigurationManager.py Returns the current meta-configuration applied to the computer. Similar to the Windows PowerShell cmdlet Get-DSCLocalConfigurationManager sudo ./GetDscLocalConfigurationManager.py

PerformRequiredConfigurationChecks.py Immediately checks the configuration in accordance with the MetaConfiguration settings and applies the configuration if an update is available. Useful for immediately applying configuration changes on the pull server. sudo ./PerformRequiredConfigurationChecks.py

RestoreConfiguration.py Applies the previous configuration known to DSC, a rollback.
sudo ./RestoreConfiguration.py

SetDscLocalConfigurationManager.py Applies a Meta Configuration MOF file to the computer. Similar to the Windows PowerShell cmdlet: Set-DSCLocalConfigurationManager. Requires the path to the Meta Configuration MOF to apply. sudo ./SetDscLocalConfigurationManager.py –configurationmof /tmp/localhost.meta.mof

StartDscConfiguration.py Applies a configuration MOF file to the computer. Similar to the Windows PowerShell cmdlet: StartDscConfiguration. Requires the path to the configuration MOF to apply. sudo ./StartDscConfiguration.py –-configurationmof /tmp/localhost.mof

You can also supply the force parameter to forcibly remove any current pending configuration before applying the new configuration. sudo ./StartDscConfiguration.py –-configurationmof /tmp/localhost.mof --force

TestDscConfiguration.py Tests the current system configuration for compliance desired state. Similar to the Windows PowerShell cmdlet: Test-DscConfiguration.
sudo ./TestDscConfiguration.py

InstallModule.py Installs a custom DSC resource module. Requires the path to a .zip file containing the module shared object library and schema MOF files. sudo ./InstallModule.py /tmp/cnx_Resource.zip

RemoveModule.py Removes a custom DSC resource module. Requires the name of the module to remove. sudo ./RemoveModule.py cnx_Resource

Using PowerShell Desired State Configuration for Linux with a Pull Server

Using HTTPS with the Pull Server

Though unencrypted HTTP is supported for communication with the Pull server, HTTPS (SSL/TLS) is recommended. When using HTTPS, the DSC Local Configuration Manager requires that the SSL certificate of the Pull server is verifiable (signed by a trusted authority, has a common name that matches the URL, etc.).

You can modify these HTTPS requirements as needed, by modifying the file /etc/opt/omi/dsc/dsc.conf. The supported properties defined in this file are:

  • NoSSLv3 set this to true to require the TLS protocol and set this to false to support SSLv3 or TLS. The default is false.
  • DoNotCheckCertificate set this to true to ignore SSL certificate verification. The default is false.
  • CURL_CA_BUNDLE an optional path to a curl-ca-bundle.crt file containing the CA certificates to trust for SSL/TLS. For more information, see: http://curl.haxx.se/docs/sslcerts.html
  • sslCipherSuite Optionally set your preferred SSL cipher suite list. Only ciphers matching the rules defined by this list will be supported for HTTPS negotiation. The syntax and available ciphers on your computer depend on whether the cURL package is configured to use OpenSSL or NSS as its SSL library. To determine which SSL library cURL is using, run the following command and look for OpenSSL or NSS in the list of linked libraries:
curl --version |head -n 1 curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.15.4 zlib/1.2.7 libidn/1.28 libssh2/1.4.3

For more information on configuring cipher support, see: http://curl.haxx.se/libcurl/c/CURLOPT_SSL_CIPHER_LIST.html

Using an HTTP(s) Proxy Server with DSC

DSC for Linux supports the use of an HTTP or HTTPS proxy server when communicating with a Pull Server. To configure a proxy server, edit the file /etc/opt/omi/conf/dsc/dsc.conf and add a line starting with PROXY=. The proxy server specification takes the format: The proxy configuration value has the following syntax: [protocol://][user:password@]proxyhost[:port]

Property Description
Protocol http or https
user Optional username for proxy authentication
password Optional password for proxy authentication
proxyhost Address or FQDN of the proxy server
port Optional port number for the proxy server

Example PROXY=https://proxyuser:proxypassword@proxyserver01:8080

PowerShell Desired State Configuration for Linux Log Files

The following log files are generated for DSC for Linux messages.

Log File Directory Description
omiserver.log /var/opt/omi/log Messages relating to the operation of the OMI CIM server.
dsc.log /var/opt/omi/log Messages relating to the operation of the Local Configuration Manager and DSC resource operations.

Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct] (https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ] (https://opensource.microsoft.com/codeofconduct/faq/) or contact [email protected] with any additional questions or comments.

powershell-dsc-for-linux's People

Contributors

abenbachir avatar amitsara avatar chparimi avatar d1v38om83r avatar dantramsft avatar diastro avatar dineshinavolu-ms avatar ericgable avatar fayzasultan avatar gauravga avatar hestolz avatar jeffaco avatar kkarmakarms avatar krisbash avatar krmanupa avatar kwirkykat avatar lagalbra avatar narinem avatar nidhanda avatar nikhim-um avatar robbiezhang avatar shkhisti avatar sugr4 avatar taglines avatar timorenz-msft avatar v-anishrao avatar vakaranamsft avatar varastog avatar vrdmr avatar zjalali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powershell-dsc-for-linux's Issues

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

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?

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.

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.

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

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?

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)

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.

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"

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'

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

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)

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

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.

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

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";


                    };

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

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.

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.

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. :)

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

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.

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.

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`

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

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.

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

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

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.

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.

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.

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

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).

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

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.