--- - name: create mac address local_action: module: command cmd: python macgen.py chdir: "{{ role_path }}/files" register: macgen check_mode: false - name: create folder for new vm local_action: module: file path: "./host_vars/{{ vmname }}" state: directory - name: create hostvars for new vm local_action: module: template src: vm_hostvars.j2 dest: ./host_vars/{{ vmname }}/vars.yml - name: add vm to hosts local_action: module: lineinfile path: hosts insertafter: '^\[vms\]' line: "{{ vmname }}"