If you want a flexible NAS, you are almost obliged to use a Linux-based operating system. Ubuntu Server lends itself perfectly as a Linux server to share files. Moreover, you can easily run all kinds of extra services with Docker. Ansible-NAS makes both file sharing and running additional services on Ubuntu Server extra easy, including a web-based dashboard. In this article we will get started.
Ansible-NAS grew out of David Stephens' frustration with FreeNAS, which often failed to upgrade for him. And that's exactly why I discovered Ansible-NAS myself: FreeNAS is a great open source operating system to run a NAS in your home, but after the umpteenth time I had to connect a keyboard and screen to my NAS to I was tired of solving a problematic upgrade.
I looked for an alternative and found Ansible-NAS (which I thought looked interesting), installed Ubuntu Server first and then Ansible-NAS. Since then I have been very satisfied. I now run even more services on it than I ever did on FreeNAS.
01 Choose hardware
First of all, you need to think about the hardware on which you want to run Ansible NAS. In principle, any Intel-compatible 64bit processor running Ubuntu Server will suffice. The amount of internal memory and your storage capacity obviously depend on what exactly you want to do with it and how many files you have. The processor is especially important if you plan to run a lot of extra services on your nas. Most people really don't need a super fast machine for their NAS. I've been using the compact Dell PowerEdge T110 II tower server with FreeNAS for years, and it runs just as smoothly with Ubuntu Server. David Stephens tests Ansible NAS on an HP Proliant Microserver N54L.
Ansible-NAS assumes that you use the ZFS file system for your data disks, which is very reliable. It's not necessary, but in my case my data disks already had ZFS, because FreeNAS uses that file system too. So I could easily import them into Ubuntu Server. If you work with ZFS, then at least 8 GB of ram is recommended, although it is also possible with less.
For a NAS, it is certainly advisable to introduce some redundancy for extra safety if a disk fails. The easiest way is to set up two data disks in a mirror configuration (aka raid 1): two equal-sized disks that copy each other. With ZFS this is easy to create. The operating system itself is best installed on a separate smaller disk.
02 Install Ubuntu Server
Ansible-NAS is not a nas operating system like FreeNAS, but rather you should think of it as a nas configuration of an Ubuntu server. So you need to install Ubuntu Server first. Ansible-NAS supports the current LTS version, Ubuntu 18.04 LTS. Download the image from the Ubuntu website and drive it to a USB stick or DVD-RW. See also the Ubuntu desktop version article on page ## for more instructions.
The installation is similar to that of Ubuntu Desktop, but without a graphical interface: instead the steps are shown in consecutive text windows. Choose your keyboard layout and then select Install Ubuntu. After that, a network connection is normally set up automatically if you use dhcp in your network. In the next step you choose your storage. Select Use An Entire Disk and choose the drive you want to install Ubuntu on. Confirm the suggested partitioning (by default, Ubuntu uses the ext4 file system, which is fine for the boot drive) with Done and confirm again with Continue. After that, the chosen disk will be erased and the installation will begin.
Then fill in some information, such as the name of the server, your username and password. Then you have to wait for the installation to be completed. Since Ubuntu Server only installs software that is useful for servers, it is faster than Ubuntu Desktop. Then remove the installation media and choose Reboot Now. Then reboot your nas and run Ubuntu Server. See how to log in in the box 'Access your Ubuntu server'.
Access your Ubuntu server
Ubuntu Server does not have a graphical interface, so you will have to enter all kinds of commands. You can do this via the keyboard and screen that you connected during the installation, but it can also be done without, namely via ssh (secure shell) from another computer on the network. If you are running a Windows version from before April 2018, you must install the PuTTY program. If you have a newer version of Windows 10, you can use the built-in ssh client. First go to Settings / Apps / Optional Items and then click Add a part. Choose OpenSSH client and restart your computer. Then you can log in to your Ubuntu server in the Windows Command Prompt with the command ssh [email protected] Confirm with yes that you trust the fingerprint and enter your password. By the way, Linux and macOS already have an ssh client installed by default, so you can get started right away.
03 Preparing data discs
In this masterclass we assume that you use ZFS for your data disks. Install the necessary tools with:
sudo apt install zfsutils
Then we want to create a ZFS file system on two disks in a mirror configuration. First, use the lsblk command to see which disks Ubuntu knows. It's probably called your startup disk sda and your two other drives sdb and sdc. Now create a new partition table on those last two:
sudo parted /dev/sdb
(parted) mklabel gpt
sudo parted /dev/sdc
(parted) mklabel gpt
Now see what the IDs of your two data drives are:
ls -l /dev/disk/by-id/
After all, the names are not guaranteed to remain the same; the IDs do. An ID looks like ata-SAMSUNG_HD204UI_S2H7J9JB712549. Then you need to know the sector size of your hard drives. For modern hard drives, that's 4 kilobytes, but some lie and display 512 bytes if you ask, because Windows XP has problems with 4 kilobytes.
04 Create ZFS Pool
With all this information we can now create a 'pool' on the two drives:
sudo zpool create -o ashift=12 tank mirror ata-SAMSUNG_HD204UI_S2H7J9JB712549 ata-SAMSUNG_HD204UI_S2H7J9JB712552
The text shift=12 points to the sector size of 4 kilobytes (2^12); tank is the name of the pool. It is tradition to choose characters from the movie The Matrix, such as tank, dozer or ash, but you can also just call them dates. Just don't make it too long so it's easy to type.
Then with zpool list you see all your pools, with zpool status the status of all your pools and with zfs list all your ZFS file systems. By default, zpool create creates a filesystem with the same name as your pool and mounts it under your root partition. So your pool called tank will be mounted under /tank.
It is customary to create multiple ZFS file systems under your pool, because you can set per file system whether you want to use compression, whether files are executable and so on. To do this, check out the ZFS configuration tips on the Ansible-NAS website.
05 Install Ansible NAS
Now that the base is ready, we can install Ansible-NAS. First we need to enable another repository with the command:
sudo add-apt-repository universe
Then we install Ansible:
sudo apt install ansible
Ansible is automation software that allows you to automatically configure your Linux systems. Ansible-NAS is really just an Ansible language predefined configuration (a "playbook") to turn your Ubuntu server into a NAS. So installing Ansible NAS is like simply downloading that configuration from GitHub:
git clone //github.com/davestephens/ansible-nas.git
Then go to the directory containing Ansible-NAS:
cd ansible nas
06 Configure Ansible NAS
Ansible NAS comes with a default configuration group_vars/all.yml.dist. Copy that first so you can customize your own configuration:
cp group_vars/all.yml.dist group_vars/all.yml
Now open this last file with the editor nano:
The entire Ansible-NAS configuration is done in this one file. Rules with # begin, are comment lines. They are all over the file for explanation. This is how you can enable any defined service by false nasty true to change.
But first you submit General to set some important things, such as the hostname of your Ubuntu server, your time zone and the username under which you want to run Ansible-NAS. Also enter the path under which Docker stores its container data.
below samba is the configuration of your file sharing. Here you set the path under which all your files that you want to share will be located. Below that, Ansible-NAS defines all kinds of subfolders for your downloads, movies, series, torrents, music, podcasts and so on. For each of those shares you can set whether they are publicly available and the like.
Save your changes with Ctrl+O and then exit nano with Ctrl+X.
07 Apply configuration
Then copy one more file with:
cp inventory.dist inventory
And remove the hash in front of the second line, so it looks like this:
Save the file and then install some more dependencies:
ansible-galaxy install -r requirements.yml
Finally, apply your Ansible-NAS configuration with:
ansible-playbook -i inventory nas.yml -b -K
Upgrade Ansible NAS
Ansible-NAS is actively maintained and new services are continuously added. But because Ansible-NAS is not a program but a collection of configuration files, upgrading is a bit atypical. To do this, go into the Ansible-NAS directory and then pull in the latest changes from GitHub with the git pull command. Then submit all new configuration sections in the file group_vars/all.yml.dist to copy to your own version group_vars/all.yml. A useful way to view those changes is as follows: look in the output of git pull for a line like 84e0c96..7860ab5 master -> origin/master. Then run the following command to show the differences:
git diff 84e0c96:group_vars/all.yml.dist 7860ab5:group_vars/all.yml.dist
In green you see the new rules, in red you see deleted rules. Then make those changes group_vars/all.yml. Then apply the configuration again with:
ansible-playbook -i inventory nas.yml -b -K
08 Dashboard for all your services
From now on, your nas will share the configured folders on your network. In Windows you can easily access it in Windows Explorer. But what else can you do with Ansible NAS? The first thing you should do is add all the extra services you have set up in the Ansible-NAS configuration file to the Heimdall dashboard.
Heimdall's concept may sound a bit simple and useless: it is a simple web server with one web page to which you can add icons of web applications. No more. But if, as in the case of Ansible-NAS, you install all kinds of services, each with its own web interface, you quickly lose the overview if you don't have one place from which you can reach them all. Heimdall excels in this, which by default runs on port 10080 of your NAS.
09 Add services to your dashboard
Therefore, open the dashboard in your web browser and click on the icon with the three horizontal lines at the bottom right. click on Add and then enter a name and url of the service you want to add. If the service is supported by Heimdall, the name of the service will also appear at Application Type, where you can also set the type yourself if, for example, you prefer to call your OPNsense router 'router' in your dashboard. You can also set an icon or background color. Finally, check whether at the top pinned is enabled and click Save to add the service to your dashboard.
Now do this for all Ansible-NAS services, whose port numbers can be found in the Ansible-NAS documentation. You can also add other websites, such as your webmail or other websites that you use often.
Ansible-NAS installs all services (except the file manager) in Docker containers. A container is a kind of virtual machine, but it uses the same kernel as the underlying operating system. Isolating each service in a separate container ensures that they don't interfere with each other and lead to incompatibility issues.
You don't have to worry about that for normal use, but if you want to perform some more advanced configuration tasks or even install extra services that Ansible-NAS does not support by default, it comes in handy that you can work with Docker. See the box 'Manage containers with Portainer'.
11 Install additional services
Ansible-NAS contains numerous additional services that you can install. For many it is sufficient to enter the file group_vars/all.yml a variable with the name of the service and then _enabled on true to enable the service. Additional configuration options such as usernames, directories, etc. for that specific service can be found at the bottom of the configuration file. Be sure to check out the online documentation of Ansible-NAS, because it contains some extra explanation for some of the services.
Every time after you modify the configuration file, you need to apply the Ansible configuration:
ansible-playbook -i inventory nas.yml -b -K
That will install the necessary Docker container and set up your configuration.
12 Interesting Services on Your Nas
It would go too far to go into all the services of Ansible-NAS, but we mention some interesting services. Watchtower is interesting because it downloads the latest version of all your containers daily and restarts them with that new version when there is an update. Cloudflare Dynamic DNS Updater updates your dynamic dns at Cloudflare. Traefik can enable remote access to all your services, including a TLS certificate for each service via Let's Encrypt.
You also have all kinds of services to download multimedia, such as Transmission for BitTorrent and NZBGet for Usenet. Also a Time Machine service for backing up your Macs, a DLNA server, Plex Media Server and even Nextcloud to share your files with others. In short, with Ansible-NAS you make much more of your NAS.
Manage containers with Portainer
Portainer is a user-friendly web interface for Docker. It is the only other service besides Heimdall that Ansible-NAS enables by default, precisely because both services are so convenient. You will find Portainer on port 9000. Log in to your web browser with the username you created for your Ubuntu server and the corresponding password. Then click containers to see your containers. Each container can be stopped, restarted, paused, deleted and so on. But be careful when you delete a container: the next time you apply the configuration of Ansible-NAS, the container will be recreated if you have not disabled it in the file group_vars/all.yml. With a click on Add container you can also install additional services that Ansible-NAS does not provide. To do this, type Image the name of an image that resides on Docker Hub.