Retrieving IP address for new server from the AWS Console after new server is built

Kristin K_
Tera Contributor

Good Morning,

 

I am currently building a ServiceNow Automation that will use Ansible templates to build Non-Production and Production servers. There's also a template in Ansible that will add the Server to DNS by name and IP address after the new server is built.

 

The IP address variable in the DNS Ansible template will not be on ServiceNow form but I need a way to retrieve IP address from AWS after the server it built. Is there a way to make ServiceNow communicate with AWS to retrieve the IP address for the new server? Could a create a client script or anything?

 

Is there a way to create a get command to retrieve and IP from a newly built server?

 

 

 

1 REPLY 1

Gary Diehl
Tera Contributor

I'm also looking for a better way to do this.  After the server is built, there isn't a CI in the SN CMDB yet, and kicking off a Discovery takes an IP address.  The way I have is rather clunky and slow, and I'd love to be able to get the IP address of the newly built server in a single action that just passes the servername.  I don't have anything that elegant though, and I don't see any action in ServiceNow that does this function.  What I'm doing is:
1. using the servername returned by ansible
2. calling jenkins spoke build with parameters to run an ansible job that does an nslookup
3. waiting for the job to finish (jenkins get build id / jenkins job status)
4. getting jenkins console output into a local flow variable

5. parsing out the data I need (indexOf() and string slicing)

6. validating that what I got was an actual ip address in the correct range (glidescript)

7. then calling discovery, waiting for that to finish
8. checking that devices discovered > 0 and
9. cmdb ci lookup
10. cmdb ci update with values I care about (app name, requestor, ritm, etc)

then the IP is available from the CI record after that, so it's easy to find an use.  but before that?  it feels like going the long way around the barn to get it.  where is there a single-action pass-servername and get IP address back?  I'd love for that to be a thing.