Provisioning Development requests sudo, gives /bin/sh: lsb_release: command not found

Revisiting a Ubuntu 18, bionic project from a couple of years ago. I needed to regenerate the Vagrant, dev box and provisioning is failing.

I am using trellis-cli, latest version, with fresh trellis init.

# on the guest
lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.1 LTS
Release:	18.04
Codename:	bionic

I run:

$ ansible-playbook dev.yml -e env=development -vvv

Resulting in:

TASK [python_interpreter : Get Ubuntu release] ***********************************************************************************************************************************************************
task path: /Volumes/path/example.com/trellis/roles/python_interpreter/tasks/main.yml:2
[WARNING]: Failure using method (v2_runner_on_start) in callback plugin (<ansible.plugins.callback.output.CallbackModule object at 0x10deb5820>): 'show_per_host_start'
Callback Exception:
  File "/Volumes/path/example.com/trellis/.trellis/virtualenv/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 381, in send_callback
    method(*new_args, **kwargs)
   File "/Volumes/path/example.com/trellis/.trellis/virtualenv/lib/python3.8/site-packages/ansible/plugins/callback/default.py", line 256, in v2_runner_on_start
    if self.get_option('show_per_host_start'):
   File "/Volumes/path/example.com/trellis/.trellis/virtualenv/lib/python3.8/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option
    return self._plugin_options[k]
<192.168.50.5> ESTABLISH LOCAL CONNECTION FOR USER: mikekilmer
<192.168.50.5> EXEC sudo -H -S -n  -u root /bin/sh -c 'echo BECOME-SUCCESS-htfhjqrjjhejifgcowdeevzuynzjzjpi ; lsb_release -cs'
System info:
  Ansible 2.9.23; Darwin
  Trellis 1.0.2: March 13th, 2019
---------------------------------------------------
non-zero return code
sudo: a password is required
fatal: [192.168.50.5]: FAILED! => {
    "changed": false,
    "rc": 1,
    "stderr_lines": [
        "sudo: a password is required"
    ],
    "stdout": "",
    "stdout_lines": []
}

And running with sudo returns

non-zero return code
/bin/sh: lsb_release: command not found
fatal: [192.168.50.5]: FAILED! => {
    "changed": false,
    "rc": 127,
    "stderr_lines": [
        "/bin/sh: lsb_release: command not found"
    ],
    "stdout": "",
    "stdout_lines": []
}

Similar error here, but I don’t believe the cause is the same.

I had initially been using Ansible v2.10 point something, and thought that might be the issue.

This trellis codebase hadn’t had a requirements.txt file, so it’s pre trellis v1.1.0.

Thanks for any suggestions.

I was thinking that perhaps the python version (v3) was causing the issue, but same result with Python v2:

PLAY [Set ansible_python_interpreter] ********************************************************************************************************************************************************************
[WARNING]: You Ansible version is 2.9.23 but this version of Trellis has only been tested for compatability with Ansible 2.4.0.0 -> 2.7.5. It is advisable to check for Trellis updates or downgrade your
Ansible version.
META: ran handlers

TASK [python_interpreter : Get Ubuntu release] ***********************************************************************************************************************************************************
task path: /Volumes/Path/to/example.com/trellis/roles/python_interpreter/tasks/main.yml:2
[WARNING]: Failure using method (v2_runner_on_start) in callback plugin (<ansible.plugins.callback.output.CallbackModule object at 0x109177d10>): 'show_per_host_start'
Callback Exception:
  File "/Users/mikekilmer/.pyenv/versions/2.7.17/envs/.trellis/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 381, in send_callback
    method(*new_args, **kwargs)
   File "/Users/mikekilmer/.pyenv/versions/2.7.17/envs/.trellis/lib/python2.7/site-packages/ansible/plugins/callback/default.py", line 256, in v2_runner_on_start
    if self.get_option('show_per_host_start'):
   File "/Users/mikekilmer/.pyenv/versions/2.7.17/envs/.trellis/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option
    return self._plugin_options[k]
