[ansible-project] Re: remove previously used remote_user (possibly ControlMaster, ControlPersist problem)

2018-02-09 Thread 'Davide' via Ansible Project
I found a related post [1] where it is suggested to just kill all processes
before deleting the user [2].

[1]: 
https://groups.google.com/d/msg/ansible-project/woy_asjA5No/c2I86Gq7AwAJ
[2]: 
https://groups.google.com/d/msg/ansible-project/woy_asjA5No/oLxrV6UZCAAJ

-- 
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/d1c514a3-4176-4eb6-b4a4-f261afbc006c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Deleting a user; still being used

2018-02-09 Thread 'Davide' via Ansible Project
So I am not the only one that has this problem on the raspberry pi ;) [1].

I am still confused on why I have this problem only on the raspberry pi but
killing the process works great. Thanks!
I still would prefer to set ControlMaster=no just for the one playbook that
uses the default user. But unfortunately there is no ssh_args playbook 
attribute. 

Regards
Davide

[1]: https://groups.google.com/forum/#!topic/ansible-project/pMMINWCyALE


On Monday, 1 February 2016 14:19:13 UTC+1, Bruno Vernay wrote:
>
> I add this problem, I did this:
>
> - name: Remove old "pi" account
>   hosts: qemu
>   become: yes
>   become_method: sudo
>   gather_facts: false
>   tasks:
> - name  : Kill all "pi" user's processes and remove the account
>   shell : "killall -KILL -u pi ; userdel -fr pi"
>
> #  Didn't work, "...cannot open /etc/subuid"
> #- name: Remove pi account
> #  user: name=pi state=absent force=yes remove=yes
>
> not very clean, but works
>
> Bruno
>
>
> On Friday, November 27, 2015 at 5:06:30 PM UTC+1, Andrew Langhorn wrote:
>>
>> Hello,
>>
>> I am instantiating an EC2 instance from a community AMI in the 
>> Marketplace. The AMI comes pre-baked with a default user (ec2-user).
>>
>> I have a role in my Ansible repository which is applied to all machines, 
>> called common. Inside this role, I have a few tasks which create a new user 
>> (`ansible`), configure an SSH key for it, and sort out an entry in 
>> /etc/sudoers. These tasks are tagged as 'firstrun'.
>>
>> The first time I run Ansible, I connect with the ec2-user account 
>> remotely using:
>>
>> ansible-playbook -i hosts site.yml --tags firstrun
>>
>> This means that I only run those tasks tagged as firstrun, which makes 
>> the initial run quick. After this has completed successfully, I run:
>>
>> ansible-playbook -u ansible -i hosts site.yml --skip-tags firstrun
>>
>> This time, I'm skipping the tasks I've already run, and am also running 
>> Ansible as the `ansible` user on the instance. This adds a load of other 
>> plays to the machine, which works fine.
>>
>> I have a slight problem, however. When I invoke `ansible-playbook` for 
>> the second time, I expect it to run a task using the user module to delete 
>> the ec2-user account:
>>
>>
>> name: remove ec2-user
>>
>> become: yes
>>
>> become_user: root
>>
>> user: name=ec2-user state=absent remove=yes force=yes
>>
>>
>>  Instead of this working correctly, I get this message:
>>
>> msg: userdel: user ec2-user is currently used by process 1918
>> userdel: cannot open /etc/subuid
>>
>> I don't see why (maybe I'm snowblind from having looked at this a bit too 
>> long!) the ec2-user still being used, given that by the time Ansible gets 
>> to this task, the connection for the first run should have timed out, or 
>> the socket should have closed.
>>
>> Does anyone have any ideas? It may just be that I can't see the wood from 
>> the trees!
>>
>> Thanks,
>>
>> Andrew
>>
>>

-- 
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/3cd318b2-93db-46d3-8871-797a63ef704a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Cygwin breaking ansible

2018-02-09 Thread lpescatore via Ansible Project
Bump, again.

