microsoft / PowerShell-DSC-for-Linux

PowerShell Desired State Configuration - for Linux
Other
338 stars 131 forks source link

Unable to invoke DSC resources #24

Closed vinithmenon28 closed 8 years ago

vinithmenon28 commented 8 years ago

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

KrisBash commented 8 years ago

Did you install the networking/computer management modules on the Linux computer?

vinithmenon28 commented 8 years ago

no I did not , can you guide me how to do that. I did not find any step by step guide for v1.1

KrisBash commented 8 years ago

Documentation is here: https://msdn.microsoft.com/en-us/powershell/dsc/lnxgettingstarted and in the release notes .pdf. I'm planning to get docs up to date on GitHub though.

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

The path is /opt/microsoft/dsc/Scripts

vinithmenon28 commented 8 years ago

I installed the rpm package for DSC and also the latest OMI package but still i get this error

below are the snippets of the commands i ran, i have not posted all the commands but the imp ones.

image

[root@CENTOSTESTDSC1 Scripts]# wget https://github.com/Microsoft/PowerShell-DSC-for-Linux/releases/download/v1.0.0-466/PSDSC.tar.gz [root@CENTOSTESTDSC1 Scripts]# wget https://collaboration.opengroup.org/omi/documents/33715/omi-1.0.8.tar.gz

[root@CENTOSTESTDSC1 Scripts]# sudo rpm -Uvh omi-1.0.8.ssl_100.x64.rpm

[root@CENTOSTESTDSC1 Scripts]# sudo rpm -Uvh dsc-1.1.0-466.ssl_098.x64.rpm

When i tried to install the modules i got the below error

image

Below are the set of commands i punched in at the Linux console ( cent OS) to configure DSC

image

It would be great if you can publish a step byb step document with screen captures on how to configure DSC v1.1 for linux for people who come from non-linux backgrounds.

JumpingYang001 commented 8 years ago

You can try "yum install unzip", I guess you didn't install unzip to extract the zip file.

vinithmenon28 commented 8 years ago

its already installed

[root@CENTOSTESTDSC1 Scripts]# yum install unzip Loaded plugins: fastestmirror Setting up Install Process Loading mirror speeds from cached hostfile Package unzip-6.0-2.el6_6.x86_64 already installed and latest version Nothing to do [root@CENTOSTESTDSC1 Scripts]#

vinithmenon28 commented 8 years ago

also note i installed the below rpm packages

[root@CENTOSTESTDSC1 Scripts]# sudo rpm -Uvh omi-1.0.8.ssl_100.x64.rpm [root@CENTOSTESTDSC1 Scripts]# sudo rpm -Uvh dsc-1.1.0-466.ssl_100.x64.rpm

versions of centos as below

InstanceID : 2FDB5542-5896-45D5-9BE9-DC04430AAABE SystemName : CENTOSTESTDSC1 ProductName : OMI ProductVendor : Microsoft ProductVersionMajor : 1 ProductVersionMinor : 0 ProductVersionRevision : 8 ProductVersionString : 1.0.8-2 Platform : LINUX_X86_64_GNU OperatingSystem : LINUX Architecture : X86_64 Compiler : GNU ConfigPrefix : GNU ConfigLibDir : /opt/omi-1.0.8/lib ConfigBinDir : /opt/omi-1.0.8/bin ConfigIncludeDir : /opt/omi-1.0.8/include ConfigDataDir : /opt/omi-1.0.8/share ConfigLocalStateDir : /opt/omi-1.0.8/var ConfigSysConfDir : /opt/omi-1.0.8/etc ConfigProviderDir : /opt/omi-1.0.8/etc ConfigLogFile : /opt/omi-1.0.8/var/log/omiserver.log ConfigPIDFile : /opt/omi-1.0.8/var/run/omiserver.pid ConfigRegisterDir : /opt/omi-1.0.8/etc/omiregister ConfigSchemaDir : /opt/omi-1.0.8/share/omischema ConfigNameSpaces : {root-check, interop, root-Microsoft-Windows-DesiredStateConfiguration, root-Microsoft-DesiredStateConfiguration...}

TingLiu6 commented 8 years ago

Why did you do the steps below: dsc After installing omi and dsc packages, you can install the module directly if unzip were already installed on your machine: /opt/microsoft/dsc/Scripts/InstallModule.py nxComputerManagement_1.0.zip

vinithmenon28 commented 8 years ago

Hi Ting Liu, i revered back to my snaphot and ran the below steps, i configured omi, copied over all the packagaes and modules using winscp.

