I have perused your reply but can't dig into it right at the moment. I will get 
back to it. Hopefully others also will chime in.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Nov 10, 2022, at 12:28 PM, Christopher Bachmeyer 
<[email protected]<mailto:[email protected]>> wrote:

Initially, I set up the Ansible Playbook outside of using a role, a plays/, 
vars/, group_vars/, and collections/ directories.  Yes, the network and 
vc_locations were being passed
in as extra_vars in Anbible Tower via  a Survey.

As things have grown, I recently converted that work over to an Ansible role.  
The conversion worked well and things run accordingly through Ansible Tower.  
The site.yml is what
is used including the vars_files sans the second role.  Now I am working on 
including the second role for post-processing needs of the deployed vms.

Yes, the vmware-windows role needs variables defined for the vcenter, vlans, 
etc.  Currently, I have multiple ymls built out holding the vars such as:
     vlan1.yml, vlan2.yml, etc.
     vcenter1.yml, vcenter2.yml, etc.
Doing it like this, I can have a prompt in the Survey for the Admins to 
customize the deployment.  I think I am following you, I can move those yml 
files over to tasks/ in the first role.

I did indent the second role, having to remove the hyphen from "name."  In 
doing so, I received two warning:


"[WARNING]: While constructing a mapping from /tmp/bwrap_ ... 
/project/vmware-windows- role/provision.yml, line 3, column 3, found a 
duplicate dict key (name). Using last defined value only

# Windows would be the inventory for the second role

[WARNING]: Could not match supplied host pattern, ignoring: windows

Thanks!
On Thursday, November 10, 2022 at 8:26:41 AM UTC-7 
[email protected]<http://nist.gov> wrote:
Does the vmware-windows role need the vars defined from the vars_files? If so 
then the role itself should include them inside it's task file(s). Move the 
vars_files inside tasks/main.yml. Anything the role does after that will get 
the value of those vars definitions.

The vmware-windows role will see the values of network and vc_location that 
come into the playbook executing the role. I presume they come in as extra_vars 
from command line or ansible tower.


Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123<tel:(202)%20355-4123>
On Nov 10, 2022, at 9:54 AM, Christopher Bachmeyer <[email protected]> wrote:

Hi, Walter,

That is correct.  I am, the vmware-windows role is the first play and creates 
the host_group "windows" to be used as inventory in the second play.
Right now, the second role is not indented but let me give that a go this 
morning.  I'm presuming to indent the entire block starting with the hyphen
( - name: .... )?

Regarding the vars_files, use import statements in the vars/main.yml of the 
first role?  I have multiple vars files under vars/ that are specific to the 
vcenters
and vlans.  Using vars_files and variables in the Ansible Tower Survey gives 
the Admins a way to customize the builds to the environment (which works well!).

Thank you!

On Thursday, November 10, 2022 at 5:23:04 AM UTC-7 
[email protected]<http://nist.gov/> wrote:
You need to make sure you use proper indentation. Your roles list needs to be 
indented two spaces like your vars_files.

Is it possible also that your sourcing of those the vars_files from within your 
role is overwriting the value of "windows" such that there is no inventory for 
the second play? Why do you source those vars files? The vmware-windows role 
will do that automatically.

- name: VMware-windows create role
  hosts: localhost
  gather_facts: no
  roles:
    - vmware-windows

### this vars_files should not be needed

  vars_files:
    - ./roles/vmware-windows/vars/{{ vc_location }}.yml
    - ./roles/vmware-windows/vars/{{ network }}.yml

- name: Windows-post role
  hosts: windows
  gather_facts: no
  roles:
    - windows-post


I presume that your vmware-windows role in the first play creates the host 
group called "windows" that you use as the inventory in your second play?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123<tel:(202)%20355-4123>

On Nov 9, 2022, at 5:30 PM, Christopher Bachmeyer <[email protected]> wrote:

Hey all,

I have two roles that are included in my site.yml and the goal is to execute 
the second role as soon as the first role completes.  I have added a task to 
generate a dynamic inventory in the first role that the second role can use.  I 
have a job Template in Ansible Tower and the first role executes cleanly but 
job Template completes without the second role executing.

What am I missing?

- name: VMware-windows create role
  hosts: localhost
  gather_facts: no
  roles:
  - vmware-windows

  vars_files:
    - ./roles/vmware-windows/vars/{{ vc_location }}.yml
    - ./roles/vmware-windows/vars/{{ network }}.yml

- name: Windows-post role
  hosts: windows
  gather_facts: no
  roles:
  - windows-post

Thanks!

--
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/907f209c-2a3a-465e-95a3-ae82c8f27d0bn%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F907f209c-2a3a-465e-95a3-ae82c8f27d0bn%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5560415534124642b0b108dac34111a3%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638036981485125911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=BFu7UD5EkW7Ar0WCxBkd4XyUDdGsq%2B0arpkcLkMaMUg%3D&reserved=0>.


--
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/37e14367-deed-4287-9a3a-f549975a7498n%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F37e14367-deed-4287-9a3a-f549975a7498n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5560415534124642b0b108dac34111a3%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638036981485125911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MB0xR5JKKcblT2RhQsq4n%2BcdeGbGmp1xNrfR9%2FYw%2Bw4%3D&reserved=0>.


--
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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/771d6e38-413b-486a-9da0-d89fa190e924n%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F771d6e38-413b-486a-9da0-d89fa190e924n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5560415534124642b0b108dac34111a3%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638036981485282145%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Wv1qpQjkA7OQ%2FjNv4XJtzgoq3oN2l7twx%2FQd1UkcpuM%3D&reserved=0>.

-- 
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/365BF4EA-2EA0-4463-BB85-FCC10F52C006%40nist.gov.

Reply via email to