summaryrefslogtreecommitdiffstats
path: root/ansible/deployment_poc/tasks/init_vm_console.yml
blob: 5b1c61426681a635ae83be495561b0d1358a3745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- 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