957 2016-01-13 03:19:45 sudo rpm -Uvh omi-1.0.8.ssl_100.x64.rpm 958 2016-01-13 03:20:06 sudo rpm -Uvh dsc-1.1.0-466.ssl_100.x64.rpm 959 2016-01-13 03:20:37 sudo ./InstallModule.py /test/nxComputerManagement_1.0.zip 960 2016-01-13 03:20:45 sudo ./InstallModule.py /root/test/nxComputerManagement_1.0.zip 961 2016-01-13 03:21:12 cd .. 962 2016-01-13 03:21:13 ls 963 2016-01-13 03:21:30 cd /opt/ 964 2016-01-13 03:21:31 ls 965 2016-01-13 03:21:36 cd microsoft/ 966 2016-01-13 03:21:37 ls 967 2016-01-13 03:21:39 cd dsc 968 2016-01-13 03:21:40 ls 969 2016-01-13 03:21:45 cd Scripts/ 970 2016-01-13 03:21:47 ls 971 2016-01-13 03:21:54 sudo ./InstallModule.py /root/test/nxComputerManagement_1.0.zip 972 2016-01-13 03:22:22 sudo ./InstallModule.py /root/test/nxNetworking_1.0.zip 973 2016-01-13 03:22:44 OMI_HOME=/opt/omi-1.0.8 974 2016-01-13 03:22:45 /opt/omi-1.0.8/bin/omiserver -d 975 2016-01-13 03:23:49 yum -y groupinstall 'Development Tools' 976 2016-01-13 03:23:51 yum -y install pam-devel 977 2016-01-13 03:24:01 yum -y install openssl-devel 978 2016-01-13 03:24:03 yum -y install python 979 2016-01-13 03:24:04 yum -y install python-devel 980 2016-01-13 03:24:05 mkdir /root/downloads 981 2016-01-13 03:24:05 cd /root/downloads 982 2016-01-13 03:24:05 wget https://collaboration.opengroup.org/omi/documents/33715/omi-1.0.8.tar.gz 983 2016-01-13 03:24:21 tar -xvf omi-1.0.8.tar.gz 984 2016-01-13 03:24:22 cd omi-1.0.8 985 2016-01-13 03:24:22 ./configure | tee /tmp/omi-configure.txt 986 2016-01-13 03:24:24 make | tee /tmp/omi-make.txt 987 2016-01-13 03:26:09 make install | tee /tmp/omi-make-install.txt 988 2016-01-13 03:26:20 OMI_HOME=/opt/omi-1.0.8 989 2016-01-13 03:26:21 /opt/omi-1.0.8/bin/omiserver -d 990 2016-01-13 03:27:32 /opt/microsoft/dsc/Scripts/InstallModule.py /root/test/nxComputerManagement_1.0.zip 991 2016-01-13 03:28:12 /opt/microsoft/dsc/Scripts/InstallModule.py /root/test/nxNetworking_1.0.zip 992 2016-01-13 03:28:20 cd /opt/microsoft/dsc/modules

i did not do the wget for PSDSC.tar.gz as you suggested, but after this when i run the DSC configuration i get the below error.

image

Also i did not see the DSC folder here after only installing the rpm package

image

vinithmenon28 commented 8 years ago

the resources i downloaded from https://www.microsoft.com/en-us/download/details.aspx?id=49150

here's the screenshot when i run DSC config when i installed the modules from above location

image

vinithmenon28 commented 8 years ago

also i cant find anything related to error from

[root@CENTOSTESTDSC1 log]# cat omiserver.log [root@CENTOSTESTDSC1 log]# cat dsc.log

KrisBash commented 8 years ago

There are multiple issues going on here, let's try to address them one by one. 1) Firstly, it appears that you installed the packages (omi and dsc rpms), and then built OMI from source. This is redundant and results in two instances of OMI, one at /opt/omi and one at /opt/omi-1.0.8. The installation of DSC from rpm will use the /opt/omi/ directory. So for logs, you should look at /var/opt/omi/log for dsc.log and omiserver.log 2) You are getting errors in the nxService resource, which is a built-in resource. This implies something wrong with the configuration. Can you provide the configuration (.ps1 or .mof) for this instance? 3) The module issue looks like a bug in the packaging of the .zip. My sincere apologies for that. Here's a workaround until we post the fix.

