Re: [ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-16 Thread Mike Eggleston
Create a local, temporary file of the new hosts and environment variable 
ANSIBLE_INVENTORY?

Mike

> On Aug 16, 2019, at 00:34, Zolvaring  wrote:
> 
> I'm not sure I understand fully, but none of the hosts you are configuring 
> need Ansible to be installed for you make changes remotely. Instead of 
> defining your hosts in a CSV, define your hosts as part of Ansible inventory 
> and your tasks will loop through them naturally. You can also group hosts as 
> you had mentioned, and run task or assign vars to specific groups, just as 
> you had in your example. To execute a play only on remote esxi servers one 
> way is:
> 
> - name: configure esxi hosts
>   hosts: esxi-hosts
>   roles:
>  - your roles here
> 
> If I run this play and have 5 esxi hosts in my inventory group, then this 
> will run all roles or tasks each time for each of those 5 servers in parallel
> 
> Making use of group_vars files and host_vars files can change the play vars 
> based on the group.
> 
> 
>> On Thu, Aug 15, 2019, 9:15 PM Kurt Robinson  wrote:
>> I intend to Ansible to run deployment configuration on a number of Dell ESXi 
>> hosts in VMware using VMware and OpenManage modules.
>> 
>> In my past ansible training, my playbooks have always run from hosts that I 
>> have defined in an inventory file. The machines I wish to configure don't 
>> have ansible installed so they will be managed from the localhost node.
>> 
>> My question is, what is the best practice in running configuration tasks on 
>> these machines that aren't actual hosts within ansible?
>> 
>> Currently, I am thinking of creating a csv file which will contain the host 
>> information, then loop through each host and run my tasks to run on each 
>> host using read_csv.
>> 
>> 
>> 
>> pseudo:
>> 
>> - name: Read csv and send to task
>>   csv_read: csvname.csv
>>   task:
>> - taskname 
>>   passvar:
>> - csv.hostname
>> 
>> 
>> 
>> - name : Run task
>>   loop: name in csv.hostnames
>> do: something
>> 
>> 
>> 
>> To me this seems like I am under-engineering the solution a bit. Is there a 
>> better way I can do this?
>> 
>> Would I be able to add the list of hosts that I want to configure to an 
>> inventory file, then reference a group for which I will run my 
>> configurations on?
>> 
>> E.g.
>> 
>> inventory
>> 
>> [management]
>> 10.0.0.1
>> 10.0.0.2
>> 
>> [database]
>> 10.1.0.1
>> 10.1.0.2
>> 
>> __
>> 
>> - name: Set DNS on hosts
>>   vmware_module:
>> hostname: '{{ management group }}'
>> dns: 1.2.3.4
>> 
>> 
>> 
>> Thanks for taking the time.
>> 
>> 
>> -- 
>> 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 ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/2c702252-eae3-461e-842f-989e80d88537%40googlegroups.com.
> 
> -- 
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/CAKEXu85Ga7EadHRB%3DyP8hCQqy7S%2BTqCKmkCp%2BTj5CV10LpL5Ew%40mail.gmail.com.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/93B6A099-DFB3-464D-858C-D64FA5C2ADC8%40gmail.com.


[ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-15 Thread Zolvaring
Seeing that you may want to loop through actual guests, I would still define 
them as Ansible inventory hosts if you know them ahead of time, and if you need 
to run tasks from a different host by invoking VMware module then try:

- name: do a thing to a guest
  vmware_module:
regular_module_args
  delegate_to: localhost (or somewhere else)

The end result will still naturally loop your inventory but will run from 
whichever host you delegate the commands to.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5823722d-4152-48ad-8b0b-b288e9604b8a%40googlegroups.com.


[ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-15 Thread Zolvaring
I'm not sure I understand fully, but none of the hosts you are configuring need 
Ansible to be installed for you make changes remotely. Instead of defining your 
hosts in a CSV, define your hosts as part of Ansible inventory and your tasks 
will loop through them naturally. You can also group hosts as you had 
mentioned, and run task or assign vars to specific groups, just as you had in 
your example. To execute a play only on remote esxi servers one way is:

- name: configure esxi hosts
  hosts: esxi-hosts
  roles:
 - your roles here

If I run this play and have 5 esxi hosts in my inventory group, then this will 
run all roles or tasks each time for each of those 5 servers in parallel

Making use of group_vars files and host_vars files can change the play vars 
based on the group.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e1640dc5-3875-46f2-95f2-fe3f9efc4819%40googlegroups.com.


Re: [ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-15 Thread Zolvaring
I'm not sure I understand fully, but none of the hosts you are configuring
need Ansible to be installed for you make changes remotely. Instead of
defining your hosts in a CSV, define your hosts as part of Ansible
inventory and your tasks will loop through them naturally. You can also
group hosts as you had mentioned, and run task or assign vars to specific
groups, just as you had in your example. To execute a play only on remote
esxi servers one way is:

- name: configure esxi hosts
  hosts: esxi-hosts
  roles:
 - your roles here

If I run this play and have 5 esxi hosts in my inventory group, then this
will run all roles or tasks each time for each of those 5 servers in
parallel

Making use of group_vars files and host_vars files can change the play vars
based on the group.


On Thu, Aug 15, 2019, 9:15 PM Kurt Robinson  wrote:

> I intend to Ansible to run deployment configuration on a number of Dell
> ESXi hosts in VMware using VMware and OpenManage modules.
>
> In my past ansible training, my playbooks have always run from hosts that
> I have defined in an inventory file. The machines I wish to configure don't
> have ansible installed so they will be managed from the localhost node.
>
> My question is, what is the best practice in running configuration tasks
> on these machines that aren't actual hosts within ansible?
>
> Currently, I am thinking of creating a csv file which will contain the
> host information, then loop through each host and run my tasks to run on
> each host using read_csv.
>
>
>
> pseudo:
>
> - name: Read csv and send to task
>   csv_read: csvname.csv
>   task:
> - taskname
>   passvar:
> - csv.hostname
>
> 
>
> - name : Run task
>   loop: name in csv.hostnames
> do: something
>
>
>
> To me this seems like I am under-engineering the solution a bit. Is there
> a better way I can do this?
>
> Would I be able to add the list of hosts that I want to configure to an
> inventory file, then reference a group for which I will run my
> configurations on?
>
> E.g.
>
> inventory
>
> [management]
> 10.0.0.1
> 10.0.0.2
>
> [database]
> 10.1.0.1
> 10.1.0.2
>
> __
>
> - name: Set DNS on hosts
>   vmware_module:
> hostname: '{{ management group }}'
> dns: 1.2.3.4
>
>
>
> Thanks for taking the time.
>
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2c702252-eae3-461e-842f-989e80d88537%40googlegroups.com
> 
> .
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKEXu85Ga7EadHRB%3DyP8hCQqy7S%2BTqCKmkCp%2BTj5CV10LpL5Ew%40mail.gmail.com.