i've got playbook run on hosts on as-needed basis. i'm running problem , haven't been able find answer myself.
we have hosts running application we're building, , there few servers updates not done automatically. goal these updates when needed via ansible. problem this: if during update process host rebooted, there additional steps need taken. however, if host did not reboot, these steps need omitted.
here's yml file looks like:
--- - name: run updates on demand hosts: static-hosts roles: - update_system - update_component1 - update_component2
here need kind of check. if steps above caused host reboot, following. if did not reboot, stop here.
- rebuild_component1 - rebuild_component2
any suggestions? may going wrong, if that's case i'd appreciate if pointed in right direction. thanks!
thought of possible solution, not yet tested. since it's ansible reboot (which wasn't listed in original yml file), 1 way might doable following yml:
--- - name: run updates on demand hosts: static-hosts roles: - update_system - update_component1 - update_component2 register: updated - name: reboot shell: shutdown -r when: updated.changed - name: wait ssh (usual "wait ssh block") - name: rebuild if rebooted roles: - rebuild_component1 - rebuild_component2 when: updated.changed
what i'm not sure if updated.changed triggers reboot (and therefore rebuild) if updates require it.
my "possible solution" listed above works.
Comments
Post a Comment