umount: /tmp: target is busy - payload files?

Hi!

I am using a playbook `from github created by Reiner Nippes to setup a nextcloud server. I changed quite some things to be able to run it on OpenSuse Tumbleweed.

Before running the playbook, /etc/fstab looks like the following:
UUID=a34c85bd-79d2-4145-8772-04be970fe413 / btrfs defaults 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /.snapshots btrfs subvol=/@/.snapshots 0 0
UUID=9d812efe-44e4-4594-affe-37299672ad9e swap swap defaults 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /var btrfs subvol=/@/var 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /usr/local btrfs subvol=/@/usr/local 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /srv btrfs subvol=/@/srv 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /root btrfs subvol=/@/root 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /opt btrfs subvol=/@/opt 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /home btrfs subvol=/@/home 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0
UUID=7388-F693 /boot/efi vfat defaults 0 0

In the playbook there is a task to mount /tmp as tmpfs:

  • name: mount tmp fs
    mount:
    src: “tmpfs”
    path: “{{ item }}”
    fstype: tmpfs
    opts: “defaults,noatime,nosuid,nodev,noexec,mode=1777”
    passno: “0”
    state: mounted
    with_items:
  • /tmp
  • /var/tmp

The first time I run the playbook, I get this error:
failed: [nextcloud] (item=/tmp) => {“ansible_loop_var”: “item”, “changed”: false, “item”: “/tmp”, “msg”: "Error mounting /tmp: umount: /tmp: target is busy.

and the file /etc/fstab has a new entry afterwards:
UUID=a34c85bd-79d2-4145-8772-04be970fe413 / btrfs defaults 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /.snapshots btrfs subvol=/@/.snapshots 0 0
UUID=9d812efe-44e4-4594-affe-37299672ad9e swap swap defaults 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /var btrfs subvol=/@/var 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /usr/local btrfs subvol=/@/usr/local 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /srv btrfs subvol=/@/srv 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /root btrfs subvol=/@/root 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /opt btrfs subvol=/@/opt 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /home btrfs subvol=/@/home 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0
UUID=a34c85bd-79d2-4145-8772-04be970fe413 /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0
UUID=7388-F693 /boot/efi vfat defaults 0 0
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777 0 0

When I run the playbook a second time, I don’t get the error anymore and all is fine.

I executed “watch -n 1 ls -l /tmp/” to perodically check if ansible is writing anything to /tmp, and yes, it is!

There are some temporary files which appear and disapear during the execution. I already added the following two lines to my ansible.cfg file:
local_tmp = /tmp2
remote_tmp = /tmp2

Unfortunately, there are still these “payload” files appearing in /tmp.

  1. Where do they come from? What do they contain and how can I change the directory for these files?

I guess these payload files are the reason why the mount module fails in the first place.

  1. Am I doing something wrong?

  2. Is a workaround possible?

  3. Has it something to do with the BTRFS filesystem? On Ubuntu this mount task is working…

  4. Why is it trying to umount at all? I want it to mount /tmp

I have also made a desktop capture of this behavior: https://drive.google.com/open?id=1Ta2-x4wUgoz1Ig3jabooHwVJV4l-SyQ1

Thanks a lot for your help!

Hi!

I am using a playbook `from github created by Reiner Nippes to setup a
nextcloud server. I changed quite some things to be able to run it on
OpenSuse Tumbleweed.

<snip />

In the playbook there is a task to mount /tmp as tmpfs:

- name: mount tmp fs
   mount:
     src: "tmpfs"
     path: "{{ item }}"
     fstype: tmpfs
     opts: "defaults,noatime,nosuid,nodev,noexec,mode=1777"
     passno: "0"
     state: mounted
   with_items:
     - /tmp
     - /var/tmp

/var/tmp is defined as a persistent tmp, and changing this to tmpfs might break other software that depends on /var/tmp being persistent.

And changing them on a running system is not recommended since other software might be using the tmp.
The best approach is to use state: present and reboot.

I executed "watch -n 1 ls -l /tmp/" to perodically check if ansible is
writing anything to /tmp, and yes, it is!
There are some temporary files which appear and disapear during the
execution. I already added the following two lines to my ansible.cfg file:
local_tmp = /tmp2
remote_tmp = /tmp2

Default they are pointing to ~/.ansible/tmp

Unfortunately, there are still these "payload" files appearing in /tmp.
1. Where do they come from? What do they contain and how can I change the
directory for these files?
I guess these payload files are the reason why the mount module fails in
the first place.

A grep in the source it seams that some module and plugins have /tmp hard coded and maybe the code you are running is creating files in tmp.

2. Am I doing something wrong?

Sort of, use present and reboot.

3. Is a workaround possible?

See 2.

4. Has it something to do with the BTRFS filesystem? On Ubuntu this mount
task is working...

No.

Ok, I just googled a bit and I think I will only mount /tmp as tmpfs. I will not change the mount for /var/tmp.

So now I am using:

  • name: mount tmp fs
    mount:
    src: “tmpfs”
    path: “{{ item }}”
    fstype: tmpfs
    opts: “defaults,noatime,nosuid,nodev,noexec,mode=1777”

passno: “0”
state: present
with_items:

  • /tmp

Thanks a lot, you are awesome!