[ansible-project] Is there a better way to restructure playbook without “include_tasks” and run task simultaneously?

2019-09-11 Thread Larry Bakun
 

I need a way to speed up my playbook, maybe better logical structuring. 
It’s running sequentially now. The task is simple – run playbook from AWX 
that will backup list of VMs.

I’m supplying list of VMs in AWX extra variables:


backupList:
  - vmName: VM1
backupAge: 2d
  - vmName: VM2
backupAge: 5d
  - vmName: VM3
backupAge: 1d
backupDirectory:/vmfs/volumes/NFS_BACKUPS


The first playbook is simple:

 
- name: Process VM backup here
  include_tasks: processBackup.yml
  vars:
vm_name: "{{ item.vmName }}"
backupAge: "{{ item.backupAge }}"
  with_items: "{{ backupList }}"
 


It reads extra variables and loops through calling second playbook using 
“include_tasks” where all functionality is written: cloning VM, copy to NFS 
server and making sure we keep the defined amount of copies. 

Basically the same set of tasks performed with different VM names and 
backup age. In this configuration, it is executed sequentially and takes a 
long time, especially the copy part to a backup server.

So, I'm wondering if there is a better way to restructure the code to run 
tasks simultaneously for each VM name?


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/baab3a3e-acdf-430c-8565-5e667603b2f6%40googlegroups.com.


[ansible-project] Ansible - use variable from another host

2018-02-22 Thread Larry Bakun
I have a playbook that executes a script on a Windows box that returns a 
value that I have to re-use later on in my playbook after switching to the 
localhost. How can I access this value after switching back to localhost. 
Here is an example:


hosts: localhost
connection: local
gather_facts: no
tasks:
.
.
.
hosts: windows
gather_facts: no
tasks:
- name: Call PowerShell script
win_command: "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe 
c:\\psl_scripts\\getData.ps1"
register: value_to_reuse

hosts: localhost
gather_facts: no
connection: local
tasks:
- name: debug store_name from windows host
 debug:
 var: "{{ hostvars[windows][value_to_reuse][stdout_lines] }}"




What is the correct syntax accessing a variable from another host? I'm 
receiving error message: *"msg": "The task includes an option with an 
undefined variable. The error was: 'windows' is undefined*

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/97fe8978-e84b-404b-85bb-c1dd41635cb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible Copy module error - "Exec format error"

2018-01-17 Thread Larry Bakun
Can you please share your solution? I'm facing the same issue.

On Thursday, June 22, 2017 at 3:11:13 PM UTC-4, Anfield wrote:
>
> Ok. Thanks. Once I update the stuff.fact file then the playbook runs fine.
>
>
>>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/95619a1c-eb52-444b-b572-7053e86a7848%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Error when running included playbook

2017-12-04 Thread Larry Bakun
Hi everyone,
I'm receiving this weird error when running the second playbook (with 
include module and passing IP address).
Here is my first playbook:

---
- name: get VM list from ESXi
  hosts: all

  tasks:
  - name: get facts
vmware_vm_facts:
  hostname: "{{ inventory_hostname }}"
  username: "{{ ansible_ssh_user }}"
  password: "{{ ansible_ssh_pass }}"
delegate_to: localhost
register: esx_facts

  - name: < {

"msg": "Received IP: 192.168.1.59"

}


TASK [< ESTABLISH LOCAL CONNECTION FOR USER: root

 EXEC /bin/sh -c 'echo ~ && sleep 0'

 EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886 `" && echo 
ansible-tmp-1512415750.71-126408181937886="` echo 
/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886 `" ) && sleep 
0'

 PUT /tmp/tmp8miEQJ TO 
/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/vmware_vm_facts.py

 EXEC /bin/sh -c 'chmod u+x 
/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/ 
/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/vmware_vm_facts.py 
&& sleep 0'

 EXEC /bin/sh -c '/usr/bin/python2 
/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/vmware_vm_facts.py;
 
rm -rf "/root/.ansible/tmp/ansible-tmp-1512415750.71-126408181937886/" > 
/dev/null 2>&1 && sleep 0'

fatal: [192.168.1.55 -> localhost]: FAILED! => {

"changed": false, 

"failed": true, 

"invocation": {

"module_args": {

"hostname": "192.168.1.59", 

"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 

"username": "root", 

"validate_certs": false

}

}, 

"msg": "[Errno 111] Connection refused"

}


 Anybody has any idea?

Thanks,
Larry


-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fe3308a3-b374-4dc1-ae0c-ddd7d1ab9a8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.