Ascender Pro videos

Seeding inventories in Ascender

An inventory is the list of every host automation can act on, and adding hosts one at a time through the Ascender UI does not scale. In this demo Greg Sowell shows how to seed an inventory with hundreds or thousands of hosts in a single sync, a technique that also applies to AWX and AAP. After creating an empty seed demo inventory he reviews the dynamic source options for cloud providers and vCenter, points to his separate video on custom sources for a CMDB, and then chooses Sourced from a Project to read an inventory file from a Git repository.

The INI-style file will look familiar to anyone who has used command-line Ansible. A bracketed group name, mountain-hosts, collects the entries. One host is a resolvable fully qualified domain name, another is a short name paired with the ansible_host magic variable and an IP address, and two more use bracketed numeric ranges, one expanding an IP address across 512 addresses and one generating web server names from 001 to 254. Group variables can be added in the same file.

Greg explains the overwrite, overwrite variables and update on launch options, warning that overwrite wipes manually added hosts and that update on launch suits changing sources like clouds and CMDBs more than a one-time seed. After the sync, the inventory shows 764 hosts, all sorted into the group.

Key takeaways

  • Sourced from a Project reads an INI or YAML inventory file from a Git repository and imports every host it defines in one sync.
  • Hosts can be listed as resolvable fully qualified domain names or as short names paired with ansible_host and an IP address.
  • Bracketed numeric ranges such as [0:1] and [1:254] expand into hundreds of IP addresses or hostnames automatically.
  • Greg avoids bare IP addresses in production inventories because job output then gives no clue what each host actually is.
  • The overwrite option wipes hosts added manually, and overwrite variables replaces existing host variables with those from the file.
  • Update on launch refreshes the source before every job, which suits dynamic cloud or CMDB sources rather than a one-time seed.

Questions this video answers

How do I bulk add hosts to an Ascender or AWX inventory?

Create an inventory, open its Sources tab and add a source of type Sourced from a Project pointing at a Git repository containing an INI or YAML inventory file. Define groups, FQDNs, ansible_host entries and numeric ranges in that file, then sync the source. Greg's example imports 764 hosts in a single run.

Can Ansible inventory files generate hostnames or IP ranges automatically?

Yes. A bracketed range like webserver[001:254].greg.com expands into 254 hostnames, and octet ranges such as [0:1] and [1:254] in an IP address expand into blocks of addresses. The same syntax works in a seeded Ascender inventory, though Greg prefers named hosts in production so job output is meaningful.

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 I'm here with another ciq demo so today I'm going to be showing you how to seed your inventories in Ascender or Ascender or awx or AAP whatever you happen to be using how you can kind of quickly get a bunch of host into your inventory so what is an inventory it's a big list of all the hosts you could potentially operate against when you're running a piece of Automation and if I pop over to my inventories right here I'm going to create a new one really quick and that is easily done by clicking add add inventory

it's going to load this screen and I will say seed demo because that's what I'm doing today I'm going to go ahead and click save and I've got my inventory created now traditionally you can come in here and you can click on host and I can add them host rather I can add those hosts one at a time right just by clicking add filling in the blanks put in either a fully qualified domain name here or just a host name and then down here anable host if I want to but that again is manual it's a little bit clunky it's great for demo environments or

test environments but in actual production you want that to be a little bit more Dynamic right you kind of want that to move on its own and that is done by going to the sources tab so this is where we're going to pull in Dynamic inventory sources so I can click add here and it gives me some options right I can give it um inventory file is what mine's going to be um but for sources here I have multiple options so if you have a cloud provider those are going to be supported in here right your Amazon your Google your Azure all those stuff and

it will connect in there to your cloud provider and pull in all of your say ec2 instances all those hosts will kind of get added dynamically in here that's great um right also VMware V Center that's another big one we see but if it falls outside of this what do you do and so I actually have a blog post and a video associated with that blog post that shows you how to do custom Dynamic inventory sources so if you've got a cmdb a configuration management database out there that you want to uh Connect into some system and Pull It in I've actually got something that

View full transcriptHide full transcript

shows you how to do that but say for example I just need to seed it my inventory is going to be fairly static um and I just need to pull a bunch of hosts in here this is really great for testing environments and things like that I could do something else so I can Source from a project and what that really does it's going to point towards a get repository I've already created one um and in fact it is this one right here I'm using my Mountain V2 migration one because I've already added kind of the seating inventory script in there so I'm just going

to cheat and use that one so I'm going to Source some project project I'm going hit the magnifying glass right there and I'll choose my Mountain V2 migration project again remember get repository has all my stuff in here next it's going to prompt me for inventory file and so in this one I am going to to be choosing inventory unor Ascender and so what I'm really doing here is I believe it can be yaml formatted or inii based uh I'm doing inii based in mine so if I take a look at the inventory file itself if you've ever done command line anable this is going

