diff --git a/README.md b/README.md index 3b7e412..17ead16 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,13 @@ Actually, the server responds to the following routes: network. * `/vaultpass`: provides encrypted password for the decription of vaulted files within [Ansible configuration repository][client-pull-installation]. - -## TODO List ## - -* Implement methods for dynamic inventory for Ansible -* Verify RPM packaging to automatically start daemon as soon as it is - installed -* Verify NethServer script for `runlevel-adjust` +* `/ansible_list`: replies with the hostname list to be used with a dynamic + inventory script for Ansible, please see [this +page][ansible-dynamic-inventory]. +* `/ansible_host`: receives a `host` parameter, but returns anyways additional + variables based on the MAC address of the client contacting it, to be used +with dynamic inventory script for Ansible and `ansible-pull`. +* `/epoptes-srv`: replies with the hostname of the local [Epoptes][epoptes] controller. [bglug]: http://bglug.it "BgLUG Homepage" [ubuntu]: http://www.ubuntu.com @@ -62,3 +62,5 @@ Actually, the server responds to the following routes: [sqlite]: https://www.sqlite.org/ [gplv2]: https://www.gnu.org/licenses/gpl-2.0.html [enrico bacis]: https://github.com/enricobacis +[ansible-dynamic-inventory]: http://docs.ansible.com/ansible/developing_inventory.html +[epoptes]: http://www.epoptes.org/ diff --git a/doraemon.py b/doraemon.py index 7b6dc0c..b48a10b 100644 --- a/doraemon.py +++ b/doraemon.py @@ -63,6 +63,7 @@ class MyApp: self.__app.get('/vaultpass', callback=self.vaultpass) self.__app.get('/ansible_list', callback=self.ansible_list) self.__app.get('/ansible_host', callback=self.ansible_host) + self.__app.get('/epoptes-srv', callback=self.epoptes_srv) def __init_tables(self): with self.__getcursor() as cursor: @@ -204,6 +205,16 @@ class MyApp: role = self.__getrole() return dumps(self.__rolevars(role)) + def epoptes_srv(self): + hostname = None + try: + with self.__getcursor() as cursor: + (hostname,) = cursor.execute('SELECT hostname FROM client WHERE role = \'docenti\' ORDER BY id DESC LIMIT 1').fetchone() + except TypeError: + return 'none' + + return hostname + def start(self): # Opens up a PID file pid = os.getpid()