You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this is a kind of feature request. If you like, i could make a pull request, please tell me.
when i try to use an attribute of the the type hash in my module and the hash data are coming from a play, i always get a kind of a json string.
for example:
if i use:
class Demo < AnsibleModule
attribute :data, Hash
with a play like this:
- name: structured data test
demo:
data:
users:
gaida:
alias: Oliver Gaida
password: myStrongPassword
if i check later the class-type of @data it is always a string, but a hash is expected.
To change this behavior, i have changed the params function in the ansible_module libary to this:
def params
return @params if @params
@params = ActiveSupport::HashWithIndifferentAccess.new
File.open(ARGV[0]) do |fh|
@params.update JSON.parse(fh.read())
end
end
good morning to japan,
this is a kind of feature request. If you like, i could make a pull request, please tell me.
when i try to use an attribute of the the type hash in my module and the hash data are coming from a play, i always get a kind of a json string.
for example:
if i use:
with a play like this:
if i check later the class-type of
@data
it is always a string, but a hash is expected.To change this behavior, i have changed the params function in the ansible_module libary to this:
but than they module has to tell ansible, that it needs the modules parameters in json format. see https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#non-native-want-json-modules
for this to work you have to put
# WANT_JSON
anywhere in the model-file:as a side-affect, there is no need for the shellwords module anymore.
kind regards
Oliver
The text was updated successfully, but these errors were encountered: