ansible / receptor

Project Receptor is a flexible multi-service relayer with remote execution and orchestration capabilities linking controllers with executors across a mesh of nodes.
Other
158 stars 77 forks source link

Documented config format invalid #1081

Closed bkahlerventer closed 5 days ago

bkahlerventer commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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: https://github.com/ansible/receptor/pull/1043

kurokobo commented 2 weeks ago

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 commented 6 days ago

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