How do you patch a fleet and reboot only when needed?
IntermediateProductionRolling Updates, Delegation and Safe Deployments
Answer
- hosts: all
serial: "10%"
become: true
tasks:
- ansible.builtin.apt:
upgrade: dist
update_cache: true
- ansible.builtin.stat: { path: /var/run/reboot-required }
register: reboot_flag
- ansible.builtin.reboot:
reboot_timeout: 900
when: reboot_flag.stat.exists
On RHEL family check needs-restarting -r (return code 1 means reboot required). Patch in rings (dev, stage, canary, then the rest), keep redundancy with serial, take nodes out of the load balancer first, and schedule within a change window.
More on Rolling Updates, Delegation and Safe Deployments
How do you do a rolling update with Ansible?BeginnerWhat forms can `serial` take?IntermediateShow the standard pattern for a zero-downtime rolling deploy behind a load balancer.IntermediateWhy do you add a health check inside the deployment play?BeginnerHow do `any_errors_fatal` and `max_fail_percentage` help a rollout?BeginnerHow do you do a canary deployment?Intermediate