ansibleturing-complete

Is Ansible Turing Complete?


Ansible offers many filters and conditionals. As far as I can tell; it should be possible to implement an Ansible playbook that executes a set of tasks that achieve the same outcome as a Turing Complete language. So, is it Turing Complete?


Solution

  • I think it is.

    1. Ansible can generate yaml files and run itself upon it (both may be done as local_action), which is a rough equivalent of eval() function.
    2. Ansible can create lists and iterate over them. Together with include_role it opens ability to run arbitrary complex code within loop (with conditions).
    3. Together with until keyword it allows to create classic while/until loop.
    4. block with where statement allows branching. Even within loops.

    Moreover, playbook-related plugins are counted as a valid way to extend playbook, therefore they provide full python features.