title: Ansible : how to create a function like
body: <p>I have a repeated pattern like this one::</p>
  
  <pre><code>- name: =code_01= clone repository
    git: repo=gitolite@git.site.net:/code_01
         dest=/tmp/code_01
         update=yes
         force=yes
         accept_hostkey=yes
         version=master
    sudo: true
    sudo_user: "{{ user }}"
  
  - name: =code_01= egg build
    shell: . {{ home }}/{{ venv_name }}/bin/activate &amp;&amp; make egg
    args:
      chdir: "/tmp/code_01"
    sudo_user: "{{ user }}"
    sudo: true
  
  - name: =code_01= egg get
    command: find /tmp/code_01/dist -type f -iname '*.egg'
    register: code_01eggs
  
  - name: =code_01= egg install in {{ venv_name }} venv
    shell: . {{ home }}/{{ venv_name }}/bin/activate &amp;&amp; easy_install {{ item }}
    args:
      chdir: "{{ home }}"
    with_items: "{{ code_01eggs.stdout_lines }}"
    sudo_user: "{{ user }}"
    sudo: true
  
  - name: =code_01= cleanup
    file: path=/tmp/code_01 state=absent
    sudo: true
  </code></pre>
  
  <p>And I have this to do with:  <strong>code_02</strong>,  <strong>code_03</strong>,  <strong>code_04</strong>, ..., <strong>code_0n</strong></p>
  
  <p>How can I "factorize" this ?</p>