How to Write Puppet Code Faster with PDK, VSCode & Copilot
As a Puppet developer, you probably spend a lot of your time writing Puppet code and building Puppet modules. Using GitHub Copilot to write Puppet code translates natural language commands into Puppet code, helping you spend less time coding and more time doing the value-adding work that lets you shine.
Let’s demo how to use GitHub Copilot with the PDK and the Puppet VSCode extension to write Puppet code faster.
Links:
- Download the Puppet Development Kit (PDK) on the Forge
- Get the Puppet VSCode extension on GitHub
- Learn more about GitHub Copilot
Using GitHub Copilot to write Puppet code translates your natural language commands into Puppet code. In this demo by Puppet Software Engineer Jordan Breen, learn how to use GitHub Copilot with the Puppet Development Kit (PDK) and the Puppet VSCode extension to write Puppet code faster.
Watch the demo video and read the post below to learn:
- How to write a Puppet manifest with GitHub Copilot
- How to run a test on Puppet code with Copilot
- How to create a Puppet resource with Copilot
Step 1: Download the Puppet Development Kit (PDK)
The Puppet Development Kit (PDK) is what enables you to create Puppet modules. It gives you a simple interface and set of tools for writing code as Puppet modules, and it’s available for several major operating systems. Download PDK here.
Back to topStep 2: Download the Puppet VSCode Extension
The Puppet VSCode extension speeds up coding with IntelliSense, debug features, linting, and more. It’s maintained by the group Lingua Pupuli, and you can download it from GitHub here.
Back to topStep 3: Download GitHub Copilot
Copilot is an AI developer tool from Microsoft, and its integration with GitHub lets developers write code from natural language (among other features). Copilot plans and pricing vary based on usage and team size, and you can find more about it here.
Back to topStep 4: Tell Copilot What You Want
Copilot can turn phrases like “write a Puppet manifest,” “write some unit tests,” and more into Puppet code for linting and review. Give it a try by opening the Copilot chat in VSCode or by pressing Command + Shift + I
(or Control + Shift + I
on Windows) and then typing out your request.
Here are a couple of examples of natural language input from the demo video above and the Puppet code Copilot returns when prompted:
Prompt: write a puppet manifest
class mymodule::mymanifest {
# Define your resources here
# For example, you can create a file and set its content
file { '/path/to/myfile':
ensure => present,
content => 'Hello, World!',
}
# You can also install a package
package { 'mypackage':
ensure => installed,
}
# And manage a service
service { 'myservice':
ensure => running,
enable => true,
}
}
Prompt: create a virtual host using the puppetlabs-apache module
apache::vhost { 'myvirtualhost':
servername => 'example.com',
docroot => '/var/www/html/',
port => '80',
priority => '10',
serveradmin => 'admin@example.com',
options => ['Indexes', 'FollowSymLinks'],
directories => [
{
'path' => '/var/www/html/',
'options' => ['Indexes', 'FollowSymLinks'],
'allow_override' => ['All'],
'require' => 'all granted',
},
],
}
Back to topTake Your Puppet Skills Further
Companies around the world rely on Puppet – and they’re looking for skilled practitioners to customize Puppet for their critical infrastructure.
If you want to learn how to make better modules for smarter automation and better IT management, check out Puppet training courses. They’re free to start on demand, feature live-learning, and cover everything from writing basic Puppet code to advanced testing strategies.
Back to topWe encourage you to leverage Puppet's software development kit and VSCode with GitHub Copilot as a means to augment your development processes. Using these three items in tandem can assist you in accelerating the development process, but we want to remind you that the critical thinking and problem-solving aspects of software development remain firmly in your hands.