Using Ansible with OpenWRT

I’ve recently been playing with OpenWRT, and decided to see if I could use Ansible to manage it.  From a basic install of OpenWRT, here is what needs to be done to be able to manage with Ansible:

  • Use the WebUI to upload your SSH public key
  • Install a few packages, either via the WebUI or from the CLI with “opkg install”
    • python-light
    • python-logging
    • python-crypto
  • On your Ansible control node, specify the following in your ansible.cfg (dropbear does not include the sftp subsystem):
    [ssh_connection]
    scp_if_ssh = True
  • Give it a test (output trimmed below for brevity):
    $ ansible -msetup -i [email protected], all
    [email protected] | SUCCESS => {
    "ansible_facts": {
      ...
      "ansible_architecture": "mips",
      ...
      "ansible_distribution": "LEDE",
      "ansible_distribution_version": "17.01.4, Reboot",
      ...
      "ansible_os_family": "LEDE",
      "ansible_pkg_mgr": "opkg",
      ...
      }
    }

 

Leave a comment