Ansible has a concept of chaining modules – e.g., template both templates and then uploads. I’m working on an ldap module that, naturally, takes and ldif file as an argument.
Present usage is like so:
- name: create temp dir
action: file path=/tmp/ansible-ldap/ state=directory - name: template & upload sample.ldif
action: template src=files/sample.ldif.j2 dest=/tmp/ansible-ldap/sample.ldif - name: apply ldif
action: ldap action=modify ldif=/tmp/ansible-ldap/sample.ldif - name: delete temp file
action: file path=/tmp/ansible-ldap/sample.ldif state=absent - name: delete temp dir
action: file path=/tmp/asnbile-ldap/ state=absent
… which is pretty verbose …
What would be nice, I think, would be this:
- name: apply ldif
action: ldap action=modify ldif=files/sample.ldif.j2
I’m pretty sure it would be hard to do this with the current code base, but wonder if there’s any planned refactoring that would make this – or something similar – a little more feasible.
On a more practical note, I think it could be reduced to two tasks if ansible provided a var pointing to the current tmp dir which it would automatically clean up. E.g.:
- name: template & upload sample.ldif
action: template src=files/sample.ldif.j2 dest=${ansible_tmp_dir}/sample.ldif - name: apply ldif
action: ldap action=modify ldif=/tmp/ansible-ldap/sample.ldif
… and ansible would take care of the rest.
I’m fishing for ideas… or for the whole idea to be shot down ;-).