Goal: Apply DSC configuration
Problem/scenario: When you run the "start-dscconfiguration NameOfConfig -wait -verbose" (where NameOfConfig is the name of the configuration) from the folder that houses the subfolder with NameOfConfig, you get an error like this: "Get-targetresource PS module does not implement the key property solution"
Solution: Stop a specific process by running this command.
gps wmi* |? {$_.Modules.ModuleName -like '*DSC*'} | Stop-Process -Force
Re-run the "start-dscconfiguration NameOfConfig -wait -verbose" command.
Problem and Solution: “New Simple Volume” is Greyed Out After Disk Was Added To Windows Server
Goal: You want to create a new Disk Partition on Windows Server.
Problem: You go to Server Manager -> Computer Management -> Storage -> Disk Management. You right click a newly-added partition (in the graphical bar section that says "Unallocated"). "New Simple Volume," "New Spanned Volume," and "New Striped Volume" are all grayed out.
Solution: Right click the "Disk X" (where X is the integer associated with the newly-added disk). Choose "Online." Right click the "Disk X" again. Choose "Initialize Disk." Now "New Simple Volume" should not be grayed out.
DSC Problem and Solution: One Way To Possibly Solve a “Cannot invoke the SendConfigurationApply” Problem
Goal: You want to use DSC to apply a configuration.
Problem scenario: When you run the "start-dscconfiguration NameOfConfig -wait -verbose" (where NameOfConfig is the name of the configuration) from the folder that houses the subfolder with NameOfConfig, you get an error like this: "DSC error: Cannot invoke the SendConfigurationApply method. The sendConfigurationApply method is in progress..."
Solution: Back up and delete the subfolder named NameOfConfig. You want to delete the .mof files. You'll need to recompile the configurations that are deleted.
How Do You List Directories Traits without Traversing into Their Contents?
Problem Scenario
You want to find out the permissions, ownership and groups associated with various subdirectories in Linux. You do not want to display the lengthy contents of these directories. How do you use the ls command to show the attributes of the directories themselves and not the contents of the directories?
Solution
From a Linux command prompt, run this command: ls -ld /parentdirectory/
For PowerShell to list files without traversing into their contents use either of these two commands:dir
ls
How Do You Create a New User with DSC?
Problem scenario
You are using Windows Server 2019. You want to create a new local user. You don't want the user to be a member of the local Administrators group (which allows remote logins). What do you do?
Solution
Prerequisites
i. Install DSC. If you need assistance, see this posting.
ii.a. Make sure the server has been added to its own TrustedHosts configuration settings. To do this, open PowerShell and run this:
Set-Item wsman:localhost\client\trustedhosts -Value $env:COMPUTERNAME
ii.b. Answer "Yes" to the pop up window.
Procedures
- Create a .ps1 file with the following content (but replace "foobar" with your desired password and replace "cooluser" with your desired password):
$ConfigData = @{
AllNodes = @(
@{
NodeName=$env:COMPUTERNAME;
PSDscAllowPlainTextPassword = $true
}
)}
Configuration newLocalAdmin
{
$secpasswd = ConvertTo-SecureString "foobar" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("cooluser", $secpasswd)
Node $env:COMPUTERNAME
{
User adminUser
{
UserName = "Steve.J"
Description = "This account is created using DSC"
Password = $mycreds
FullName = "Steve Jobs"
PasswordNeverExpires = $true
Ensure = 'Present'
}
}
}
# Run the Configuration with the -ConfigurationData parameter and use our configData as argument
newLocalAdmin -ConfigurationData $ConfigData
- Run the script above.
- Run this command (from the directory where you ran the above command as it would have created a new directory):
Start-DscConfiguration -Path .\newLocalAdmin -Wait -Verbose - You are done. This method was adapted from this posting.
We think the directions above would work on most versions of Windows.
How Do You Troubleshoot Desired State Configuration Problems where Actions Are Not Working or Software Is Not Installing?
Problem scenario
You run a Start-DscConfiguration command in PowerShell like this:
Start-DscConfiguration -Path . -Wait -Verbose
You get an error message that the installation failed. The message may say something like this:
Start-DscConfiguration : The computer name was not specified and the configuration directory does not have any configuration files.
CategoryInfo : NotSpecified … ArgumentException
FullyQualifiedErrorId : System.ArgumentException, Microsoft.PowerShell.DesiredStateConfiguration.Commands.StartDscConfigurationCommand
What should you do?
Solution
Is the .mof file in the directory where you ran the above command? You could run "dir" to see if it is there. You could re-run the command to replace the "." with the directory path where the .mof file is.
How Do You Create Docker Containers To Have Unique IP Addresses?
Problem scenario
How do you create Docker containers to have unique IP Addresses (but not the default 172.x.x.x type)?
Solution
(If you need help installing Docker, see this posting.)
Create new IP addresses with these commands (with sudo in front of them, preferably, or less preferably as the root user):
ip addr add 33.33.33.38/28 brd + dev eth0
ip addr add 33.33.33.39/28 brd + dev eth0
ip addr add 33.33.33.40/28 brd + dev eth0
# Replace the IP addresses and subnet masks as you desire
Then use a modified version of this command:docker run -p 33.33.33.38:80:80 repositoryName:versionDesignation /bin/bash
# You can use the "docker images" command to find the "repositoryName" and "versionDesignation"
# The IP address and port mapping (from Linux server to Docker container) can be substituted as needed
Two or more containers on the same Docker host can use port 80 using this method. To have the IP addresses available upon every log in, you can create a /etc/profile.d/custom.sh file. This will give you the IP addresses on the Docker server upon logging in each time. The custom.sh file should have the lines you entered above after a "#!/bin/bash" header. Here is an example:
#!/bin/bash
ip addr add 33.33.33.38/28 brd + dev eth0
ip addr add 33.33.33.39/28 brd + dev eth0
ip addr add 33.33.33.40/28 brd + dev eth0
How To Create IP Addresses On a Linux Server without Corresponding NICs
If you do not want to create new interfaces, just new IP addresses, use these commands:
ip addr add 33.33.33.38/28 brd + dev eth0
ip addr add 33.33.33.39/28 brd + dev eth0
ip addr add 33.33.33.40/28 brd + dev eth0
# Replace the IP addresses and subnet masks as you desire.
The IP addresses will go away upon rebooting. You may want multiple IP addresses on new "semi-virtual" interfaces on a Linux server. These interfaces can be linked to a device such as eth1. The following method comes with a caveat as I have experienced networking problems with the method below. The main IP address stops working after an hour or two. The new interfaces with IP addresses may cause network instability on the server. The below method of creating new interfaces is not recommended for anything but theoretical testing or short-duration procedures.
# Usage instructions: Save the content below as fiveips.sh. Then do the following to run it: chmod +x fiveips.sh; ./fiveips.sh
#!/bin/bash
ip li add dummy0 type dummy
ip li add dummy1 type dummy
ip li add dummy2 type dummy
ip li add dummy3 type dummy
ip li add dummy4 type dummy
ip link set name eth20 label dummy0
ip link set name eth21 label dummy1
ip link set name eth22 label dummy2
ip link set name eth23 label dummy3
ip link set name eth24 label dummy4
ip addr add 33.33.33.33/28 brd + dev eth20 label eth20:0
ip addr add 33.33.33.34/28 brd + dev eth21 label eth22:0
ip addr add 33.33.33.35/28 brd + dev eth22 label eth23:0
ip addr add 33.33.33.36/28 brd + dev eth23 label eth24:0
ip addr add 33.33.33.37/28 brd + dev eth24 label eth25:0
# The IP addresses are just examples. The CIDR can be modifed as well.
# The interface names eth20 through eth25 are numbered in a high way (starting at 20) so as to avoid conflict with the server's NIC names.
# For a book on Docker, you may want to view this list.
Troubleshooting DSC for Configuration Management (Problem and Solution)
Background: DSC is a toolkit of PowerShell cmdlets that enable you to do configuration management. It can allow you to do CM tasks with Windows and Linux machines (https://msdn.microsoft.com/en-us/powershell/dsc/LnxGettingStarted).
Problem/Scenario: You are trying to use this PowerShell command (e.g., to test your Desired State Configuration tool):
Enter-PSSession -ComputerName goodServer -Credential jdoe
# where goodServer is a Windows server on the network and jdoe is a local user account on the goodServer machine.
# There may be a pop up for the password associated with jdoe. You may enter the correct one. But you are encountering an error like this:
"Enter-PSSession : Connecting to remote server goodServer failed with the following error message : WinRM cannot process the request. The following error with the errorcode ... occurred while using Kerberos authentication: There are currently no logon servers available to service the logon request. Possible causes are:
-The user name or password specified are invalid.
-Kerberos is used when no authentication method and no user name are specified.
-Kerberos accepts domain user names, but not local user names.
-The Service Principal Name (SPN) for the remote computer name and port does not exist.
-The client and remote computers are in different domains and there is no trust between the two domains.
-After checking for the above issues, try the following: -Check the Event Viewer for events related to authentication."
The event viewer has no leads for this problem.
Solution:
Prerequisite: You are logged on with local credentials to a Windows server that happen to be the same username and password as the credentials of the remote server ("goodServer" in this example).
1) Open PowerShell as an Administrator
2) Run this in PowerShell:
Set-Item wsman:\localhost\client\trustedhosts *
3) Respond "Yes" to the two following prompts. The problem should now go away.
------------
See this: https://sqlbelle.com/2015/02/09/installing-sql-server-using-powershell-desired-state-configuration-dsc/
Attached files taken from: https://www.youtube.com/watch?v=bz3D5ciOdgo
Start-DscConfiguration -Path C:\Users\Mike\Documents\SqlServerInstall -Wait -Verbose
What does the I.T. term “bootstrap” mean?
Bootstrap
Definition 1 (transitive verb) of bootstrap: To turn on a computer so that the operating system is completely functional. Source: The fifth definition of "bootstrap" in Dictionary.com is specific to "computers."
Definition 2 (transitive verb) of bootstrap: To intentionally initiate multiple subprocesses (especially a primarily automatic sequence of often incremental subprocesses), as in a batch execution, from a single file or action.
Examples of definition 2:
"Between the advent of handy tools, like Chef and Puppet, and virtual machine infrastructures, like VMWare and AWS, I feel like there has been a great debate about how to bootstrap machines." This quote was taken from Devops.com.
"In the following, I want to highlight how to create an Angular service that bootstraps the application with data defined in an ASP.NET MVC back-end." This quote was taken from a blog that was up in 2016 (https://blog.mariusschulz.com/2014/03/25/bootstrapping-angularjs-applications-with-server-%20side-data-from-aspnet-mvc).
Definition 3 (noun) of bootstrap: A software application for designing websites developed at Twitter. Source: TechTarget.
Definition 4 (transitive verb): To provision a server and install an agent on the server.
Definition 5 (adjective): A type of DNS server that initially allows other DNS servers to be found. DNS will work after the initial resolution of a hostname of a regular DNS server identified without an IP address. See this posting for more information.
To elaborate on definition 4, a configuration management tool's master server may control the server with this agent. This previous sentence and definition 4 are according to page 26 of Terraform Up & Running.
Background Commentary and Research Notes of The I.T. Term "bootstrap" and "bootstrapping"
- It could denote the process of turning on a server. It would connote the details of booting a server involving the initiation of a self-sustaining process from the time it power is turned on until the server begins to function. (1) Relevantly, the bootstrap loader (which is executable code) of a server is stored in the MBR. (2) The bootstrap loader loads the operating system during power up (and puts the kernel into memory according to page 1240 of A Practical Guide to Fedora and Red Hat Enterprise Linux by Mark Sobell). According to Techopedia a bootstrap loader is a synonym for boot loader or boot manager. Therefore one definition of the verbal phrase "to bootstrap a server" is "to turn on a server with a properly configured operating system." You can power on servers with no hard drives. The POST and BIOS will go through their processes. The server will not function properly because it cannot boot without an operating system
- A separate definition of "bootstrap a server" would be to "install an application with any necessary dependencies." When an installation process "bootstraps" something else it initiates on an as-needed basis a dependency-filling subprocess. However it would be less likely that you would semantically "bootstrap a server" with this alternate definition and more likely that you would observe or run an .exe file that bootstraps an application installation. To see an example of this separate definition of "bootstrapping" view this link from Microsoft that is for installing Office 2000.
- In the past tense or as a adjective describing a server, "a bootstrapped server" could refer to a self-configured or automatically configured server. (3)
- Bootstrap can mean to configure a server to participate as a node in a cluster (e.g., a Consul cluster). (4)
- To bootstrap a server in Chef is to make it a Chef client via installation and configuration of relevant media. (5)
- For web applications there is a bootstrapping process. This refers to a main file being a central point for joining together other files, initiating dynamic content (e.g., RSS feeds) connections and with other technologies (e.g., CSS). A definition from another source is 'In the context of PHP development, it also means funneling all web requests through a single script that performs the bootstrapping process, also called "front controller."' To see an example of the term "bootstrapping" (in the context of web technologies) that can itself be manual or automatic in the context of AngularJS view this old link (https://blog.mariusschulz.com/2014/10/22/asynchronously-bootstrapping-angularjs-applications-%20with-server-side-data) or read this StackOverflow answer.
- "Bootstrapping" even in strictly I.T. vernacular has multiple definitions. For further reading, you may want to see this link.