hostname supplied on the cmd line

I have a situation I’m positive is not very unique where I’d like to leverage Ansible to set the hostname of a node upon intial setup post it’s installation. The node where I call the ansible playbook from is using the proper hostname as the names are pre-generated, pre-known, already resolvable via DNS.

Could the calling script inject the names into the standard gathered facts? I know I could use reverse DNS to get going, but it sure seems like there’s some shortcut that everybody else uses that I’m not aware of.

I just tried more searches and I think I found it: $inventory_hostname

Yep, you should do {{ inventory_hostname }} though, to use the newstyle variable system.

It becomes easier if you want to use more complex data later.