to seem extremely familiar here I've got uh two brackets with the word mountain- host inside of there that's essentially what I'm doing is setting up a group right and then anable in an inventory a group is a way for you to uh put bunch of hosts in there and so rather than in the host portion of my playbook referencing every one of those individually I can just reference the host or rather the uh the group and it will pull all of those in um in here I've got a couple of examples so the very first example is going to be a fully qualified domain name

and if anible gets an fqd in it's going to be able to resolve that connect to that host you're done right you're good you can move on the next example is me showing you uh in this inventory file a host that isn't fully qualified right it's not resolvable so in here I use a magic variable anore host I put an IP address in this tells anible Hey whenever I'm connecting to web host 44 go ahead and use the IP address 192168 1.44 to to connect to them and uh I'll be able to uh essentially grab their IP connect to it everything's great next is showing

how to kind of dynamically build some stuff which is interesting so here I'm doing an address range you can see I have bracket number call and number and that's really essentially telling it hey scan our scale from this number to this number right so here I have 0 to one as well as in the the last octet there I have 1 to 254 right so this is going to do 224s it's going to be 10.

13410 do0 all the way to 103411 254 right so like 512 hosts I'm going to be able to have in there so that's a good way to pull in whole bunch of IP addresses is really quickly right so again if it's kind of a lab environment or um a demo environment or maybe in some production environments it's a little bit risky I I I really don't like putting in just IP addresses because I have no idea what that thing is right there's kind of no description and when I am automating this like in Ascender the output is just going to show those IP address

right so I I really don't know what those hosts are so I I generally don't try and do that in my actual production environments but if you're in a pinch you need to see this inventory really quickly U maybe you've got some zero day and you just need to um throw it against all of your host to fix some stuff this could be a way for you to do that via IP address now in the last example we also support that number range option inside of fully qualified domain names so right here web server and then it's going to scale from 001 all the way to 24.

greg.com right so it'll actually flesh all that out in the inventory so we're we're going to use this to seed right so you could copy and paste this make modifications if you want create different groups add things to dynamically different groups so when it gets imported in the inventory it'll actually get sorted into those groups as well you can also do a group bar section in here so if you wanted uh variables associated with just the mount host group to to actually get pushed in you can do that as well so all the things that you're accustomed to you can actually do it in the

seating method so I have chosen my inventory now down here at the bottom I have uh a few additional options and so I have overwrite overwrite variables and update on launch so what overwrite will do is it will take whatever is in this inventory it's essentially going to wipe it out and then whatever it pulls from this inventory file will get installed right so that can be a little dangerous if you have some hosts in there that you've manually added they're going to get wiped uh on run if you had that checked you also have overwrite variables and so what this will do is um

by default if it pulls extra variables for say web server 001 it will just add them to the existing variables that Happ to already exist for that host if it's already in there um override variables if you hit that check boox it will wipe any variables associated with that host and it will only install the ones that is dynamically pulling in from that file right so can be a little dangerous in that respect as well uh update on launch is a nice one so what that will do is anytime you're using this inventory any piece of automation that's utilizing it it will first pause that

Automation and it will do a Refresh on this inventory file right so theoretically if this is something that gets updated regularly it will pull in and make sure you have the newest version that's really more useful I I would say like if you're just seating an inventory often times that's going to be a one-time thing so you don't really need to update on launch uh update on launch I usually see that with kind of cloud providers or cmdbs that are Dynamic right things that are changing you want to kind of pull those hosts in my think of this is more you're just trying to pull

in a bunch of hosts really quick one time because we need to crank some automation against those things once we're done I'm going to click save and I'm going to go ahead and synchronize that and through the magic of editing you won't have to wait all right it is now seated that inventory right so you can see job status up here says successful that means it's consumed that inventory file it's pull all that stuff in so I'm going to click up here uh to go back to the C demo inventory itself self then I'm going to click well I mean I don't even have to

click anything right here you see total host 764 so it has autocreated a whole bunch of a host I'm going to click on the host section so you can see it should start out with all of these IP addresses right here on the right under related groups you can see they're all under the mountain- host group so all of that is listed as imported as well so you can see it's pulled in a bunch of stuff I'm going to change the Sorting on this right here so that it will reverse sort and now we can see kind of the web servers you see 254 moving

its way all the way down and again in the list down here 764 so as you can see a really quick way to seed your inventories especially if you need to do some quick and dirty operations on something uh if you have any questions or concerns or you would tweak or tune this to match your environment I'd love to hear from you I am definitely a big advocate of feedback so I give me uh constructive feedback uh I'm always willing to to hear it if you have any questions comments please reach out to us we definitely want to hear from you in that respect too

you're looking for support on Ascender or you'd like to talk more about its capabilities or migrating from awx or AAP be happy to do that uh if nothing else happy automating happy seating your inventories and we'll talk to 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