DevOps / Ansible Interview questions
When should you use blocks with rescue in Ansible?
A block groups related tasks together, and pairing it with rescue gives Ansible try/catch-like error handling: if any task inside the block fails, execution jumps to the rescue section instead of immediately failing the whole host.
- block: - name: Deploy new application version ansible.builtin.command: /opt/deploy.sh rescue: - name: Roll back to previous version ansible.builtin.command: /opt/rollback.sh always: - name: Notify deployment status ansible.builtin.debug: msg: "Deployment attempt finished"
Use this pattern whenever a sequence of steps needs a defined fallback if something partway through fails, such as rolling back a deployment, cleaning up a partially-created resource, or sending an alert before giving up on that host. The optional always section runs regardless of whether the block succeeded or the rescue was triggered, making it a natural place for cleanup or notification logic that must happen either way.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
