summaryrefslogtreecommitdiffstats
path: root/ansible/deployment_poc/tasks/init_vm_console.yml
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/deployment_poc/tasks/init_vm_console.yml')
-rw-r--r--ansible/deployment_poc/tasks/init_vm_console.yml39
1 files changed, 39 insertions, 0 deletions
diff --git a/ansible/deployment_poc/tasks/init_vm_console.yml b/ansible/deployment_poc/tasks/init_vm_console.yml
new file mode 100644
index 0000000..1007c90
--- /dev/null
+++ b/ansible/deployment_poc/tasks/init_vm_console.yml
@@ -0,0 +1,39 @@
+---
+- 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 }}"
+
+ - 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
+
+