unzip nxComputerManagement_1.0.zip
cd nxComputerManagement_1.0
zip -r nxComputerManagement_1.0.zip nxComputerManagement/*
cp nxComputerManagement_1.0.zip /tmp/
sudo /opt/microsoft/dsc/Scripts/installModule.py /tmp/nxComputerManagement_1.0.zip 

unzip nxNetworking_1.0.zip
cd nxNetworking_1.0
zip -r nxNetworking_1.0.zip nxNetworking/*
cp nxNetworking_1.0.zip /tmp/
sudo /opt/microsoft/dsc/Scripts/installModule.py /tmp/nxNetworking_1.0.zip

We'll get the fixed module uploaded to the PS Gallery asap. We're working on an updated release of the DSC package that will also include the module pacakging fix.

vinithmenon28 commented 8 years ago

Thanks for the help Kris, yes i was able to install the nxNetworking module using the steps you gave above but for nxComputerManagement it failed.

I got the module zip files from https://www.microsoft.com/en-us/download/details.aspx?id=49150, after i installed the msi package i was able to see the modules here and i copied them over to the cenntos vm using winscp

image

Also i saw a number of versions of RPM packages when i installed the above msi package. i saw a 098 an 100 version. how can we identify which we need to install?

image

Here are the screencaptures for the module installation.

image

As you can see above when i try to install nxComputerManagement via Install.py it results in an error, module files not found but for nxNetworking it worked.

Also here's my mof file.

/ @TargetNode='11.128.171.21' @GeneratedBy=vinithm @GenerationDate=01/14/2016 08:19:23 @GenerationHost=VINITHM-BLR /

instance of MSFT_nxFileResource as $MSFT_nxFileResource1ref { ResourceID = "[nxFile]myTestFile"; Type = "File"; Ensure = "Present"; Contents = "This is my DSC Test!"; DestinationPath = "/tmp/dsctest"; ModuleName = "nx"; SourceInfo = "C:\psscripts\dsc\linux_final.ps1::11::9::nxFile"; ModuleVersion = "1.0";

}; instance of MSFT_nxUserResource as $MSFT_nxUserResource1ref { ResourceID = "[nxUser]WebAdmin"; FullName = "Web Admin"; UserName = "webadmin"; Ensure = "Present"; Password = "test"; SourceInfo = "C:\psscripts\dsc\linux_final.ps1::20::9::nxUser"; ModuleName = "nx"; ModuleVersion = "1.0";

}; instance of MSFT_nxUserResource as $MSFT_nxUserResource2ref { ResourceID = "[nxUser]WebAdmin1"; FullName = "Web Admin1"; UserName = "webadmin1"; Ensure = "Present"; Password = "test"; SourceInfo = "C:\psscripts\dsc\linux_final.ps1::27::9::nxUser"; ModuleName = "nx"; ModuleVersion = "1.0";

}; instance of MSFT_nxComputerResource as $MSFT_nxComputerResource1ref { ResourceID = "[nxComputer]ComputerSettings"; TimeZoneName = "Asia/Calcutta"; SourceInfo = "C:\psscripts\dsc\linux_final.ps1::34::8::nxComputer"; Name = "CENTOST"; ModuleName = "nxComputerManagement"; ModuleVersion = "1.1";

}; instance of MSFT_nxServiceResource as $MSFT_nxServiceResource1ref { ResourceID = "[nxService]FWD"; Controller = "init"; State = "Running"; Enabled = True; SourceInfo = "C:\psscripts\dsc\linux_final.ps1::39::9::nxService"; Name = "httpd"; ModuleName = "nx"; ModuleVersion = "1.0";

}; instance of OMI_ConfigurationDocument

                {

Version="2.0.0";

                    MinimumCompatibleVersion = "1.0.0";

                    CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};

                    Author="vinithm";

                    GenerationDate="01/14/2016 08:19:23";

                    GenerationHost="VINITHM-BLR";

                };
vinithmenon28 commented 8 years ago

Also Kris, it would be great if you could update / publish a new blog on a step by step series for PSDSCLinux v 1.1, just like what you had done for v 1.0 http://blogs.technet.com/b/privatecloud/archive/2014/05/19/powershell-dsc-for-linux-step-by-step.aspx

It would be helpful for non-linux guys to easily follow your guide

vinithmenon28 commented 8 years ago

Hey Kris, just an update, finally it got fixed, i did a rm-rf of the nxComputerManagement module and it deleted all the files, then i again did a re-copy using winscp and voila!! it finally worked.

Thanks a lot guys for your excellent support :), lets roll out DSC Linux in production :+1:

image