You can simplify this to be:

```ruby
# Set the password for the ubuntu user to 'ubuntu'.
config.vm.provision :shell, inline: "sudo su - root /bin/bash -c 'echo \"ubuntu:ubuntu\" | chpasswd -c SHA512'"
```