skibish / ddns

Personal DDNS client with Digital Ocean Networking DNS as backend.
MIT License
254 stars 24 forks source link

docker in unraid can't find expected key #28

Closed wwray closed 3 years ago

wwray commented 3 years ago

Hi there, I'm trying to use your docker implementation in unraid and I'm receiving an error when I try to start it.

time="2021-06-27T03:39:09Z" level=fatal msg="yaml: line 33: did not find expected key"

It is definitely seeing the .yaml file. I've tried putting my public ip in the data: field to no avail. I'm trying to add a subdomain home.domain.com

I have created an api key and put it in the ddns.yml file.

Any help would be appreciated, thanks!

skibish commented 3 years ago

Hi @wwray,

Could you please share how you setup a yaml file?

Try the following configuration:

domains:
  domain.com:
  - type: "A"
    name: "home"
wwray commented 3 years ago

Hi I created it in notepad++ and moved it to the server. I just checked and made sure it's in unix encoding.

That's the configuration I have .

List of domains and their records to update.

domains: wraynet.com:

More details about the fields can be found here:

# https://developers.digitalocean.com/documentation/v2/#create-a-new-domain-record

Thanks for looking into this for me!

On Sat, Jun 26, 2021 at 11:54 PM Sergey Kibish @.***> wrote:

Hi @wwray https://github.com/wwray,

Could you please share how you setup a yaml file?

Try the following configuration:

domains: domain.com:

  • type: "A" name: "home"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/skibish/ddns/issues/28#issuecomment-869096041, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL3XXDUJYJEZQQGUSIPTYN3TU2OJDANCNFSM47L7IBKQ .

skibish commented 3 years ago

Hi @wwray ,

Thanks!

But unfortunately, this is not the full yaml file. May I ask you to share full yaml file (without secrets, better via GitHub to preserve spacing and highlighting)?

In first message error says that error is on line 33. My assumption is that maybe some spacing is broken. I want to see what is on line 33 and around.

For an experiment you can replace your current file with the following configuration and see if it works:

token: "<your Digital Ocean token>"

domains:
  wraynet.com:
  - type: "A"
    name: "home"
wwray commented 3 years ago

Here you go! sorry I misunderstood, thanks again for your help.

ddns.yml.txt

wwray commented 3 years ago

when I use the config provided I get a different error

time="2021-06-27T13:24:10Z" level=fatal msg="yaml: unmarshal errors:
line 8: cannot unmarshal !!map into []string"
skibish commented 3 years ago

I've found the following issues:

  1. data key had space in front and this led to error on line 31
  2. because YAML is an interesting format and not JSON, lines with priority, port etc. will be parsed incorrectly (commas in the end of lines
--- a/ddns.original.yml
+++ b/ddns.fixed.yml
@@ -28,15 +28,10 @@ domains:
     # Supports Go template engine.
     # Additional keys can be set in "params" block below.

-     data: "107.179.128.81"
+    data: "107.179.128.81"

     # By default, 1800 seconds (5 minutes).
     ttl: "1800"
- "priority": null,
-  "port": null,
-  "weight": null,
-  "flags": null,
-  "tag": null
 # By default, params is empty.
 params:

I've adjusted the file (see attached) and seems like it's working now as expected.

ddns.fixed.yml.txt

wwray commented 3 years ago

I downloaded your file, and pasted in my token in but am still getting an error

time="2021-06-27T20:32:24Z" level=fatal msg="yaml: unmarshal errors: line 22: cannot unmarshal !!map into []string"

skibish commented 3 years ago

Please check what you have on line 22

wwray commented 3 years ago

attached file. There's 3 spaces before the domain, thanks for helping out.

ddns.yml.txt

wwray commented 3 years ago

Ok so I finally got it to validate on a .yaml validator and I'm still having the unmarshal error on the 1st domain entry. I understand yaml a lot better than I did this morning. Pretty neat! ddns.yml.txt

time="2021-06-28T15:10:50Z" level=fatal msg="yaml: unmarshal errors: line 4: cannot unmarshal !!map into []string"

skibish commented 3 years ago

Happy to hear that!

What version of ddns are you using?

ddns -v in old one and ddns -ver in new one

wwray commented 3 years ago

I can't get it to start because of the error so can't tell ya. I am using this docker https://hub.docker.com/r/ronnieroller/ddns

skibish commented 3 years ago

Seems like you are using a fork :)

Try this one: https://hub.docker.com/r/skibish/ddns

wwray commented 3 years ago

My deepest apologies @skibish ! I didn't realize I was using a fork. I would have been very sad if it had just worked, but now I'm getting the error below when starting the docker using the config file I provided above.

time="2021-06-28T16:01:54Z" level=fatal msg="failed to read configuration file: While parsing config: yaml: control characters are not allowed"

skibish commented 3 years ago

Remove dashes on the first line, I think this should help

On Mon, Jun 28, 2021, 19:04 wwray @.***> wrote:

My deepest apologies @skibish https://github.com/skibish ! I didn't realize I was using a fork. I would have been very sad if it had just worked, but now I'm getting the error below when starting the docker using the config file I provided above.

time="2021-06-28T16:01:54Z" level=fatal msg="failed to read configuration file: While parsing config: yaml: control characters are not allowed"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/skibish/ddns/issues/28#issuecomment-869810439, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJZWK2KF4UI2KC2W55STFDTVCMRTANCNFSM47L7IBKQ .

wwray commented 3 years ago

Ok well, I can't get the container that I'm using to even register the existence of the .ddns.yml file. If I delete it I get the exact same error. I loaded it up using docker run command in your help docs and I got:

Status: Downloaded newer image for skibish/ddns:latest time="2021-06-28T17:29:52Z" level=debug msg="using the following configuration file: /config/.ddns.yml" time="2021-06-28T17:29:52Z" level=debug msg="initializing ip" time="2021-06-28T17:29:53Z" level=info msg="current ip is <deleted>" time="2021-06-28T17:29:53Z" level=debug msg="syncing dns records" failed to sync dns records: failed to create a record for the domain wraynet.com: unexpected response with status code 422

Which is probably what is supposed to happen, but even if I get the container working I'll then have to deal with the DO error. I'm gonna sit on it and see if I want to try some other way. You can close this ticket since I suspect it's not a problem with your software, thanks for all your help!

skibish commented 3 years ago

Yep, it's a good sign that configuration file is valid and application was able to read it.

I think the issue is now that you specify multiple arrays which all are invalid.

    - 
      type: A
    - 
      name: home
    - 
      data: "{{.IP}}"
    - 
      ttl: "1800"

Each dash means a new array element and in the end they are all wrong because first one has only type: A which is not enough to create a record, second one a name: home which is also not enough because it waits for type, etc.

I should be like this:

domains:
  wraynet.com: 
    - type: A
      name: home
      data: "{{.IP}}"
      ttl: "1800"