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

I can't generate a .mof file with DSC using Rocky8.4 #814

Open
joelhacker opened this issue Sep 23, 2021 · 1 comment
Open

I can't generate a .mof file with DSC using Rocky8.4 #814

joelhacker opened this issue Sep 23, 2021 · 1 comment

Comments

@joelhacker
Copy link

I am using Rocky 8 under WSL 2.0, and have I have installed the following Centos RPM's for OMI, Powershell & DSC:

https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-1.centos.8.x86_64.rpm
https://github.com/microsoft/omi/releases/download/v1.6.8-1/omi-1.6.8-1.ssl_110.ulinux.x64.rpm
https://github.com/microsoft/PowerShell-DSC-for-Linux/releases/download/v1.2.1-0/dsc-1.2.1-0.ssl_110.x64.rpm

I have the following: LD_LIBRARY_PATH=/opt/omi/lib/:/opt/microsoft/dsc/lib

I have the following PATH=/opt/microsoft/dsc/Scripts/3.x/Scripts/:/opt/omi/Scripts/3.x/Scripts/:/opt/microsoft/powershell/7/Modules/:/opt/omi/lib/Scripts/python3/:/opt/omi/lib/Scripts/:/opt/microsoft/dsc/Scripts/python3/:/opt/omi/bin:/opt/microsoft/dsc/bin:/opt/microsoft/dsc/Scripts/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:

When I try to create a DSC configuration within powershell, I run the following pwsh script:


#!/usr/bin/pwsh

Configuration Dsctestlinux
{
Import-DscResource -Module PSDesiredStateConfiguration,nx
Node "localhost"
{
nxFile ExampleFile
{
DestinationPath = "/tmp/example"
Contents = "hello world `n"
Ensure = "Present"
Type = "File"
}
}
}

Dsctestlinux


When I run this as the root user within a bash shell, I get the following output:

PSDesiredStateConfiguration\node: /root/Test_Dsc_Config.ps1:17
Line |
17 | Node "localhost"
| ~~~~
| The term 'PSDesiredStateConfiguration\nxFile' is not recognized as a name of a cmdlet, function,
| script file, or executable program. Check the spelling of the name, or if a path was included,
| verify that the path is correct and try again.

InvalidOperation: /opt/microsoft/powershell/7/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.psm1:3745
Line |
3745 | throw $ErrorRecord
| ~~~~~~~~~~~~~~~~~~
| Errors occurred while processing configuration 'Dsctestlinux'.


In my bash install script, I am also installing the nx module via:
$(echo A | pwsh -c "Install-Module -Name nx -SkipPublisherCheck") > /dev/null

I am wanting to run DSC in a push configuration from one Rocky 8 Linux machine to a second Rocky 8 machine.

Please advise what other information you need to help resolve this issue.

Thanks!

@joelhacker joelhacker changed the title can't generate mof file I can't generate a .mof file with DSC using Rocky8.4 Sep 27, 2021
@joelhacker
Copy link
Author

joelhacker commented Sep 27, 2021

Given that we were trying to build DSC on a newer platform (rocky8), we decided to try to build DSC from source.

We followed the following guide,

https://github.com/microsoft/PowerShell-DSC-for-Linux

and performed the following steps:

  1. Install the RPM repos that are used for the installation

    a. We Install the dnf-plugins support and enable the EPEL repo.
    (Which is the fedora build of Extra Packages for Enterprise Linux)
    NOTE: wget and tar are included to support Visual Studio code
    /usr/bin/dnf -y install dnf-plugins-core epel-release wget tar

  2. Enable the Powertools and Development Tools and install the pre-requisite rpms.

/usr/bin/dnf config-manager --set-enabled powertools
/usr/bin/dnf -y groupinstall 'Development Tools'
/usr/bin/dnf -y install pam-devel openssl-devel python39 python39-devel libicu gssntlmssp unzip mlocate gcc-c++ make redhat-lsb-core
ln -s /usr/bin/python3 /usr/bin/python

  1. Disable selinux

sed -i s/SELINUX=enforcing/SELINUX=permissive/ /etc/sysconfig/selinux
setenforce permissive

  1. Install the powershell.

wget https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-1.centos.8.x86_64.rpm
rpm -Uvh *.rpm && rm *.rpm

We then performed the following steps from the following online build steps:

(https://github.com/microsoft/PowerShell-DSC-for-Linux#building-and-using-dsc-and-omi-from-source)
Starting at building and using dsc and omi from source (see link above), we ran the following steps

  1. git clone the DSC source

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

  1. Place the OMI source where DSC expects it alternatively clone from Git and symlink to omi/Unix
    wget https://github.com/microsoft/omi/archive/refs/tags/v1.6.8-1.tar.gz
    tar xzf v1.6.8-1.tar.gz

  2. Build OMI in developer mode
    cd omi-1.6.8-1/Unix/
    ./configure --dev
    make -j

After running the make, we get the following errors in our build:


injector.cpp: In function ‘long unsigned int InjectorSetup()’:
injector.cpp:468:70: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class TestSystem::Globals’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
memcpy(g_globals, &g_tempGlobals, sizeof(TestSystem::Globals));
^
In file included from injector.cpp:10:
../../nits/base/Globals.h:230:7: note: ‘class TestSystem::Globals’ declared here
class Globals
^~~~~~~
cc1plus: all warnings being treated as errors
make[3]: *** [../../mak/rules.mak:486: /root/dsc_source/PowerShell-DSC-for-Linux/omi-1.6.8-1/Unix/output/obj/nits/injector/injector.o] Error 1
make[3]: Leaving directory '/root/dsc_source/PowerShell-DSC-for-Linux/omi-1.6.8-1/Unix/nits/injector'
make[2]: *** [../mak/rules.mak:421: all] Error 2
make[2]: Leaving directory '/root/dsc_source/PowerShell-DSC-for-Linux/omi-1.6.8-1/Unix/nits'
make[1]: *** [/root/dsc_source/PowerShell-DSC-for-Linux/omi-1.6.8-1/Unix/mak/rules.mak:421: all] Error 2
make[1]: Leaving directory '/root/dsc_source/PowerShell-DSC-for-Linux/omi-1.6.8-1/Unix'
make: *** [GNUmakefile:38: all] Error 2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant