Functional programming design patterns in Ansible code
#
Abstract
Ansible yaml code is easy to write but hard to understand and reason about, hard to maintain, debug and test.
All of this until you take a functional programming perspective look at an Ansible code. Concepts from functional programming like pure functions, effects, composition, lazy evaluations and others are very much applicable and very useful in Ansible.Allow me to show you how concepts from functional programming can help you simplify Ansible content development, make your Ansible content bullet proof tested, easy to maintain, understand and reuse.
This talk does not require any prior knowledge of functional programming. It is designed to be useful to both beginners and experienced Ansible content developers.
Ansible’s YAML syntax makes writing automation straightforward — but as projects grow, maintaining large playbooks and roles becomes a real challenge. In this session, Kirill Satarin proposed a powerful solution: borrowing functional programming (FP) principles to improve Ansible code quality. Attendees learned how adopting functional patterns like pure functions, clear separation of effects, immutability, composition, and lazy evaluation can make Ansible automation far easier to test, debug, understand, and extend. These ideas were made accessible even to those without prior FP experience, with real-world Ansible examples illustrating each principle. What is covered in the talk: Why complex Ansible codebases become difficult to manage Introduction to functional programming concepts relevant to Ansible Practical techniques to apply FP principles in roles, playbooks, and modules Strategies for improving testability, modularity, and maintenance How beginners and experienced developers alike can benefit from FP patterns By adopting a functional mindset, attendees were shown a clear path to more reliable and resilient automation content.
#
Slide Deck
Functional programming design patterns in ansible code
#
Code samples
Code examples for the talk given by Kirill Satarin at CfgMgmtCamp 2025
https://github.com/kksat/functional-ansible
#
Video
Will be provided as soon as it is available.