Configuring a TerraMaster NAS with Ansible

I recently purchased a TerraMaster F5-422 NAS. The main reason was so that I could move a number of Docker containers off of my PC, allowing it to be switched off without the need to manage services beforehand.

While I haven’t made my opinion of the TNAS quite yet, As I like to automate what I can, I wanted to share what I had to do to use Ansible for configuration management on their bespoke Linux operating system.

In the end, it was fairly straight forward, but there are a few pre-requisites to address before Ansible will be able to connect.

  1. Ensure that SSH has been enabled within the TOS settings SSH options in TOS v4.2.15
  2. Connect to your TNAS and edit the /etc/ssh/sshd_config file to allow your custom user (if applicable)
     AllowUsers admin myuser
    
  3. Add your public key to ~/.ssh/authorized_keys so that we can connect without passwords
  4. Finally, update the permissions of /dev/null to 666 otherwise Ansible won’t be able to function properly

With these requirements in place, we can now test that the Ansible playbook runs as intended. This repository contains details on what we have already covered, as well as all the pieces needed to confirm that the SSH connection through Ansible is working.

Make changes to the inventory file as appropriate to your situation (IP, user, key path, etc), then run the following command to connect to your TNAS.

$ ansible-playbook -i ./inventory.ini -K ./example-playbook.yml
BECOME password:

PLAY [TerraMaster] ************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************
ok: [F5-422]

TASK [ping] *******************************************************************************************************************
ok: [F5-422]

PLAY RECAP ********************************************************************************************************************
F5-422                     : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

You can now modify the playbook to add any requirements that you may have to configure your own instance. As the flavour of Linux is not standard, you may encounter some issues.