Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when i use Verbose=true in playbookOptions, parsejson fail invalid character 'a' looking for beginning of value #110

Closed
YXY-121 opened this issue Aug 31, 2022 · 7 comments
Labels
bug Something isn't working v2.0.0

Comments

@YXY-121
Copy link

YXY-121 commented Aug 31, 2022

when i use “Verbose: true ” in playbook.AnsiblePlaybookOptions,output could not be parsed to result.AnsiblePlaybookJSONResult struct and err:invalid character 'a' looking for beginning of value
but if i set “Verbose: false ”,the json parse ok.
can u help me?thank u very much!

    ansiblePlaybookConnectionOptions := &options.AnsibleConnectionOptions{
	Connection: "local",
}
ansiblePlaybookOptions := &playbook.AnsiblePlaybookOptions{
	Inventory: "127.0.0.1,", //
	Verbose:   true,   
}

playbook := &playbook.AnsiblePlaybookCmd{
	Exec:              execute,
	Playbooks:         []string{"site1.yml"}, 
	ConnectionOptions: ansiblePlaybookConnectionOptions,
	Options:           ansiblePlaybookOptions,
	StdoutCallback:    "json",
}

err := playbook.Run(context.TODO())
if err != nil {
	panic(err)
}
var res *results.AnsiblePlaybookJSONResults

   res, err = results.ParseJSONResultsStream(io.Reader(buff))
if err != nil {
	panic(err)// this wil show"invalid character 'a' looking for beginning of value"
}
@YXY-121
Copy link
Author

YXY-121 commented Aug 31, 2022

the version that i use is the lastest

@YXY-121
Copy link
Author

YXY-121 commented Aug 31, 2022

oh i know the reason. when use verbose,the buff not only contains the json struct value,the buff contains something detail about the playbook ,they are not json struct

@apenella
Copy link
Owner

apenella commented Sep 1, 2022

Hi @YXY-121
Thanks for raising that issue, I was not aware about it.
The reason is exactly what you said :)

I would like to think a solution in depth, no just to solve that issue but how to set some restrictions depending on the stdout callback.

@apenella apenella added bug Something isn't working v1.2.0 labels Sep 1, 2022
@YXY-121
Copy link
Author

YXY-121 commented Sep 7, 2022

hi @apenella
well i am interested in it. i would like to find out the solution with u

@apenella
Copy link
Owner

Hi @YXY-121
I want to add some breaking changes to the Executor interface which will facilitate introducing the changes I want to add to solve that issue. For that reason, I will add it to version 2.0.0.

I am about to start working on 1.2.0 where I want to release a few minor features, and as soon as I release them I am going to start working on 2.0.0.

@apenella
Copy link
Owner

hi @YXY-121!

I already have the fix for the issue you raised. It will be released in the coming days.
9a384e5

Thanks!

@apenella
Copy link
Owner

The fix is available in https://github.com/apenella/go-ansible/releases/tag/v2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.0.0
Projects
None yet
Development

No branches or pull requests

2 participants