Day 32: Managing Multiple Resources in Linux using PowerShell DSC

Following up to last week’s article, Day 27: Managing Linux Users and Groups using PowerShell DSC, this week we’ll be demonstrating how to manage multiple resources in Linux using PowerShell DSC. In This week’s post is two examples, one for Ubuntu and one for CentOS, showing what a configuration can look like that is managing multiple items on a single host.

 

 

Sample Script for managing Multiple Resources in CentOS 6.2

Below is a sample Script that will do the following:

Ensures that the scom-svc-centos user is present.
Ensures that the scom-svc-users group is present.
Ensures that the root and scom-svc-centos users are members of the scom-svc-users group.
Ensures that the crond service is running.
Resets the password of the scom-svc-centos user account.

It should go without saying that storing credentials in clear text for Production purposes is a really bad idea; but just in case, the password here is in clear text for demonstration purposes only!

To use this script, first create the following directory on your DSC Scripting Host: C:\LinuxConfigs. Next, replace the value <COMPUTERNAME> in the $LinuxServer variable next to the -ComputerName: switch, with the name of your CentOS Host.

 

 

Sample Script for managing Multiple Resources in Ubuntu 12.04

Below is a sample Script that will do the following:

Ensures that the scom-svc-ubuntu user is present.
Ensures that the scom-svc-users group is present.
Ensures that the root and scom-svc-ubuntu users are members of the scom-svc-users group.
Ensures that the cron service is running.
Resets the password of the scom-svc-ubuntu user account.

It should go without saying that storing credentials in clear text for Production purposes is a really bad idea; but just in case, the password here is in clear text for demonstration purposes only!

To use this script, first create the following directory on your DSC Scripting Host: C:\LinuxConfigs. Next, replace the value <COMPUTERNAME> in the $LinuxServer variable next to the -ComputerName: switch, with the name of your Ubuntu Host.

 

 Conclusion

This week’s post has demonstrated how to manage Multiple Resource in Linux using PowerShell DSC. Hopefully, this has given you some ideas on how you can template resource management for your Linux Environment.

Previous Installments

100 Days of DevOps with PowerShell

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.