Ansible and QNAP

Ansible and my QNAP NAS

Im a huge fan of Ansible and I also really like my NAS. Im currently on my second NAS from QNAP - they just do the job, with no fuss. They have a nice interface, you can ssh into them easily and they are frequently updated, even long after any warranty has run out.

One of the things you do when you first discover ansible is you start thinking of all the things you can use it on. As its agentless the scope is much broader than other configmanagement tools. Even network switches and routers can be managed via ansible

So it stands to reason that I would like to ensure the configuration of my NAS with ansible. As my NAS has python on it, it can be a first class citizen isn this respect - or so I thought. However it quickly became apparent that the version of pythin that was on there wasnt going to be good enough and so I would have to fall back to raw mode. This didnt sit well, so I trawled the internet and saw other people with the same issue - all offering some advice that worked for them but not for others

So to cut a long story short - go the the app store on your QNAP and install Python 3.5.x.y

QNAP app store

Next you meed to find where your new python3 program is, on my NAS its here

 /share/CACHEDEV1_DATA/.qpkg/Python3/python3/bin/python3

Now that you know this, simply add a line to your inverntory file to instruct ansible where to find the correct version of python

In my inverntory I have this

 [qnap]
 192.168.3.240 ansible_user=admin ansible_python_interpreter=/share/CACHEDEV1_DATA/.qpkg/Python3/python3/bin/python3

Now you should be able to so a proper ansible run against your QANP

ansible ping

$ ansible qnap -i hosts -m ping
192.168.3.240 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

ansible setup

$ ansible qnap -i hosts -m setup
192.168.3.240 | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "10.0.3.1", 
            "172.20.0.1", 
            "172.17.0.1", 
            "172.19.0.1", 
            "172.18.0.1", 
            "192.168.3.240", 
            "10.0.5.1"
        ], 
        "ansible_all_ipv6_addresses": [], 
        "ansible_apparmor": {
            "status": "disabled"
        }, 
        "ansible_architecture": "x86_64", 
        "ansible_bios_date": "06/07/2016", 
        "ansible_bios_version": "QX77AR20", 
        "ansible_bond0": {
            "active": true, 
            "device": "bond0", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "on", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off", 
                "loopback": "off [fixed]", 
                "netns_local": "on [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "off [fixed]", 
                "rx_fcs": "off [fixed]", 
                "rx_vlan_filter": "on", 
                "rx_vlan_offload": "on", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "on", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "off [fixed]", 
                "tx_gre_segmentation": "on", 
   <output truncated>

Have fun, OSG