On Tuesday, January 30, 2018 at 1:59:24 PM UTC-8, lpesc...@google.com wrote:
>
> Hi folks, I have a WEIRD problem. 
> After running cygwin ssh-host-config on my PC, which starts sshd and rsync 
> services, suddenly I can no longer run ansible. 
> I get this error:
>
> root@Raspi_Ctrl:/ansible/playbook/nuc# ansible -i /ansible/hosts nuc -m 
> win_ping
>
> * [WARNING]: FATAL ERROR DURING FILE TRANSFER: Traceback (most recent call 
> last):   File*
>
> *"/usr/local/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py",
>  
> line 276, in _winrm_exec*
>
> *self._winrm_send_input(self.protocol, self.shell_id, command_id, data, 
> eof=is_last)   File*
>
> *"/usr/local/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py",
>  
> line 256, in _winrm_send_input*
>
> *protocol.send_message(xmltodict.unparse(rq))   File 
> "/usr/local/lib/python2.7/dist-*
>
> *packages/winrm/protocol.py", line 207, in send_message return 
> self.transport.send_message(message)   File*
>
> *"/usr/local/lib/python2.7/dist-packages/winrm/transport.py", line 202, in 
> send_message raise*
>
> *WinRMTransportError('http', error_message) WinRMTransportError: (u'http', 
> u'Bad HTTP response returned from*
>
> *server. Code 500')*
>
>
> 100.126.255.201 | FAILED! => {
>
> "msg": "winrm send_input failed"
>
> }
>
> root@Raspi_Ctrl:/ansible/playbook/nuc# ansible -i /ansible/hosts nuc -m 
> win_ping
>
> *100.126.255.201 | UNREACHABLE! => {*
>
> *"changed": false, *
>
> *"msg": "basic: HTTPSConnectionPool(host='100.126.255.201', 
> port=5986): Max retries exceeded with url: /wsman (Caused by 
> ConnectTimeoutError( 0x749335b0>, 'Connection to 100.126.255.201 timed out. (connect 
> timeout=30)'))", *
>
> *"unreachable": true*
>
> *}*
>
>
>
>
> *When I run system restore to before this ssd-host-config, I can reach it 
> again. *
>
> *rsync uses port 873, sshd uses 22, and I believe ansible uses 5986 so 
> there should be no conflict. *
>
>
> *Has anyone else had this issue?*
>
>
> *By the way, this is the script that does the config. I do have this set 
> to become: so i dont think it's a privelege thing.*
>
>
> #!/bin/bash
>
>
> #::Configure sshd service
>
> if ! ssh-host-config --yes --pwd "foo"; then
>
> echo "ERROR: Failed to configure sshd"
>
> exit 1
>
> fi
>
> #echo db_home: /cygdrive/c/home/YRunner > C:\cygwin\etc\nsswitch.conf || 
> exit /b 1
>
>
> if ! net start sshd; then
>
> echo "ERROR: Failed to start sshd service."
>
> exit 1
>
> fi
>
>
> #configure the rsyncd service
>
> cat < /etc/rsyncd.conf
>
> use chroot = yes
>
>
> [yrunner_rsyncer]
>
> #path = /cygdrive/c/home/YRunner
>
> comment = YRunner Rsyncer
>
> auth users = YRunner
>
> secrets file = /etc/rsyncd.secrets
>
> write only = false
>
> read only = false
>
> list = true
>
> strict modes = false
>
> hosts allow = *
>
> EOF
>
>
>
> /usr/bin/cygrunsrv.exe --install "rsyncd" --path /usr/bin/rsync --args 
> "--daemon --no-detach" -f "Rsync daemon service"
>
> if [[ "$?" -ne 0 ]]; then
>
> echo "ERROR: Failed to install rsyncd service"
>
> exit 1
>
> fi
>
>
> net start rsyncd
>

-- 
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/8ceec9cf-3c7a-43ea-9dc7-7ea0dc58dba3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: unable to run ping command from Ansible server to Application server

2018-02-09 Thread Lokanath Veluru
Hi Suresh,

 Are you able to login SSH manually (ssh 10.XXX.XXX.XX)?

--> Request you to regenerate the keys and make copy on both servers. It 
should work
#

On Friday, February 9, 2018 at 9:17:32 PM UTC+5:30, sureshma...@gmail.com 
wrote:
>
> hello 
>
>
> I have configured password less login from my ansible server to 
> application server but my application  server is having prompt like below 
>
> This user account allows you to configure the appliance
> What would you like to do?
>  1) Configure system settings
>  2) Display Gateway configuration menu
>  3) Use a privileged shell (root)
>  R) Reboot the SSG appliance (apply the new configuration)
>  X) Exit (no reboot)
>
> when I run ansible all -m ping from my ansible server to Application 
> server , I am getting below failure 
>
> # ansible gateway -m ping
> apsrt1234.com 
> 
>  | 
> UNREACHABLE! => {
> "changed": false,
> "msg": "Failed to connect to the host via ssh:  Gateway 
> v8.4.01\nPermission denied 
> (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
> "unreachable": true
> }
>
> could you let me know how to avoid the application server prompt or any 
> other solution ?
> Show trimmed content 
>

-- 
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/69dc1c2e-fcea-4867-8817-77a1f6f4d8f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to configure playbook serial value by group var from inventory file?

2018-02-09 Thread Bing Hsueh
Thanks for the explaination.
Now I know the reason why I cannot set the value from inventory file.

And also thanks for branko to point out the inconsistence of variable 
names, I didn't notice that. :p

Brian Coca於 2018年2月9日星期五 UTC+8下午11時08分27秒寫道:
>
> This is because serial is a play level keyword and must be the same 
> for ALL hosts in play, so inventory data cannot be used to set it. 
>
>
> You cannot set 'batches' of hosts for all play if the batch size keeps 
> changing per host. 
>
>
>
>
> -- 
> -- 
> Brian Coca 
>

-- 
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/8f7a5c47-b1d9-471f-968a-487f4af1d27e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] unable to run ping command from Ansible server to Application server

