ansible: ignore _ansible parameters and don't emit trailing newlines
This commit is contained in:
parent
839c072ae2
commit
c8e69b9b7a
1 changed files with 12 additions and 10 deletions
|
@ -19,10 +19,8 @@ end
|
||||||
local function split(str, delimiter)
|
local function split(str, delimiter)
|
||||||
local toks = {}
|
local toks = {}
|
||||||
|
|
||||||
local i = 0
|
|
||||||
for tok in string.gmatch(str, "[^".. delimiter .. "]+") do
|
for tok in string.gmatch(str, "[^".. delimiter .. "]+") do
|
||||||
toks[i] = tok
|
toks[#toks + 1] = tok
|
||||||
i = i + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return toks
|
return toks
|
||||||
|
@ -67,13 +65,17 @@ local function canonicalize(params, spec)
|
||||||
for k,v in pairs(params) do
|
for k,v in pairs(params) do
|
||||||
local desc = findspec(k, spec)
|
local desc = findspec(k, spec)
|
||||||
if not desc then
|
if not desc then
|
||||||
|
-- ignore _ansible parameters
|
||||||
|
if 1 ~= string.find(k, "_ansible") then
|
||||||
return nil, "no such parameter " .. k
|
return nil, "no such parameter " .. k
|
||||||
end
|
end
|
||||||
|
else
|
||||||
if copy[desc['name']] then
|
if copy[desc['name']] then
|
||||||
return nil, "duplicate parameter " .. desc['name']
|
return nil, "duplicate parameter " .. desc['name']
|
||||||
end
|
end
|
||||||
copy[desc['name']] = v
|
copy[desc['name']] = v
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
params = copy
|
params = copy
|
||||||
|
|
||||||
|
@ -346,7 +348,7 @@ function Ansible:fail_json(kwargs)
|
||||||
kwargs['invocations'] = {module_args=self.params}
|
kwargs['invocations'] = {module_args=self.params}
|
||||||
end
|
end
|
||||||
|
|
||||||
print(json.encode(kwargs, {indent=true}))
|
io.write(json.encode(kwargs))
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -359,7 +361,7 @@ function Ansible:exit_json(kwargs)
|
||||||
kwargs['invocations'] = {module_args=self:get_params()}
|
kwargs['invocations'] = {module_args=self:get_params()}
|
||||||
end
|
end
|
||||||
|
|
||||||
print(json.encode(kwargs, {indent=true}))
|
io.write(json.encode(kwargs))
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue