[ansible-project] Run playbook against multiple hosts with different variables

2022-03-02 Thread Nitrous
So, we build alot of servers with different specs, and our YAML file 
variables for the build specs differ (like different CPU/RAM/HDD etc) , but 
the playbooks remain the same.

Currently, to run multiple builds concurrently, I have to open new ssh 
session to the Ansible server everytime and run the builds for each server 
using:

So first ssh session will run the build for the firsr server like this: 
ansible-playbook playbooks/newonpremserver.yml -e "hostname=server01" -

Second ssh session will run the build for the second server like this: 
ansible-playbook playbooks/newonpremserver.yml -e "hostname=server02" -

and so on..

Please suggest a better way to run builds concurrently.

-- 
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/84a37dfc-d21b-496b-b4da-511733921083n%40googlegroups.com.


Re: [ansible-project] Run playbook against multiple hosts

2022-03-02 Thread Nitrous
I got it work, by following this simple example on git hub:

https://github.com/ryanschulze/ansible_examples/tree/master/simple

Thanks everyone.

On Tuesday, March 1, 2022 at 12:26:28 PM UTC-6 Nitrous wrote:

> Does my  win_us_bgrsuistg.yaml  file have to be in a specific format, 
> maybe its missing some information, that I am overlooking.
>
> On Tuesday, March 1, 2022 at 12:14:26 PM UTC-6 Nitrous wrote:
>
>> This is what I got when I ran:
>>
>> TASK [Include vars of server.yaml file] 
>> 
>> task path: /etc/ansible/roles/secwinupdates/tasks/main.yml:12
>> fatal: [server1]: FAILED! => {
>> "ansible_facts": {
>> "server": {}
>> },
>> "ansible_included_var_files": [],
>> "changed": false,
>> "message": "Could not find or access 
>> '/etc/ansible/servers/win_us_bgrsuistg.yaml' on the Ansible Controller.\nIf 
>> you are using a module and expect the file to exist on the remote, see the 
>> remote_src option"
>> }
>> fatal: [server2]: FAILED! => {
>> "ansible_facts": {
>> "server": {}
>> },
>> "ansible_included_var_files": [],
>> "changed": false,
>> "message": "Could not find or access 
>> '/etc/ansible/servers/win_us_bgrsuistg.yaml' on the Ansible Controller.\nIf 
>> you are using a module and expect the file to exist on the remote, see the 
>> remote_src option"
>> }
>> fatal: [server3]: FAILED! => {
>> "ansible_facts": {
>> "server": {}
>> },
>> "ansible_included_var_files": [],
>> "changed": false,
>> "message": "Could not find or access 
>> '/etc/ansible/servers/win_us_bgrsuistg.yaml' on the Ansible Controller.\nIf 
>> you are using a module and expect the file to exist on the remote, see the 
>> remote_src option"
>> }
>>
>> This is what my host file looks like:
>>
>> [win_us_bgrsuistg]
>> server1 ansible_host=x.x.x.x
>> server2 ansible_host=x.x.x.x
>> server3 ansible_host=x.x.x.x
>>
>> I tried to create a seperate yaml file for the servers, called 
>> win_us_bgrsuistg 
>> , which includes the server1, server2, server 3 names in it, I then got the 
>> below error:
>>
>> fatal: [server1]: FAILED! => {
>> "ansible_facts": {
>> "server": {}
>> },
>> "ansible_included_var_files": [],
>> "changed": false,
>> "message": "/etc/ansible/servers/win_us_bgrsuistg.yaml must be stored 
>> as a dictionary/hash"
>> On Tuesday, March 1, 2022 at 10:22:18 AM UTC-6 mikee...@gmail.com wrote:
>>
>>> I must have missed something… why wouldn’t -i $FILE not work? 
>>>
>>> > On Mar 1, 2022, at 10:14, Stefan Hornburg (Racke)  
>>> wrote: 
>>> > 
>>> > On 01/03/2022 16:51, Nitrous wrote: 
>>> >> I have defined my hosts in the variable file: 
>>> >> [servers] 
>>> >> server1 ansible_host=ip address of server 1 
>>> >> server2 ansible_host=ip address of server 2 
>>> >> etc 
>>> >> I have a playbook that looks like this: 
>>> >> - hosts: '{{ hostname }}' 
>>> >> gather_facts: no 
>>> >> tasks: 
>>> >> - name: Include vars for vcenter 
>>> >> include_vars: 
>>> >> file: /etc/ansible/roles/createvm/vars/main.yml 
>>> >> name: vcenter 
>>> >> vars: 
>>> >> ansible_become_password: "{{ domain_password }}" 
>>> >> - name: Include vars of server.yaml file 
>>> >> include_vars: 
>>> >> file: /etc/ansible/servers/{{ hostname }}.yaml 
>>> >> name: server 
>>> >> - name: Wait For Connection to Continue 
>>> >> wait_for_connection: 
>>> >> connect_timeout: 30 
>>> >> - name: Reboot to check for second round of updates 
>>> >> ansible.windows.win_reboot: 
>>> >> msg: "Reboot to check for second round of updates" 
>>> >> - import_role: 
>>> >> name: windowsupdates 
>>> >> This playbook works fine if I run the command to specify 1 hostname: 
>>> >> ansible-playbook playbooks/file.yml -e "hostname=server1" -. 
>>> >> How can I run my file.yml against server1,server2 etc at the same 
>>> time? 
>>> > 
>>> > I suppose that -e "hostname=servers" should do the trick. 
>>> > 
>>> > Regards 
>>> > Racke 
>>> > 
>>> >> 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 ansible-proje...@googlegroups.com >> ansible-proje...@googlegroups.com>. 
>>> >> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com
>>>  
>>> <
>>> https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com?utm_medium=email_source=footer>.
>>>  
>>>
>>> > 
>>> > 
>>> > -- 
>>> > Automation expert - Ansible and friends 
>>> > Linux administrator & Debian maintainer 
>>> > Perl Dancer & conference hopper 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> 

Re: [ansible-project] Run playbook against multiple hosts

2022-03-01 Thread Nitrous
This is what I got when I ran:

TASK [Include vars of server.yaml file] 

task path: /etc/ansible/roles/secwinupdates/tasks/main.yml:12
fatal: [server1]: FAILED! => {
"ansible_facts": {
"server": {}
},
"ansible_included_var_files": [],
"changed": false,
"message": "Could not find or access 
'/etc/ansible/servers/win_us_bgrsuistg.yaml' on the Ansible Controller.\nIf 
you are using a module and expect the file to exist on the remote, see the 
remote_src option"
}
fatal: [server2]: FAILED! => {
"ansible_facts": {
"server": {}
},
"ansible_included_var_files": [],
"changed": false,
"message": "Could not find or access 
'/etc/ansible/servers/win_us_bgrsuistg.yaml' on the Ansible Controller.\nIf 
you are using a module and expect the file to exist on the remote, see the 
remote_src option"
}
fatal: [server3]: FAILED! => {
"ansible_facts": {
"server": {}
},
"ansible_included_var_files": [],
"changed": false,
"message": "Could not find or access 
'/etc/ansible/servers/win_us_bgrsuistg.yaml' on the Ansible Controller.\nIf 
you are using a module and expect the file to exist on the remote, see the 
remote_src option"
}

This is what my host file looks like:

[win_us_bgrsuistg]
server1 ansible_host=x.x.x.x
server2 ansible_host=x.x.x.x
server3 ansible_host=x.x.x.x

I tried to create a seperate yaml file for the servers, called win_us_bgrsuistg 
, which includes the server1, server2, server 3 names in it, I then got the 
below error:

fatal: [server1]: FAILED! => {
"ansible_facts": {
"server": {}
},
"ansible_included_var_files": [],
"changed": false,
"message": "/etc/ansible/servers/win_us_bgrsuistg.yaml must be stored 
as a dictionary/hash"
On Tuesday, March 1, 2022 at 10:22:18 AM UTC-6 mikee...@gmail.com wrote:

> I must have missed something… why wouldn’t -i $FILE not work?
>
> > On Mar 1, 2022, at 10:14, Stefan Hornburg (Racke)  
> wrote:
> > 
> > On 01/03/2022 16:51, Nitrous wrote:
> >> I have defined my hosts in the variable file:
> >> [servers]
> >> server1 ansible_host=ip address of server 1
> >> server2 ansible_host=ip address of server 2
> >> etc
> >> I have a playbook that looks like this:
> >> - hosts: '{{ hostname }}'
> >> gather_facts: no
> >> tasks:
> >> - name: Include vars for vcenter
> >> include_vars:
> >> file: /etc/ansible/roles/createvm/vars/main.yml
> >> name: vcenter
> >> vars:
> >> ansible_become_password: "{{ domain_password }}"
> >> - name: Include vars of server.yaml file
> >> include_vars:
> >> file: /etc/ansible/servers/{{ hostname }}.yaml
> >> name: server
> >> - name: Wait For Connection to Continue
> >> wait_for_connection:
> >> connect_timeout: 30
> >> - name: Reboot to check for second round of updates
> >> ansible.windows.win_reboot:
> >> msg: "Reboot to check for second round of updates"
> >> - import_role:
> >> name: windowsupdates
> >> This playbook works fine if I run the command to specify 1 hostname:
> >> ansible-playbook playbooks/file.yml -e "hostname=server1" -.
> >> How can I run my file.yml against server1,server2 etc at the same time?
> > 
> > I suppose that -e "hostname=servers" should do the trick.
> > 
> > Regards
> > Racke
> > 
> >> 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 ansible-proje...@googlegroups.com  ansible-proje...@googlegroups.com>.
> >> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com
>  
> <
> https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com?utm_medium=email_source=footer
> >.
> > 
> > 
> > -- 
> > Automation expert - Ansible and friends
> > Linux administrator & Debian maintainer
> > Perl Dancer & conference hopper
> > 
> > -- 
> > 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-proje...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/a89fe0ef-bf32-9d0e-7a1d-f0f9111b8d54%40linuxia.de
> .
>
>

-- 
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/44127a4a-d9fa-4737-afe8-45ddf1af55f7n%40googlegroups.com.


Re: [ansible-project] Run playbook against multiple hosts

2022-03-01 Thread Mike Eggleston
I must have missed something… why wouldn’t -i $FILE not work?

> On Mar 1, 2022, at 10:14, Stefan Hornburg (Racke)  wrote:
> 
> On 01/03/2022 16:51, Nitrous wrote:
>> I have defined my hosts in the variable file:
>> [servers]
>> server1 ansible_host=ip address of server 1
>> server2 ansible_host=ip address of server 2
>> etc
>> I have a playbook that looks like this:
>> - hosts: '{{ hostname }}'
>>   gather_facts: no
>>   tasks:
>>   - name: Include vars for vcenter
>> include_vars:
>> file: /etc/ansible/roles/createvm/vars/main.yml
>> name: vcenter
>> vars:
>>   ansible_become_password: "{{ domain_password }}"
>>   - name: Include vars of server.yaml file
>> include_vars:
>> file: /etc/ansible/servers/{{ hostname }}.yaml
>> name: server
>>   - name: Wait For Connection to Continue
>> wait_for_connection:
>>   connect_timeout: 30
>>   - name: Reboot to check for second round of updates
>> ansible.windows.win_reboot:
>>   msg: "Reboot to check for second round of updates"
>>   - import_role:
>>   name: windowsupdates
>> This playbook works fine if I run the command to specify 1 hostname:
>> ansible-playbook playbooks/file.yml -e "hostname=server1" -.
>> How can I run my file.yml against server1,server2 etc at the same time?
> 
> I suppose that -e "hostname=servers" should do the trick.
> 
> Regards
> Racke
> 
>> 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 ansible-project+unsubscr...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com
>>  
>> .
> 
> 
> -- 
> Automation expert - Ansible and friends
> Linux administrator & Debian maintainer
> Perl Dancer & conference hopper
> 
> -- 
> 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/a89fe0ef-bf32-9d0e-7a1d-f0f9111b8d54%40linuxia.de.

-- 
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/64AE13A5-41F8-49A8-8ACD-5723610A7EBE%40gmail.com.


Re: [ansible-project] Run playbook against multiple hosts

2022-03-01 Thread Stefan Hornburg (Racke)

On 01/03/2022 16:51, Nitrous wrote:

I have defined my hosts in the variable file:

[servers]

server1 ansible_host=ip address of server 1

server2 ansible_host=ip address of server 2

etc

I have a playbook that looks like this:

- hosts: '{{ hostname }}'
   gather_facts: no
   tasks:
   - name: Include vars for vcenter
     include_vars:
         file: /etc/ansible/roles/createvm/vars/main.yml
         name: vcenter
     vars:
       ansible_become_password: "{{ domain_password }}"

   - name: Include vars of server.yaml file
     include_vars:
         file: /etc/ansible/servers/{{ hostname }}.yaml
         name: server

   - name: Wait For Connection to Continue
     wait_for_connection:
       connect_timeout: 30

   - name: Reboot to check for second round of updates
     ansible.windows.win_reboot:
       msg: "Reboot to check for second round of updates"

   - import_role:
       name: windowsupdates

This playbook works fine if I run the command to specify 1 hostname:


ansible-playbook playbooks/file.yml -e "hostname=server1" -.

How can I run my file.yml against server1,server2 etc at the same time?


I suppose that -e "hostname=servers" should do the trick.

Regards
 Racke



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 
ansible-project+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com
 
.



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/a89fe0ef-bf32-9d0e-7a1d-f0f9111b8d54%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


[ansible-project] Run playbook against multiple hosts

2022-03-01 Thread Nitrous


I have defined my hosts in the variable file:

[servers]

server1 ansible_host=ip address of server 1

server2 ansible_host=ip address of server 2

etc

I have a playbook that looks like this:
- hosts: '{{ hostname }}'
  gather_facts: no
  tasks:
  - name: Include vars for vcenter
include_vars:
file: /etc/ansible/roles/createvm/vars/main.yml
name: vcenter
vars:
  ansible_become_password: "{{ domain_password }}"

  - name: Include vars of server.yaml file
include_vars:
file: /etc/ansible/servers/{{ hostname }}.yaml
name: server

  - name: Wait For Connection to Continue
wait_for_connection:
  connect_timeout: 30

  - name: Reboot to check for second round of updates
ansible.windows.win_reboot: 
  msg: "Reboot to check for second round of updates"   

  - import_role:
  name: windowsupdates

This playbook works fine if I run the command to specify 1 hostname:


ansible-playbook playbooks/file.yml -e "hostname=server1" -.

How can I run my file.yml against server1,server2 etc at the same time?

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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/adaee4d9-0c58-4d00-a355-eeb4fe8bdba2n%40googlegroups.com.