Skip to content

Friendly fail on duplicate keys without yaml exception #266

Description

@pythoninja

Consider this hosts.yaml:

provider:
  hosts:
    private-host-01:
      ansible_host: 127.0.0.1
      ansible_user: root
      ansible_password: 
      _meta:
        _auth_type: IdentityAgent
        _auth_path: ~/.1password/agent.sock
        _aliases: []

provider:
  hosts:
    my-private-host-01:
      ansible_host: 127.0.01
      ansible_user: root
      ansible_password: 
      _meta:
        _auth_type: IdentityAgent
        _auth_path: ~/.1password/agent.sock
        _aliases: []

sshgen will fail with a long exception like:

  File "/home/user/.cache/uv/archive-v0/gPnlXI4ewKabvm2j/lib/python3.14/site-packages/ruamel/yaml/constructor.py", line 281, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugBug or uncommented behavior

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions