How do i do IOS upgrade of devices sequentially and not simultaneously?

I have written a script to do IOS upgrade of cisco devices. However problem is that each TASK in playbook gets executed SIMULTANEOUSLY on all devices defined in inventory file before moving on to next TASK.

But my requirement is:

  1. I want to complete IOS upgrade of 1 device first and only after that, move on to 2nd device

  2. If IOS upgrade of 1st device fails for some reason, then IOS upgrade activity should not proceed any further.

1 solution i can think for 1st point is to write multiple plays within a single playbook and then define 1 host in 1 play but that would be m ake the playbook extremely long (if i decide to upgrade 20 devices for example).

Please suggest what other script needs to be added to achive both the objectives?

Thanks,

Vikram

https://docs.ansible.com/ansible/latest/user_guide/playbooks_strategies.html#setting-the-batch-size-with-serial

Hi,

Thanks once again for your kind assistance. Your suggestion helped with 1st of my concern. For my 2nd of my concern, i learnt that below command helps:
any_errors_fatal: true