<192.168.50.5> ESTABLISH LOCAL CONNECTION FOR USER: mikekilmer
<192.168.50.5> EXEC sudo -H -S -n  -u root /bin/sh -c 'echo BECOME-SUCCESS-foblwtzmdokbuffugxwnecrbuhwagxbh ; lsb_release -cs'
System info:
  Ansible 2.9.23; Darwin
  Trellis 1.0.2: March 13th, 2019
---------------------------------------------------
non-zero return code
sudo: a password is required
fatal: [192.168.50.5]: FAILED! => {
    "changed": false,
    "rc": 1,
    "stderr_lines": [
        "sudo: a password is required"
    ],
    "stdout": "",
    "stdout_lines": []
}

Following a return of this issue, decided to update trellis codebase (like a pro!)

(Note that in the above tutorial, the writer assumes that the root directory of your git project is in the trellis directory. If the project root is above the trellis directory:

.git
trellis
site

You will need to first run git init within the trellis directory, otherwise you will have a bunch of updated trellis files above the trellis directory. I like the kDiff app for managing git merge conflicts.

Then destroyed and rebuilt trellis/.trellis using trellis-cli (trellis init), using Python v3.8.

Now I get this error:

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 192.168.50.1:/System/Volumes/Data/Volumes/Path/To/example.com/site /vagrant-nfs-example.test

Stdout from the command:

mount.nfs: mounting 192.168.50.1:/System/Volumes/Data/Volumes/Path/To/example.com/site failed, reason given by server: No such file or directory
exit status 1

And at that point vagrant reload returns:

    default: Running ansible-playbook...
ERROR! Unable to retrieve file contents
Could not find or access '/Volumes/Path/To/example.com/trellis/dotenv.yml' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
exit status 1

Remove the example.test entry from ~/.ssh/config.

Try running trellis up --with-galaxy and it says there’s no galaxy.yml file, which I have added from the Trellis repo.

Destroy again (vagrant destroy), then run trellis dotenv then trellis up --with-galaxy.

Same error:

mount.nfs: mounting 192.168.50.1:/System/Volumes/Data/Volumes/Drive/Clients/Client/example.com/site failed, reason given by server: No such file or directory
exit status 1

The directory is there:

ls /System/Volumes/Data/Volumes/path/to/example.com/site
total 176
CHANGELOG.md   LICENSE.md     README.md      auth.json      composer.json  composer.lock  config/        scripts/       vendor/        web/           wp-cli.yml

Try this SO solution deleting and recreating the exports file:

$ sudo rm -f /etc/exports
$ sudo touch /etc/exports
$ vagrant destroy
$ trellis up

Now it looks like this:

# VAGRANT-BEGIN: 501 2fb1e1ab-22fb-4ab7-b408-ae01cea6fae3
"/System/Volumes/Data/Volumes/Path/To/example.com/site" -alldirs -mapall=501:20 192.168.50.5
"/System/Volumes/Data/Volumes/Path/To/example.com/trellis" -alldirs -mapall=501:20 192.168.50.5
# VAGRANT-END: 501 2fb1e1ab-22fb-4ab7-b408-ae01cea6fae3

Hmmm.

(virtualenv) which vagrant
/usr/local/bin/vagrant
(virtualenv) vagrant --version
Vagrant 2.2.16

VirtualBox Version 6.1.22

Same issue in another, newer Trellis codebase, on Big Sur, working from an external drive.

Was hopeful, again, briefly, when this thread suggested that iTerm may need further permissions (which it does), but I had already done that.

Noticed that the etc/hosts file didn’t have entries for the two trellis projects, which lead me to running sudo trellis up, which returned something new:

Installing plugin vagrant-bindfs
Installing plugin vagrant-hostmanager
`vagrant up` must be re-run now that plugins are installed

Same result with trellis up.

Tried installing vagrant-vbguest plugin with errors:

Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:

ERROR: Failed to build gem native extension.

    current directory: /Volumes/Ochosi/vagrant_home/gems/2.6.7/gems/oroku_saki-1.1.1/ext/oroku_saki
/opt/vagrant/embedded/bin/ruby -I /opt/vagrant/embedded/lib/ruby/2.6.0 -r ./siteconf20210706-30781-fsgyx5.rb extconf.rb
creating Makefile

current directory: /Volumes/Ochosi/vagrant_home/gems/2.6.7/gems/oroku_saki-1.1.1/ext/oroku_saki
make "DESTDIR=" clean

current directory: /Volumes/Ochosi/vagrant_home/gems/2.6.7/gems/oroku_saki-1.1.1/ext/oroku_saki
make "DESTDIR="
compiling memzero.c
clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
memzero.c:16:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^~~~~~~~~~
1 error generated.
make: *** [memzero.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Volumes/Ochosi/vagrant_home/gems/2.6.7/gems/oroku_saki-1.1.1 for inspection.
Results logged to /Volumes/Ochosi/vagrant_home/gems/2.6.7/extensions/x86_64-darwin-19/2.6.0/oroku_saki-1.1.1/gem_make.out

Now had to run vagrant plugin expunge before trellis up (vagrant up) would even run.

Incremented the vagrant ip here as per @ben recommendation.

Wait a minute

Don’t know if this will solve the problem, but I am seeing that the IP address specified by vagrant_ip in the default file (above), is vagrant_ip: '192.168.50.5', but in the error messages, it is 192.168.50.1.

@swalkinshaw @strarsis your input would be very welcome.

Wow. This is a long, lonely thread.

Tried downgrading from vagrant v2.2.16 to v2.2.15. Also tried increasing the vagrant_ip in hosts/development and vagrant.default.yml.

Still getting same error

mount.nfs: mounting 192.168.50.1:/System/Volumes/Data/Volumes/Ochosi/Clients/Example/example.com/site failed, reason given by server: No such file or directory

I think it’s looking for a file called vagrant-nfs-example.test, which is not present.

My two cents here:
Does this folder actually exist on your OS X system?: /System/Volumes/Data/Volumes/Ochosi/Clients/Example/example.com/site

Is 192.168.50.1 the IP address of your OS X workstation, at least for the internal VM/VirtualBox network?

1 Like

Thank you much. Yes, /System/Volumes/Data/Volumes/Ochosi/Clients/Example/example.com/site exists. Is it supposed to contain a file named, vagrant-nfs-example.test? And if so, what process generates that file?

Can you tell me how/where I check what the IP of my workstation, for Vagrant network is?

A simple ifconfig in terminal should be enough to list the interfaces and their IP addresses.

Cool. Yes, the referenced path exists, as noted previously. (I know, it’s a lot to read. Very much appreciate your time and wisdom.)

It looks like the virtualbox IP is the one in the error:

vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	ether 0a:00:27:00:00:00
	inet 192.168.50.1 netmask 0xffffff00 broadcast 192.168.50.255
vboxnet1: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 0a:00:27:00:00:01

How does that IP relate to the one configured in development/hosts and vagrant.default.yml?

Good news, sort of. Same error on a different Trellis project:

mount.nfs: mounting 192.168.50.1:/System/Volumes/Data/Volumes/Ochosi/Clients/Another/another.com/site failed, reason given by server: No such file or directory

Permission issue, maybe?

So I found a troubleshooting topic for this error:

  • Check status of nfs-kernel-server systemctl status nfs-kernel-server for errors like exportfs: Failed to stat /path : No such file or directory . Then create the missing directory or remove the line from /etc/exports and restart the nfs-kerne-server sysctemctl start nfs-kernel-server

Also on that page check the section For OS X, sudoers should have this entry: and ensure those changes.

Awesome. Getting closer. I can feel it.

As noted in above link, using visudo, added the following to /etc/sudoers file:

Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

In the guest (vagrant ssh):

vagrant@example:~$ mount -o vers=3,udp 192.168.50.1:/System/Volumes/Data/Volumes/Ochosi/Clients/example/example.com/site /vagrant-nfs-example.test
mount: only root can use "--options" option.

Using sudo:

sudo mount -o vers=3,udp 192.168.50.1:/System/Volumes/Data/Volumes/Ochosi/Clients/client/client.com/site /vagrant-nfs-example.test
mount.nfs: access denied by server while mounting 192.168.50.1:/System/Volumes/Data/Volumes/Ochosi/Clients/client/client.com/site

Have given full disc access to nfsd.

The /etc/exports entry looks good:

# VAGRANT-BEGIN: 501 97e897e1-d468-4a41-bf42-a96eb4fc8306
"/System/Volumes/Data/Volumes/Ochosi/Clients/Client/example.com/site" -alldirs -mapall=501:20 192.168.50.6
"/System/Volumes/Data/Volumes/Ochosi/Clients/Client/example.com/trellis" -alldirs -mapall=501:20 192.168.50.6
# VAGRANT-END: 501 97e897e1-d468-4a41-bf42-a96eb4fc8306

With matching entry in /etc/hosts:

## vagrant-hostmanager-start id: 2fb1e1ab-22fb-4ab7-b408-ae01cea6fae3
192.168.50.5    example.test
192.168.50.5    www.example.test
## vagrant-hostmanager-end

Hey! Wait a minute! Those IDs (in hosts and exports) don’t match. Are they supposed to? Removed both entries and running this loop for the 40th time: vagrant destroy -f && trellis up.

This time there’s no /etc/hosts entry for example.com. Does the vagrant-hostmanager-start id matter? It’s just a comment, right?

Here’s something. The IP address I have set in vagrant.default.yml and hosts/development ends with a 6, but in the hosts file entry was (i presume an older one) ending with a 5 as you can see above. I don’t imagine that makes any difference in terms of the inability to mount.

Same problem here while trying to re-provision a new install after changed WP env’s on MacOS Big Sur.

sudo trellis provision development results in.

TASK [python_interpreter : Get Ubuntu version] *********************************

System info:

Ansible 2.10.11; Darwin

Trellis 1.8.0: February 12th, 2021

---------------------------------------------------

non-zero return code

/bin/sh: lsb_release: command not found

fatal: [192.168.50.5]: FAILED! => {"changed": false, "rc": 127, "stderr_lines": ["/bin/sh: lsb_release: command not found"], "stdout": "", "stdout_lines": []}


The one hint I found: ``lsb_release is a command that runs on Linux only: the "LSB" stands for "Linux Standard Base" and this refers to a standard baseline set of tools and libraries that Linux distributions can elect to support. https://stackoverflow.com/questions/39946101/make-dependencies-on-mac-gives-make-lsb-release-command-not-found-erro

Still unresoved trying to provision any of these Trellis vagrant boxes on Big Sur here as well.

1 Like

Running through some of the tips here.

I’m not sure if the following is meant to be run on the host or guest:

tcpdump -s0 -i [eth#] host [ip_address] -w /tmp/tcpdump.pcap

With or without sudo, or if the ip_address is supposed to be 192.168.50.1 or (in my case) 192.168.50.5 or 192.168.50.6 (depending on project).

Without sudo the result is

tcpdump: [eth#]: You don't have permission to capture on that device
((cannot open BPF device) /dev/bpf0: Permission denied)

Run as super user,

tcpdump: [eth#]: No such device exists
(BIOCSETIF failed: Device not configured)

That’s the same in guest and host.

Within the guest, still getting mount.nfs: access denied by server while mounting 192.168.50.1:.

I think that “server” refers to the host machine, but am not sure what within the host machine is doing the serving.

I was able to get pas this hurdle by, as referenced at the bottom of the Vagrant link from above, as well is in another local thread here by adding the nfs_udp: false, configuration to Vagrantfile.

I added it in two places, on lines 86 and 87.

I had wondered if **extra_options were command line options where this config pair could go, but it appears they are settings for when vagrant_mount_type == 'smb'.

UDB, is User Datagram Protocol. It looks like Big Sur has added some security features that may have effected these types of connections.

Whoops. Did I say that adding nfs_udp: false worked. It just appeared to work because I had already run vagrant up.

Then I get the Composer could not find a composer.json file (MacOS Catalina) issue. So… still in the playground.

Reverted back to OSX Mojave and provisioning as usual now.

You ever make any progress on this, man? Seems to have popped up again for me.

This would be if I were running the HOST MACHINE on Linux, as opposed to OS X, correct?

Yes, the NFS kernel thing runs on the host machine and provides the shares that should be used by the Vagrant guests.