[Autogenerated] last thing we're going to do in this demo is desired
state configuration particularly Azure automation dsc let's take the
example that we want to enforce the iis web server and some basic
content on one or more of our machines.
I have a configuration here called web server that has a single
string parameter that defaults to the local host,
looks like we need the web administration and desired state
configuration resources and it looks like I haven't installed these
modules on my workstation now I always could do and install module to
grab those from the PowerShell gallery.
But I actually am going to let Azure automation dsc do all the work for us.
So this is going to substitute the computer name,
parameter as the node name and we're specifying that the I.
S features should be present, the management console should be present,
scripting sp .NET we've got the default website that looks like it
will be present but stopped for some reason.
That's kind of weird.
Now if you're wondering what are the proper parameters and values,
you could just look in the Microsoft docks for the x.
website resource and you can see I'm assuming started is also a valid option.
Let me make that change here.
We can do dependencies here and then in this case it's going to create a
demo folder and put in just a placeholder index dot html.
Welcome to the Pluralsight 800 training course and we've got a web pool.
So as you can see,
we're declare a tiddly defining how we want that machine to behave right.
So that is our configuration.
Let me show you how to get this off the ground.
And Azure automation dsc in our automation account will come up to state
configuration dsc here on the state configuration.
Dsc page we can see a list of on boarded nodes.
We actually want to start on the configurations played here
and I'm going to add a new configuration.
It says that the file must be a PS one script smaller than one megabyte.
That shouldn't be a problem.
So let me grab on my dsC folder, that web server,
PS one I'm going to call it Web server.
Okay.
In order to make the configuration usable by nodes,
it has to be compiled into managed object format.
So let me select the web server.
Configuration and we'll run a compile on it right now.
It's going to default to local host.
That's fine because I'm just going to have each node that
ingests this used local host as its name,
says that that configuration job completed.
I have another configuration that I've already uploaded and compiled called.
Test Config.
That's pretty interesting.
Let me show you the configuration source here.
There's some clever use of the node keyword here basically.
It's called Test Config and then if we specify is web server,
then we're saying that the IIs server needs to be present with all sub features.
But if we apply the configuration, test Config dot not web server,
then it's just the opposite.
We want to make sure that IIs is not present.
I kind of like that better than the one that I just uploaded.
So why don't I go back to the root here and let's go back over to
nodes and let me show you how to onboard your nodes into dsc so
that they can ingest the configuration.
Now.
You should note that a node can have only one dsc
configuration at a time and that's a bit unfortunate
because that's going to lead to monolithic.
Dsc scripts.
There was a concept of partial configurations a while
ago and composite configurations.
That's still a thing.
Fortunately we don't have to get that deep in the weeds
for asi 800 I'm grateful for that.
Let's click add on the nodes page and this is where we can
specify which of our machines we want to on board.
I'm going to choose my VM three A machine that is an Azure machine
looks like the VM is showing as de allocated.
Yikes.
So let me quickly fix that by going over to my virtual machines.
Note Oh yeah, it sure is.
So why don't I go back to automation accounts?
Let's try this again, repetition is a good thing.
Right, repetition is a good thing.
Now, one thing to keep in mind.
The user interface is a little bit weird.
The add button here, depends upon where you are.
That is if you're on nodes and click add,
that's how you would onboard a new node.
Two dsc on the configurations page.
Ad does a configuration upload.
Takes a little bit of getting used to let's go to add and let me grab
VM one this time and let me connect it in here.
And what we're doing here is configuring the L c M or
the local configuration manager.
I'm going to first specify my config in this case,
I'm going to say test Config is web server.
We've got our refresh frequency.
How long will the node wait before checking the Azure automation pull
server to see if there's any changes to the configuration.
That's 30 minutes.
Config mode is important because this determines compliance.
You don't want to be too aggressive with that mode frequency.
I'm going to leave the defaults the configuration mode.
I'm actually going to do apply an auto correct,
which is the most aggressive option.
That means that if one of my colleagues,
let's say we're to uninstall the IIS server on the
machine at the next configuration mode,
the dsc LLC M component would automatically reinstall and
potentially reboot the server C So I'm going to do a reboot node
if needed and after reboot we're going to continue configuration
now there's a couple d sclc.
M configuration manager.
PowerShell commands,
you can adjust the L C M properties on the node with PowerShell and we
can also do it centrally here in the Azure automation.
Dsc panel.
This is just a convenience to configure the L C M as we're on boarding machine.
Let's connect this machine into dsC And while we're waiting for that,
let me open up another instance of the portal and let's see if we
can beat dsc I want to quickly log in the VM one.
Let's do a bastion connection.
Going to sign in with my domain administrator credential,
see if I can type and click at the same time.
I'm going to open up power shell session here administrative PowerShell session
and I'm going to do a get Windows feature web server and as you can see it's not
installed yet but we're going to find in time once this machine is on boarded it
will be a web server and like I said,
we can check the current Elsie M settings with get
dsc local configuration manager, the L c m state is busy so it is working,
it is set for apply and auto, correct.
So it looks like we are in fact connected into Azure we can see down
here as your automation DsC is our poll server.
Let's come back to the portal.
If I refresh, I can see my L CM settings.
If I come back to my nodes view,
I can see that VM one is in progress with the test.
Config is web server node configuration let's go back to VM one,
make clear the terminal up arrow and let's check the status of the web server,
yep we can see now that is has been successfully installed.
And, like I said, because of the apply and auto correct Elsie M property.
This is going to ensure that our configuration does not drift out of our desired state for this server.