0

I am trying to start a named byobu session on a VM through ansible playbook using byobu commands. The session does start but in the background i.e the session and its all windows/tasks are being shown when I run _ps -aux_ command but when I try to attach to that session (testByobu) from VM by _byobu attach-session -t testByobu_, it says can't find session testByobu, similarly command _byobu list-session_ says

no server running on /tmp/tmux-100/default*.

VM ---VirtualBox VM with Ubuntu 18.04.2 LTS ---Byobu version 5.125 tmux 2.6

Local system ---Ubuntu 18.04.2 LTS ---ansible 2.8.0 config file = /etc/ansible/ansible.cfg configured module search path =[u'/home/emumba/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]

When I try to create a session of same name i.e. testByobu again with the ansible playbook, an error

TASK [start byobu session] *************************************************************************************************************************** fatal: [192.168.2.218]: FAILED! => {"changed": true, "cmd": "byobu new-session -d -s testByobu", "delta": "0:00:00.046348", "end": "2019-05-27 12:26:15.832584", "msg": "non-zero return code", "rc": 1, "start": "2019-05-27 12:26:15.786236", "stderr": "duplicate session: testByobu", "stderr_lines": ["duplicate session: testByobu"], "stdout": "", "stdout_lines": []}

occurs as it finds the session already exists. But when I make this same session (testByoby) directly on the VM, it is created successfully. And the ps -aux command on VM shows both sessions running wih same name and the windows I created of the session created through playbook are also being shown in the output. But running byobu list-session command shows only one session which I created directly on the VM.

**output of the _ps -aux_ command:**

USER    PID %CPU %MEM   VSZ   RSS TTY   STAT START   TIME COMMAND
osama   3374  0.0  0.1  37284  3740 ?       Ss   12:27   0:00 tmux -u -2 -f /usr/share/byobu/profiles/tmuxrc new-session -d -s testByobu
osama   3378  0.0  0.2  29896  5080 pts/6   Ss+  12:27   0:00 /bin/bash
root    4087  0.0  0.0      0   0 ?     I   12:31   0:00 [kworker/u2:1-ev]
root    4123  0.0  0.0      0   0 ?     I   12:36   0:00 [kworker/0:2]
root    4126  0.0  0.3 110076  7280 ?       Ss   12:36   0:00 sshd: osama [priv]
osama   4190  0.2  0.2 110556  5288 ?       S   12:36   0:00 sshd: osama@notty
root    4275  0.0  0.1  37276  3652 ?       Ss   12:36   0:00 tmux -u -2 -f /usr/share/byobu/profiles/tmuxrc new-session -d -s testByobu
root    4278  0.0  0.1  28908  4040 pts/3   Ss+  12:36   0:00 /bin/bash
root    4403  0.0  0.1  28908  3852 pts/2   Ss   12:36   0:00 /bin/bash
root    4441  0.0  0.2  39760  4196 pts/2   S+   12:36   0:00 vi
root    4492  0.0  0.1  28908  3948 pts/4   Ss+  12:36   0:00 /bin/bash
root    4581  0.0  0.1  28908  3892 pts/5   Ss   12:36   0:00 /bin/bash
root    4619  0.0  0.0  23828  1076 pts/5   S+   12:36   0:00 ping 8.8.8.8
osama   4641  0.0  0.1  47100  3716 pts/0   R+   12:37   0:00 ps -aux

tried other way around If I make the session on the VM first and then if I run the playbook to make the windows of that session, it again encounters an error

TASK [task 1] **************************************************************************************************************************************** fatal: [192.168.2.218]: FAILED! => {"changed": true, "cmd": "byobu send-keys -t testByobu:0 'vim' 'C-m'", "delta": "0:00:00.057772", "end": "2019-05-27 12:30:08.899375", "msg": "non-zero return code", "rc": 1, "start": "2019-05-27 12:30:08.841603", "stderr": "no server running on /tmp/tmux-0/default", "stderr_lines": ["no server running on /tmp/tmux-0/default"], "stdout": "", "stdout_lines": []}

which again shows that the playbook is not accessing the already existing.

here is the sample playbook.


  name: Test Byobu
  hosts: all
  remote_user: osama
  become: yes

tasks:

#  name: kill byobu session
#  shell: byobu kill-session -t testByobu

    name: start byobu session
    shell: byobu new-session -d -s testByobu


  name: task 1
  shell: |
  byobu send-keys -t testByobu:0 'vim' 'C-m'

  name: task 2
  shell: |
  byobu new-window -t testByobu:1
  byobu send-keys -t testByobu:1 'vi' 'C-m'

  name: task 3
  shell: |
  byobu new-window -t testByobu:2
  byobu send-keys -t testByobu:2 'cd /tmp/ && touch testByobu.txt' 'C-m'

  name: task 4
  shell: |
  byobu new-window -t testByobu:3
  byobu send-keys -t testByobu:3 'ping 8.8.8.8' 'C-m'`

What I expect is that when I run my playbook (code provided), it should create a new session named testByobu on the VM such that it should be accessible when I run _byobu attach-session -t testByobu_ command with all its winows intact which are being created in the playbook. And I can switch to all 4 windows that are being created in the playook.

And what actually happening is that the playbook runs successfully but on the VM, the session runs in background and the byobu on the VM seems to have no clue about that session.

I'll appreciate any help in this regard.

Update I think I should summarize the problem, it may make the detailed description easy to understand.

I want to start a byobu session named testByobu on a VM and run different processes on separate windows of that session all through ansible playbook. The playbook (code provided) runs successfully but on the VM when I try to list byobu sessions using byobu list-session command, testByobu is not there in the list. And for this reason I am also unable to attach to that session when I run byobu attach-session -t testByobu command. The important thing to mention is that the session 'testByoby' and all the processes made to run inside this session through playbook, do show up in the list of running processes produced by the command ps -aux. What I want is that the session must appear when I run the byobu list-session command on the VM and consequently getting inside that session must be achievable when I run byobu attach-session -t testByobu command.

0 Answers0