parse_hosts_json_file
The parse_hosts_json_file
function takes one argument:
src
: a string that contains the path to the JSON file.
The function returns a table that contains the parsed hosts.
Usage Example
hosts.json
:
[
{
"name": "server1",
"user": "user1",
"address": "10.20.30.41",
"tags": ["webserver", "database"]
},
{
"name": "server2",
"user": "user2",
"address": "10.20.30.42",
"tags": ["webserver"]
},
{
"name": "server3",
"user": "user3",
"address": "10.20.30.43",
"tags": ["database"]
}
]
main.lua
:
local hosts = komandan.parse_hosts_json_file("/path/to/hosts.json")
This will return the table hosts
that contains the parsed hosts.