- hosts: localhost tasks: # Create folder for execution - name: Create dir file: state: directory path: "/tmp/{{ runtime }}" # Pull repository - name: pull repository git: repo: "{{ repository }}" version: "{{ version }}" dest: "/tmp/{{ runtime }}" # Packer build - name: build command: packer build build.json args: chdir: "/tmp/{{ runtime }}" # Destroy folder for execution - name: Destroy build folder file: state: absent path: "/tmp/{{ runtime }}"