Setting up our Media Server

Some time ago (almost 2 years ago), my boyfriend built a media server.  He has no idea how to set it up, so since then it has sat in our closet and collected dust.  Our external hard drive is on its last leg, so I figured now is a better time than ever to get our media server up and running.

I’ve always wanted to play with Ansible.  If you don’t know what Ansible is, you can check out more here:  In summary, it’s an IT automation platform used for machine configuration and management.  It’s simple to use, but powerful.  Although it would probably make for a better use case if I was utilizing it towards a multi-host environment, I’ll only be using it to manage a single host, our media server.

By default, Ansible manages hosts over SSH.  You only need a single machine to act as the ‘control machine.’  Your control machine should be running a *nix based OS.  I will be using my laptop as my control machine, which is running on Ubuntu 16.04 LTS.  For my remote machine, I’m running Ubuntu Server 16.04.1 LTS.

Installing Ansible on my remote machine was super easy:

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible


I created a directory, server-ansible in my home directory.  In your own Ansible directory, you will want to create a hosts file.  Your hosts file should have a structure similar to the following:



Anything in [brackets] are group names.  They are as they sound — we use them to group different systems.  You could name [server] anything you want.

Next, I created a configuration file: ansible.cfg.  This will tell Ansible where it can find our list of hosts:

inventory = hosts

I should note that, before adding the server variables ansible_ssh_user/ansible_password (and more importantly, ansible_password), I was receiving an undesirable response via ping command: | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh.", 
    "unreachable": true

This was driving me nuts, as I was able to connect to my server via ssh through a terminal no problem…

Thanks to a very helpful Github comment, once I added the ansible_password variable to my hosts file, I was able to get a proper response:

$ ansible server -m ping | SUCCESS => {
 "changed": false, 
 "ping": "pong"

To test, I ran my very first ad-hoc command to see if I could contact my single node:

$ ansible server -a "/bin/echo hello world!" | SUCCESS | rc=0 >>
hello world!

Voila!  Easy peasy. 🙂

Next, I will probably try tackling a Docker install via Ansible.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s