ansible-lint fixes
This commit is contained in:
@@ -1,32 +1,34 @@
|
||||
---
|
||||
- name: Check if VM disk exists
|
||||
delegate_to: localhost
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2"
|
||||
register: vm_disk_stat
|
||||
|
||||
- name: Create VM disk
|
||||
when: not vm_disk_stat.stat.exists
|
||||
delegate_to: localhost
|
||||
command: "qemu-img create -f qcow2 {{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2 {{ vm_size }}G"
|
||||
ansible.builtin.command: qemu-img create -f qcow2 {{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}.qcow2 {{ vm_size }}G
|
||||
|
||||
- name: Generate Random MAC Address
|
||||
delegate_to: localhost
|
||||
shell: openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | sed 's/^/02:/'
|
||||
ansible.builtin.shell: openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | sed 's/^/02:/'
|
||||
changed_when: false
|
||||
register: mac_address_output
|
||||
|
||||
- name: Render cloud config templates
|
||||
delegate_to: localhost
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "/tmp/{{ item.dest_prefix }}-{{ hostname }}.yml"
|
||||
dest: /tmp/{{ item.dest_prefix }}-{{ hostname }}.yml
|
||||
loop:
|
||||
- { src: "cloud-user-data.yml.j2", dest_prefix: "cloud-user-data" }
|
||||
- { src: "cloud-network-config.yml.j2", dest_prefix: "cloud-network-config" }
|
||||
- { src: cloud-user-data.yml.j2, dest_prefix: cloud-user-data }
|
||||
- { src: cloud-network-config.yml.j2, dest_prefix: cloud-network-config }
|
||||
|
||||
- name: Create cloud-init disk
|
||||
delegate_to: localhost
|
||||
command: "cloud-localds {{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}-cloudinit.iso /tmp/cloud-user-data-{{ hostname }}.yml -N /tmp/cloud-network-config-{{ hostname }}.yml"
|
||||
ansible.builtin.command: cloud-localds {{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}-cloudinit.iso /tmp/cloud-user-data-{{ hostname }}.yml -N
|
||||
/tmp/cloud-network-config-{{ hostname }}.yml
|
||||
|
||||
- name: Create VM using libvirt
|
||||
delegate_to: localhost
|
||||
@@ -34,8 +36,8 @@
|
||||
command: define
|
||||
xml: "{{ lookup('template', 'vm.xml.j2') }}"
|
||||
|
||||
- name: start vm
|
||||
- name: Start vm
|
||||
delegate_to: localhost
|
||||
community.libvirt.virt:
|
||||
name: "{{ hostname }}"
|
||||
state: running
|
||||
state: running
|
||||
|
||||
Reference in New Issue
Block a user