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

Documented config format invalid #1081

Closed
bkahlerventer opened this issue Jul 9, 2024 · 4 comments · Fixed by #1082
Closed

Documented config format invalid #1081

bkahlerventer opened this issue Jul 9, 2024 · 4 comments · Fixed by #1082

Comments

@bkahlerventer
Copy link

bkahlerventer commented Jul 9, 2024

no matter the content of the config file for receptor, I always get:

$ receptor --config foo.yml 
Error: error loading config file: config format invalid: item has multiple names
$ cat foo.yml
---
- node:
  id: foo

- control-service:
  service: control
  filename: /tmp/foo.sock

- tcp-peer:
  address: localhost:2222
  redial: true

- log-level: debug

$ 
@bkahlerventer
Copy link
Author

when config file is indented with 4 spaces instead of 2 the file loads, no problem. if indentation is done with 2 spaces, config refuses to load with error.

@resoluteCoder
Copy link
Contributor

I found success this way

- node:
    id: foo

- control-service:
    service: control
    filename: /tmp/foo.sock

- tcp-peer:
    address: localhost:2222
    redial: true

- log-level: debug

The way the current config works is its using yaml-like syntax so there are some strange behaviors with it.

I have a PR out right now to use traditional yaml syntax for our configuations here: #1043

@kurokobo
Copy link
Contributor

The current configuration file is valid YAML, not just "YAML-like" syntax, I think.
If we convert the YAML to JSON, we should be able to understand the difference in meaning caused by the indentation.

This is invalid configuration and JSONed version:

- control-service:
  service: control
  filename: /tmp/foo.sock
[
  {
    "control-service": null,
    "service": "control",
    "filename": "/tmp/foo.sock"
  }
]

This is valid configuration and JSONed version:

- control-service:
    service: control
    filename: /tmp/foo.sock
[
  {
    "control-service": {
      "service": "control",
      "filename": "/tmp/foo.sock"
    }
  }
]

In the invalid configuration, all three keys are at the same level.
In the valid configuration, service and filename are child elements of the control-service key.

Since service and filename are settings related to control-service, it is more appropriate for them to be child elements.

However, the indentation in the example in the documentation is indeed incorrect and should be fixed: https://ansible.readthedocs.io/projects/receptor/en/latest/getting_started_guide/creating_a_basic_network.html

@bkahlerventer
Copy link
Author

I will check again doing indentation with 2 spaces, but initial tests show it MUST BE 4 spaces or errors show up.

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

Successfully merging a pull request may close this issue.

3 participants