Yes. We use TWO plays in a playbook. The first play uses an extra_var of 
the hostname to create a new host group. The second play scopes its 
inventory to that host group.

In our workflow the new machines' name comes in as an extra var called 
vm_guest_name.

##

*## play 1: add new machine to inventory*##
- name: Add new host to playbook inventory
  hosts: localhost
  gather_facts: no
  tasks:

    # add our new host to the inventory for this play




*    - name: add {{ vm_guest_name | lower }}      add_host:        name: 
"{{ vm_guest_name | lower }}"        group: newvm*
##

*## play 2: customize new machine*##
- name: "Customize Server - Linux - Set Time Zone, Hostname, Join AD"
  gather_facts: no

*  hosts: newvm*  become: yes

--
Walter Rowe, Chief
Infrastructure Services
Office of Information Systems Management
National Institute of Standards and Technology
United States Department of Commerce
On Monday, August 1, 2022 at 8:05:01 AM UTC-4 [email protected] wrote:

> It's that the add_host directive? 
>
> Get Outlook for iOS <https://aka.ms/o0ukef>
> ------------------------------
> *From:* 'Walter Rowe' via Ansible Project <[email protected]>
> *Sent:* Monday, August 1, 2022 11:58:48 PM
> *To:* Ansible Project <[email protected]>
> *Subject:* Re: [ansible-project] Deploying Windows Server using Ansible 
> Tower 
>  
> One more item I will add .. in our Customize step of our workflow we do 
> create an in-memory inventory with the new machine name so the steps in 
> that lengthy process have an inventory to work on.
>
> --
> Walter Rowe, Chief
> Infrastructure Services
> [email protected]
>
> Office of Information Systems Mgmt
> National Institute of Standards and Technology
> US Department of Commerce
> On Monday, August 1, 2022 at 7:43:24 AM UTC-4 Walter Rowe wrote:
>
> The "secret" to any good provisioning workflow is to parameterize 
> EVERYTHING. We feed user specifications from a ServiceNow request into our 
> Ansible Tower workflow. These specifications include what network, what AD 
> OU to deposit the new computer object we create, what function the server 
> will provide, what OS and version (windows 2016, windows 2019, ubuntu 20, 
> ubuntu22, redhat8, rocky8, debian10, debian11, etc), AWS or VMware, etc. 
> Our playbooks in ansible tower use most of these parameters from the 
> ServiceNow request as keys into dictionaries or as indicators of specific 
> vars files to import that have detailed specifications in YAML format we 
> can use to do all our work for provisioning. We can add new operating 
> system versions, new cloud service providers, new machine purposes and 
> describe all of these in our vars files and parameters from ServiceNow. We 
> have to make few if any changes to the actual playbooks. Even attached 
> storage is described in a JSON list that cleverly has all the disks 
> associated with each machine type for both Windows and Linux. A json_query 
> lets us pull out the records we need from the JSON list. 
> --
> Walter Rowe, Chief
> Infrastructure Services
> [email protected]
>
> Office of Information Systems Mgmt
> National Institute of Standards and Technology
> US Department of Commerce
>
> On Monday, August 1, 2022 at 7:30:28 AM UTC-4 Walter Rowe wrote:
>
> You don't need the machine added to an inventory and you don't need 
> ansible tower callbacks. The vmware_guest module doesn't require either 
> one. You do need to know the name of the new machine in a variable.
>
> We have a very elaborate ServiceNow -> Ansible Tower request and deliver 
> workflow. We create the VMs (or EC2s in AWS), then create the DNS record, 
> then do OS level machine customization.
>
> Email be directly and I can set up a TEAMS call to show you our playbook 
> for creating a machine in VMware.
>
> [image: ASP-Workflow-Concept.png]
>
> On Friday, July 29, 2022 at 3:28:03 PM UTC-4 [email protected] wrote:
>
> Sounds like good use of Tower callback function. That way Tower does not 
> have to know anything about the new host. Just be sure the windows image is 
> configure for ansible, and then use either a cloud_init or or a first run 
> script to execute the callback.
>
> On Fri, Jul 29, 2022, 12:18 PM Wei-Yen Tan <[email protected]> wrote:
>
> You can use add_host to the playbook that generates In memory hosts during 
> the execution run 
>
> Get Outlook for iOS <https://aka.ms/o0ukef>
> ------------------------------
> *From:* 'Nicholas Branson' via Ansible Project <
> [email protected]>
> *Sent:* Friday, July 29, 2022 10:31:11 PM
> *To:* Ansible Project <[email protected]>
> *Subject:* [ansible-project] Deploying Windows Server using Ansible Tower 
>  
> Ansible Newbie Calling... 
>
> We have Ansible Tower and Satellite. 
>
> I've been asked to look at Deploying Windows Server using Ansible Tower.
>
> I've created a win2019-tmp (template) in VMware
>
> Now I need to look at creating a Role playbook to deploy a Windows system 
> in VMware.
>
> I've made a start on the main.yml and vars.yml files but I am not sure 
> they will run on my new pipeline yet. 
>
> Is there a way to check if the pipeline is ready to test playbooks on ?
>
> Also, since I will be deploying a Windows Server that has not been created 
> yet, how can I put any info in the Ansible Tower Template Inventory area if 
> it does not exist?  
>
> I hope someone can help me with Windows deployements using Ansible. I 
> couldn't find a suitable Red Hat course for this.
>
> Thanks
> Nick
>
>
>
>
>
> DISCLAIMER
>
> This email is confidential and subject to important disclaimers and 
> conditions in relation to monitoring, viruses, confidentiality and legal 
> privilege full details of which can be viewed on our Email Policy at the 
> following link: http://www.next.co.uk/Policy/
>
> Next Holdings Ltd registered in England 35161.  Registered Office Desford 
> Road Enderby Leicester LE19 4AT.  Authorised and regulated by the Financial 
> Conduct Authority
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/a54de861-ffef-4f15-bffa-46d472101ec2n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/a54de861-ffef-4f15-bffa-46d472101ec2n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/SYBP282MB3525DE557DE6C3D303B25B79AD999%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM
>  
> <https://groups.google.com/d/msgid/ansible-project/SYBP282MB3525DE557DE6C3D303B25B79AD999%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>
> .
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/69f1b3bf-9a56-444e-a611-343615727b06n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/69f1b3bf-9a56-444e-a611-343615727b06n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8f59306d-075f-4144-8c93-d0a238eca353n%40googlegroups.com.

Reply via email to