Right, if you need more complex logic, then you write a module in a normal programming language. The YAML is intended to keep the intention and orchestration logic simple and readable.
- apt: name=apache2 state=present
Then, on day 2, you realize that Apache isn't hip, so you switch to nginx instead: - apt: name=apache2 state=absent
- apt: name=nginx state=present
It works, but you're stuck with entries in your playbook that are there for purely historical reasons.I think that Ansible is still a transitional glue tech though, and projects like flynn.io may move things forward by making the CM part of the infrastructure a developer task vs. a devops one.
Ansible is 100% intended for configuration management. Configuration is by its very nature declarative, so in any case if you were doing a lot of custom procedural code for configuration you're probably doing something a bit wrong.