43 lines
866 B
YAML
43 lines
866 B
YAML
---
|
|
- name: Start VM and attach console inside tmux
|
|
block:
|
|
- name: Start VM
|
|
community.libvirt.virt:
|
|
uri: "{{ libvirt_url }}"
|
|
command: start
|
|
name: "{{ vm_name }}"
|
|
state: running
|
|
|
|
- name: Spawn tmux session
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/bin/tmux
|
|
- -S
|
|
- /tmp/ansible
|
|
- new-session
|
|
- -d
|
|
- -s
|
|
- "{{ vm_name }}"
|
|
ignore_errors: true
|
|
|
|
- name: Attach console inside tmux
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/bin/tmux
|
|
- -S
|
|
- /tmp/ansible
|
|
- new-window
|
|
- -t
|
|
- "{{ vm_name }}"
|
|
- /usr/bin/virsh
|
|
- -c
|
|
- "{{ libvirt_url }}"
|
|
- console
|
|
- "{{ vm_name }}"
|
|
|
|
delegate_to: localhost
|
|
tags:
|
|
- init_ssh
|
|
|
|
|