2018-02-09 Thread sureshmadapathii
hello 


I have configured password less login from my ansible server to application 
server but my application  server is having prompt like below 

This user account allows you to configure the appliance
What would you like to do?
 1) Configure system settings
 2) Display Gateway configuration menu
 3) Use a privileged shell (root)
 R) Reboot the SSG appliance (apply the new configuration)
 X) Exit (no reboot)

when I run ansible all -m ping from my ansible server to Application server 
, I am getting below failure 

# ansible gateway -m ping
apsrt1234.com 

 | 
UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh:  Gateway 
v8.4.01\nPermission denied 
(publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
"unreachable": true
}

could you let me know how to avoid the application server prompt or any 
other solution ?
Show trimmed content 

-- 
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/2993025a-11fd-4607-afa1-541af9b583a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Layer7 Prompt is not allowing to ping the application server

2018-02-09 Thread sureshmadapathii


On Friday, February 9, 2018 at 9:13:33 PM UTC+5:30, sureshma...@gmail.com 
wrote:
>
> hello 
>
>
> I have configured password less login from my ansible server to 
> application server but my application  server is having prompt like below 
>
> This user account allows you to configure the appliance
> What would you like to do?
>  1) Configure system settings
>  2) Display Gateway configuration menu
>  3) Use a privileged shell (root)
>  R) Reboot the SSG appliance (apply the new configuration)
>  X) Exit (no reboot)
>
> when I run ansible all -m ping from my ansible server to Application 
> server , I am getting below failure 
>
> # ansible gateway -m ping
> apsrt1234.uhc.com  | UNREACHABLE! => {
> "changed": false,
> "msg": "Failed to connect to the host via ssh: Gateway 
> v8.4.01\nPermission denied 
> (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
> "unreachable": true
> }
>
> could you let me know how to avoid the application server prompt or any 
> other solution ?
>

-- 
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/a52fcb3d-c745-4547-bc6e-ae3746f1edb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Layer7 Prompt is not allowing to ping the application server

2018-02-09 Thread sureshmadapathii
hello 


I have configured password less login from my ansible server to application 
server but my application  server is having prompt like below 

This user account allows you to configure the appliance
What would you like to do?
 1) Configure system settings
 2) Display Gateway configuration menu
 3) Use a privileged shell (root)
 R) Reboot the SSG appliance (apply the new configuration)
 X) Exit (no reboot)

when I run ansible all -m ping from my ansible server to Application server 
, I am getting below failure 

