we have running 100 Machines in aws with tag Name=ad_server so how can i run release code only 50% machines. Example:
- hosts: tag_Name_ad_server
sudo: yes
remote_user: ubuntu
tasks:
- name: whatever
so how can i do this..
we have running 100 Machines in aws with tag Name=ad_server so how can i run release code only 50% machines. Example:
- hosts: tag_Name_ad_server
sudo: yes
remote_user: ubuntu
tasks:
- name: whatever
so how can i do this..
Option 1: serial + pause
This will use standard feature of batches for rolling updates and require some user interaction.
We add
pause
with prompt as a first task to wait for ENTER to be pressed at the start of every batch.So press ENTER on the first 50%-batch and then abort execution when asked to start the second half.
With every playbook run
serial
will always choose the same servers from inventory. In this case first 50% from the list.Option 2: form a new dynamic group
Loop through hosts in tag_Name_ad_server group and form a new 50_percent group.
Then execute your actual tasks within this new group.
No user interaction required.
With ever playbook run
random
will choose 50% random servers from the list.Option 3: dirty trick with max_fail_percentage
If you have only one task to run, you can use
max_fail_percentage: -1
to stop execution after first task of first batch.This will make a 50%-batches, execute first task on every host of this batch and check failed servers count, as it always will be above -1 playbook will stop execution.