FreeNAS 11.2/Ansible Integration - what version of FreeNAS API to pick?

Rhaido

Cadet
Joined
Jun 19, 2018
Messages
7
Colleagues,

I'm developing a set of Ansible modules, intended to automate certain aspects of FreeNAS integration. I'm testing with FreeNAS 11.2, and it looks like, that API v2.0 is still catching up with v1.0. For example, this is a valid v1.0 call:

Code:
$ curl -u 'user:password' 'https://storage.local/api/v1.0/storage/dataset/tank/test/' 2>/dev/null | jshon
{
 "atime": "off",
 "avail": 502817193984,
 "comments": null,
 "compression": "lz4",
 "dedup": "off",
 "exec": "on",
 "inherit_props": [
  "compression",
  "aclmode",
  "aclinherit",
  "dedup",
  "org.freebsd.ioc:active"
 ],
 "mountpoint": "\/mnt\/tank\/test",
 "name": "tank\/test",
 "pool": "tank",
 "quota": 0,
 "readonly": "off",
 "recordsize": 131072,
 "refer": 34053718016,
 "refquota": 536870912000,
 "refreservation": 0,
 "reservation": 0,
 "sync": "standard",
 "used": 34053718016
}


In comparison, approximately the same call is failing in v2.0:

Code:
$ curl -u 'user:password' 'https://storage.local/api/v2.0/pool/dataset/id/tank/test'
404: Not Found


So, the question for the experts: is it's worth a hassle right now to develop using v2.0 of API or better to write for API v1.0 and try to isolate API-dependent calls for future upgrade?

And another tricky question: I've written the user management module for freenas using v1.0 of API (i'll soon publish on github, as it's production tested :D), and POST calls are very-very-very slow with it, though getting through. Does anybody know, is there any improvement in this domain (speed of POST calls processing) with v2.0 API and FreeNAS 11.2?

Thank you in advance and have a good day!
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
From my understanding of the release notes and roadmap you should upgrade to 11.3 and switch to the 2.0 API. No concrete technical experience, although we had a good look at the new API and found it very promising. But first Ansible iocage integration. For us there's a strong business case for that, so toying with FreeNAS has been shelved for the time being.

Kind regards,
Patrick
 

Rhaido

Cadet
Joined
Jun 19, 2018
Messages
7
Unfortunately, at least at this moment of time, upgrade to 11.3 is not an option - tried it and our AD<->UCS integration did not take off; in addition new UI returned very strange error codes when trying to re-enter domain password. 11-STABLE to 11.2 with old UI was flawless and worked "like a charm" - so we are sticking with it for a while.
Am I right, that amount of v2.0 API adopters is very close to 0 and basically, everybody is still using "tried and true" v1.0 API?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Sorry, I don't have a clue. We are not using the API at all but should we ever start, we would go 2.0 ...
 

nassarmu

Cadet
Joined
Mar 26, 2020
Messages
1
Did you ever figure this out? it appears that RESTful APIv2 does not support nested datasets in the same way that APIv1 did and i have yet to figure how it would.
 
Joined
Feb 28, 2017
Messages
5
With the new v2.0 API a path such as "tank/test" needs to have the slash escaped with %2F in order to be used, so the curl command would become:

Code:
$ curl -u 'user:password' 'https://storage.local/api/v2.0/pool/dataset/id/tank%2Ftest'


I think you will find that works as expected.
:D
 

bociankruk

Cadet
Joined
Oct 13, 2019
Messages
4
Hi,
@Rhaido, I'm just curios did you managed to complete some of the modules?
I would love to configure FreeNAS (and now TrueNAS) as a code, not from UI, but I don't like to recreate wheel :)
 

tmueko

Explorer
Joined
Jun 5, 2012
Messages
82
@Rhaido: Something new on this modules?
By the way: We had no troubles with 11.3 or 12.2 at UCS-AD!
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
Guys, this is a module for a depricated version of FreeNAS, combined with a depricated API.
Anno 2021, it's not relevant anymore.
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
An ansible-module for TrueNAS would be a great idea!
This isn't about a general ansible module, it was about an ansible module for just an old version and old API. It won't be compatible.

Please notice that this is the "legacy" forum. It really is not worth spending time crafting tools for API v1 and 11.2.
 
Top