# ansible gateway -m ping
apsrt2535.uhc.com | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Layer 7 Gateway 
v8.4.01\nPermission denied 
(publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
"unreachable": true
}

could you let me know how to avoid the application server prompt or any 
other solution ?

-- 
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/1d53f330-63c3-422a-9f85-7535b761065d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to configure playbook serial value by group var from inventory file?

2018-02-09 Thread Brian Coca
This is because serial is a play level keyword and must be the same
for ALL hosts in play, so inventory data cannot be used to set it.


You cannot set 'batches' of hosts for all play if the batch size keeps
changing per host.




-- 
--
Brian Coca

-- 
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/CACVha7ef3JhEDjHhaFqToFFHFxNcrFfZ%2BkwggKteYtaPgPfdDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible: Failed to connect to the host via ssh

2018-02-09 Thread Lokanath Veluru
Hi Ansible Team:

  This is application requirement to do package installation and 
configuration tunning on multiple servers and i have done with my 
requirement on all servers except one server(10.XXX.XXX.XX).

10.XXX.XXX.XX: In this server, we are able to do SSH but while we are 
executing with ansible script to do package installation on server i'm 
getting below error:

###
PLAY [10.XXX.XXX.XX] 
***

TASK [Gathering Facts] 
*
fatal: [10.XXX.XXX.XX]: UNREACHABLE! => {"changed": false, "msg": "Failed 
to connect to the host via ssh: Shared connection to 10.XXX.XXX.XX 
closed.\r\n", "unreachable": true}
to retry, use: --limit @/etc/ansible/Hadoop/NFS-Mount.retry

PLAY RECAP 
*
10.XXX.XXX.XX  : ok=0changed=0unreachable=1failed=0

###

==> Please hep us to getting issue resolved. Thank you

Regards,
Lokanath.




-- 
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/639efbcc-3c02-4c41-8cfe-46171e4f3297%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible reporting wrong service status

2018-02-09 Thread Sidh
Thanks for your suggestion.

Regards,
Sidh

On Thursday, February 8, 2018 at 5:49:52 PM UTC+1, Kai Stian Olstad wrote:
>
> On Thursday, 8 February 2018 16.26.07 CET Sidh wrote: 
> > Ansible - 2.4 
> > 
> > With below snippet, service failed to start at remote host but ansible 
> > reports that lighttpd service has been restarted and ok. 
> >   
> > 
> >  
> > - name: lighttpd config file 
> >   template: 
> > src: lighttpd.conf.j2 
> > dest: /etc/lighttpd/lighttpd.conf 
> > owner: root 
> > group: root 
> > mode: 0644 
> >   notify: Restart lighttpd 
> > 
> >  handlers: 
> > - name: Restart lighttpd 
> >   become: true 
> >   service: name=lighttpd state=restarted 
> > 
> >  
> > 
> > 
> > Note: It's happening with lighttpd only. 
> > 
> > RUNNING HANDLER [Restart lighttpd] 
> > 
> ***
>  
>
> > changed: [HOSTNAME] 
> > 
>
> The init system on the host is reporting OK(return code 0) so Ansible says 
> everything is OK. 
> If that's not correct then you need to fix the init file/configuration. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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/0a3509f2-1a10-4b60-b19a-aa992f9e1076%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to configure playbook serial value by group var from inventory file?

2018-02-09 Thread Branko Majic
On Fri, 9 Feb 2018 01:35:08 -0800 (PST)
Bing Hsueh  wrote:

> > ERROR! The field 'serial' has an invalid value, which includes an   
> >> undefined variable. The error was: 'batch_deploy' is undefined  

Ansible is complaining that you are referencing a variable
"batch_deploy", and that it is not defined anywhere.

> inventory.yml
> ---
> deployservers:
> vars:
>  deploy_batch: 1

Here, the variable is called "deploy_batch".

> playbook.yml
> ---
>   - name: test rolling update by batch size
> hosts: deployservers
> serial: "{{ batch_deploy }}"

Here, the variable is called "batch_deploy". E.g. not the same as in
the inventory file (swapped batch/deploy in the name).

Best regards

-- 
Branko Majic
XMPP: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
XMPP: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.

-- 
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/20180209134043.594aa837%40majic.rs.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Tower can't reach SCM source or remote host.

2018-02-09 Thread 'J Hawkesworth' via Ansible Project
WSL doesn't support every function available in the linux kernel 
unfortunately.  

There's a bug report open for signalfd here

https://github.com/Microsoft/WSL/issues/129


If I recall Tower wants a fair bit of RAM etc so you are probably better 
off spinning up a dedicated VM for it.

Hope this helps,

Jon

On Thursday, February 8, 2018 at 8:16:02 PM UTC, Pranav Baitule wrote:
>
> Hello,
>
> I have installed Ansible Tower on Ubuntu using Windows Subsystem for 
> Linux. 
>
> Starting an SCM update or running a playbook against a remote host gives 
> me the following error - 
>
>
> Can't create signalfd: Function not implemented
> Failed to make / slave: Invalid argument
>
> How can I fix this?
>

-- 
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/2a257d18-69c5-4a67-892b-139dd702ccb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to configure playbook serial value by group var from inventory file?

2018-02-09 Thread Bing Hsueh
I've tried to setup a group var "batch_deploy" in my inventory file and use 
it in playbook serial field.
But always got failed with following message.
Is there any concept I misunderstanding?

PLAYBOOK: playbook.yml 
>> *
>
> 1 plays in playbook.yml
>
> ERROR! The field 'serial' has an invalid value, which includes an 
>> undefined variable. The error was: 'batch_deploy' is undefined
>
>
>> The error appears to have been in '/vagrant/ansible/playbook.yml': line 
>> 2, column 5, but may
>
> be elsewhere in the file depending on the exact syntax problem.
>
>
>> The offending line appears to be:
>
>
>> ---
>
>   - name: test rolling update by batch size
>
> ^ here
>
>
>> exception type: 
>
> exception: 'batch_deploy' is undefined
>
>
inventory.yml
---
deployservers:
vars:
 deploy_batch: 1

hosts:
 app-server-1:
 app-server-2:
 app-server-3:
...


playbook.yml
---
  - name: test rolling update by batch size
hosts: deployservers
serial: "{{ batch_deploy }}"
roles:
- deploy
...



-- 
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/01189ed6-9975-4edd-b179-8c339e9a5214%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] In a loop everything executes at the same time?

