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

Can't override variable value if it's already defined #280

Closed
DrySimon opened this issue Apr 12, 2022 · 4 comments · Fixed by #281
Closed

Can't override variable value if it's already defined #280

DrySimon opened this issue Apr 12, 2022 · 4 comments · Fixed by #281
Labels
documentation Improvements or additions to documentation

Comments

@DrySimon
Copy link

Hi,

I started using ansible-doctor to document my roles, and, following the documentation, I see that I should be able to override an existing variable value, like so:

---
# defaults file for test

# @var testvar:value: "foo"
testvar: "secret"

However, when I run ansible-doctor, I have an error:

[CRITICAL] Unable to merge annotation values:
... too many values to unpack (expected 2) other=['"foo"']

Is this a normal behavior?

Thanks a lot for your answer!

@xoxys xoxys added the documentation Improvements or additions to documentation label Apr 12, 2022
@xoxys
Copy link
Member

xoxys commented Apr 12, 2022

Hi, Thanks for your report. That's because the documentation is wrong here. The value will always be parsed as json/yaml, but therefor you need to flag it with a $.

Example:

## Content after the $ need to be a valid json; this json will be translated to YAML for the generated docs.
## Simple value
# @var demo_role_override: $ "test"
demo_role_override: original

## Complex value
# @var demo_role_override_complex:value: $ {"foo":"bar", "second":"value"}
demo_role_override_complex: {}

Rendered docs output:

demo_role_override: test
demo_role_override_complex:
  foo: bar
  second: value

Quoting matters in this case as well. I'll fix the documentation later.

@xoxys
Copy link
Member

xoxys commented Apr 12, 2022

Hope that helps. If not please let us know.

@DrySimon
Copy link
Author

Hi, sorry for the delay!

Thanks for the insight, it works like a charm!

@xoxys
Copy link
Member

xoxys commented Apr 13, 2022

No worries, thanks for your feedback :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants