Ascender Pro videos

Building playbooks via GitHub Copilot

Greg Sowell steps away from CIQ products to show how GitHub Copilot inside VS Code can get newcomers writing Ansible playbooks quickly. Typing a task name such as install Apache on Rocky Linux prompts inline suggestions that a Tab keystroke accepts, producing hosts, become, and task sections in seconds. When Copilot picks the generic package module, he highlights the block and uses the chat panel to request the dnf module with fully qualified collection names, then applies the change directly in the editor.

A second example asks Copilot to add a VLAN to a Cisco Nexus switch and place it on an access port; it produces nxos_vlans and interface tasks that need adjustments such as removing localhost, disabling fact gathering, and turning the VLAN into a variable. Greg notes that Copilot keeps variables from other open tabs in context and estimates it has cut his development time to about a quarter of what it was, at roughly ten dollars a month.

The session is for people new to automation who want a faster on-ramp, alongside CIQ workshops and hackathons.

Key takeaways

  • Copilot offers inline suggestions in VS Code as you type a task name, and pressing Tab accepts the generated playbook section.
  • Highlighting code and asking the chat panel to use the dnf module with fully qualified collection names rewrites the task in place.
  • Being more verbose in task names improves the quality of Copilot's guesses, and it remembers variables from other open tabs.
  • A Nexus VLAN request produced nxos_vlans and interface tasks but needed fixes such as gather_facts false and a real host.
  • Greg estimates Copilot has reduced his playbook development time to about 25 percent of what it used to take.

Questions this video answers

Can GitHub Copilot write Ansible playbooks?

Yes. In VS Code, Copilot suggests complete play and task sections as you type a task name, such as installing Apache on Rocky Linux, and Tab accepts them. The chat panel lets you refine the result, for example switching to the dnf module with fully qualified collection names, and apply the edit directly.

Does Copilot work for network automation playbooks?

It can. Asking it to add a VLAN to a Nexus switch and put it on an access port produced nxos_vlans and interface tasks. The output is not perfect: you still need to set the right hosts, disable fact gathering for network devices, and turn hard-coded values like the VLAN into variables.

About this video

Are you new to automation? Have a quick learning session with Greg Sowell. Greg will have you building playbooks via GitHub Copilot in no time!

What to expect:

  • Quickly get up and running with GitHub Copilot
  • How to install Apache on Rocky Linux
  • Add a VLAN to a Nexus switch

How are you using GitHub Copilot? Let us know!

This video is part of the Ascender Pro playlist. Browse every CIQ video by product and topic.

Transcript

hey everybody I'm Greg Sowell and welcome to another ciq demo today I'm not actually going to be demoing one of our products I'm going to be instead showing you how you can kind of get up and moving as fast as possible with Playbook so a lot of things I've done uh in the past is enablement based like I've been teaching people for a very long time and so um a lot of the folks I come into their environments they're brand new to anible they've never touched it maybe they've never even done automation period And so how can I get them up and working as

fast as possible one is to attend one of our workshops or have us coming and do a hackathon like that's that's a good one um because uh myself Jimmy Ford all of us love doing it and those other guys are really good at it I just pretend to be on TV but aside from that one of the things I found that is the most helpful at least in recent years is GitHub co-pilot Believe It or Not uh something in AI actually is real so what's the uh what's the uh joke running right now it's like uh hey quick find all of our marketing material find

and replace uh blockchain with AI right so it's it's such a buzzword but genuinely co-pilot uh GitHub co-pilot specifically is extremely useful because it integrates into say your vs code right here and uh can essentially help you build playbooks really quick so I thought I would just give some demonstrations so once you actually have it kind of integrated in you can see it's already like prompting me to you know control ey to do stuff so control ey pops up kind of a chat box that lets me um kind of type in what I want so I I can do that or it can start making

suggestions in line right so I could do the the three dashes and I'll do name and let's see if we can uh install Apache on Rocky ly okay there you go it already knows uh what it should probably do and once it makes a suggestion I can just hit Tab and it will accept all that code so here it added the host portion all I can change that to whatever I want it to be become yes that's probably going to be an accurate uh statement so become does privilege escalation so it's going to do sayu uh in Linux so it will actually kind of elevate

