Installing addons via ansible

Hi there,

I’m trying to automatically set up openhab2 on a Debian machine through an ansible task. Adding the repository and installing the packages works fine, an so does copying pre-defined configuration files into /etc/openhab2. However, I’m a bit lost when it comes to installing add-ons. I suppose one could let ansible execute something like

ssh -p 8101 openhab@localhost ‘bundle:install [whatever]’

on the remote machine, but I just can’t figure out what to enter for [whatever]. The bundle:install command apparently expects an URI, but how to find out the URI for a specific add-on? (In my case, I’m particularly interested in the TCP/UDP binding and JSONPath transformation add-ons.)

So does anyone know how to find the URL for a specific add-on? Or is there a better way to install add-ons through ansible?

(A secondary problem would be how to set/change/provide the openhab2 password through ansible…)

Any help appreciated –

Torsten

You should be able to define a list of addons to install in /etc/openhab2/services/addons.cfg.

1 Like

Hi,

You should be able to define a list of addons to install in |/etc/openhab2/services/addons.cfg|.

well, in this file it is stated that “This is only regarded at the VERY FIRST START of openHAB”, which isn’t very helpful in case I want to change the list of add-ons to be installed later.

Furthermore, the add-on designations to be used in this file are rather semi-intuitive – for instance, what would be the correct designation of the “TCP & UDP Binding” (as it is called on http://docs.openhab.org/addons/bindings/tcp1/readme.html)?

So is there any way to install additional add-ons from the command line later on?

Cheers –

Torsten

I think the very first start is referring to the installation package only:

#package = minimal

which is only checked once. It should check the others at least each launch so this should be fine for changing the list later.

The correct designation for that specific binding is “tcp1”. The path after “/bindings/” in the docs is the name the services usually refer to. The appended 1 simply refers to the fact that it’s a binding from openHAB 1.x.

EDIT: I’ve just tested changing the addons.cfg file. It installs the list of bindings as soon as the file is updated, it will also uninstall ones that are no longer in the list.

Benjy,

I think the very first start is referring to the installation package only:

package = minimal

which is only checked once. It should check the others at least each launch so this should be fine for changing the list later.

The correct designation for that specific binding is “tcp1”. The path after “/bindings/” in the docs is the name the services usually refer to. The appended 1 simply refers to the fact that it’s a binding from openHAB 1.x.

EDIT: I’ve just tested changing the addons.cfg file. It installs the list of bindings as soon as the file is updated, it will also uninstall ones that are no longer in the list.

that’s cool – that seems to be exactly what I need! (And it’s also much simpler than issuing a Karaf command though ssh through ansible…)

The only remaining question is: How can I figure out the add-on names myself – I don’t want to bother the forum all the time I need another entry in addons.cfg… :wink:

Cheers –

Torsten

I’m not sure of the correct way myself! The only sure way I know of is to look for the binding in this list:

http://docs.openhab.org/addons/bindings.html

And check the path of the binding to match with the name e.g.:

That is to say it is whatever comes after “org.openhab.binding.” for openHAB 2 addons and openHAB 1.x bindings (with an appended ‘1’).

Hope this helps!

Hey guys, I think this should be possible using the openHAB REST API, e.g.:

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" "http://127.0.0.1:8080/rest/extensions/binding-airquality/install"

Edit: Tested and confirmed :tada:

1 Like

image

Rich,

thanks, I already figured this out by myself over the last hours…

Thanks to all of you, now everything works perfectly! :slight_smile:

Cheers –

Torsten

1 Like

I explained it in an beginner tutorial some moments ago, with the intention to refer it later. Thank you for that chance. :laughing:

I did not post all bindings information feature:list returns.

@tcrass: Would you mind sharing your ansible role? Either on ansible galaxy or here (even if it’s not quite clean for sharing with the masses)?

Would be great!