2018-02-09 Thread Guillem Sola
Thanks Brian for helping me understand how with item task work under the 
hoods.

I was expecting "with_items" to work as different tasks, as per 
documentation "To save some typing, repeated tasks can be written in 
short-hand like so 

:" 

thus I was expecting it to be "transformed" to something like this

- name: Long task iteration 1
win_shell: (0..5) | foreach { (date).ToString("hh:mm:ss:");Start-Sleep 
-Seconds 1 }
when: "(( ansible_play_batch.index(inventory_hostname) % (( play_hosts | 
length ) / 2 )) | round) == 0"
- name: Long task iteration 2
win_shell: (0..5) | foreach { (date).ToString("hh:mm:ss:");Start-Sleep 
-Seconds 1 }
when: "(( ansible_play_batch.index(inventory_hostname) % (( play_hosts | 
length ) / 2 )) | round) == 1"
- name: Long task iteration 2
win_shell: (0..5) | foreach { (date).ToString("hh:mm:ss:");Start-Sleep 
-Seconds 1 }
when: "(( ansible_play_batch.index(inventory_hostname) % (( play_hosts | 
length ) / 2 )) | round) == 2"

which has my desired behaviour,

>From what you told me I understand that loops are executed as a single task 
for each host

---
Guillem

On Friday, February 9, 2018 at 2:47:12 AM UTC+1, Brian Coca wrote:
>
> No, in a loop everything executes sequentially, but EACH host executes 
> their own version of the task AND the loop in parallel. 
>
> debug will give you misleading results as it is a 'local' process and 
> probably finishes before other forks can start, once you intorduce the 
> delay of remote tranfer+execution you start seeing the real and 
> correct behaviour. 
>
> You might want to put the task in a play with 'serial' to handle the 
> 'global limit' correctly. 
>
>
> -- 
> -- 
> Brian Coca 
>

-- 
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/55cf6423-9879-4feb-b7fb-c2f133531536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.