View full transcriptHide full transcript

per Villages which you generally need to to install stuff it created the task section install Apache let's see it's using package I don't like that so what I wanted to do is use the dnf module so instead here for example I can highlight this right here and I can either control I or I can hit chat right here and I like chat let's just say new chat so we'll kind of clean it out so it's nice and fresh and I can say uh use the fully qualified collection name and use the dnf module let's do that all right it's Rocky N I know I want to use kind of dnf so it's going

to be a much better representation and it made it fully qualified anible built-in dnf and then right there it allows me to apply an editor if I click that it just magically pushes that over so on this service one I want this to actually use a fully qualified collection name so right here I'm just going to say use all fully qualified collection names and it should make a suggestion right there and I'll go ahead and push that in and so you could see it quickly made the update right there so I can highlight individual lines I can highlight whole chunks of my code or I

can just say in general hey make this modification for me and it will do those things so here let's take a look at the service uh name yeah it picked the name State started and enabled yes so enabled is essentially telling it whenever you boot you should go ahead and start that service as well so you can see that you can quickly create your playbooks right if I want to keep iterating on this I can just add an extra line start typing what I want the name is the more verbose I am the better it is at guessing and also interestingly enough if I have

multiple tabs open it will keep that in its memory so if I create some variable in different Playbook or maybe it's a yl task file or something like that and I move back to a different tab it's going to have those variables in memory and so it'll actually start pre-populating some of my tasks with those variables it's so crazy how well it kind of integrates all these pieces together but it's not just your system stuff say I wanted to uh make a Playbook that does name um let's say uh add a a no we'll say add a yeah add a VLAN to a Nexus switch

then place that on um an access port so let's see what it suggests for me there does it actually suggest anything sometimes it doesn't right it doesn't know exactly what to do so you just go ahead and go to the next line and it'll go ahead and give you some options here host host Local Host that's going to be incorrect because my Local Host obviously isn't a Nexus switch but I mean you're going to have to change all that stuff anyway the connection local that's going to go away when you're not doing Local Host gather facts um turning that off actually is Paramount because in

your networking stuff I don't like no yes and no here I like false I like true and false I mean you're entitled to do it the other way but you're also entitled to be wrong so both work I just like true false uh but let's take a look it did n xos vlans um it yeah it uh did the interface so it's actually configuring the interface and it just kind of arbitrarily picked a VIN uh it's pretty cool so I could go ahead and maybe add a VAR section say here's the uh the VLAN variable and then uh I can have it go ahead and

replace that throughout the rest of this so you can see it's not 100% foolproof perfect but it sure is getting you there really quick so I'm just going to say for 10 bucks a month which is what this costs which is pennies honestly if you really break it down it's less than you're paying for coffee every day uh it can really rapidly increase your development cycle so I think I've cut mine down to 25% of what it used to take for me to do all this stuff and uh it's even good at like complex reject uh statements and various things like that so if you

want to use this Beyond playbooks it's great at virtually every programming language that exists out there so uh if you have any questions or comments I would love to hear how you're using this do you have any special hidden features in here um I know my guy Nick is the one who turned me on to this and he has done some Incredible Kung Fu with it so he'll probably have some suggestions in there uh but if you have any let me know if this is new to you let me know too if it's uh helped you out in some various ways I'd love to hear

that as well so uh if nothing else uh Happy um Playbook creation happy co-piloting and we'll see you next time bye

Built for scale. Chosen by the world’s best.

2.75M+

Rocky Linux instances

Being used world wide

90%

Of fortune 100 companies

Use CIQ supported technologies

250k

Avg. monthly downloads

Rocky Linux

9

Enterprise products

Spanning the kernel to the orchestrator

Have questions about your infrastructure?

Talk to a CIQ engineer about Rocky Linux, HPC, and AI infrastructure.

Talk to an Expert