vm-setup/roles/create-vm/tasks/create_hostvars.yml

30 lines
586 B
YAML
Raw Normal View History

2022-06-16 20:43:06 +02:00
---
- 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
#mode: 0666
- name: add vm to hosts
local_action:
module: lineinfile
path: hosts
insertafter: '^\[vms\]'
line: "{{ vmname }}"