Yaml anchors: what is wrong?

Could you give me a good doc for this?
So far I only read these:
http://thomasloven.com/blog/2018/08/YAML-For-Nonprogrammers/
http://blogs.perl.org/users/tinita/2019/05/reusing-data-with-yaml-anchors-aliases-and-merge-keys.html

There really isn’t a good single resource, just google yaml anchors and click through links.

But be warned, you need a firm understanding of yaml

To clarify further with your example. Your configuration is this:

entities: &entities
- entity: aaa
  name: bbb

So yaml only sees this in the anchor *entities:

entity: aaa
name: bbb

if you were to merge them the way they are supposed to be merged, it would look like this:

entities:
- <<: *entities
  entity: ccc
  name: ddd

which WILL produce errors because this is not valid:

- entity: aaa
  name: bbb
  entity: ccc
  name: ddd

But you are not doing that, you’re providing this as your configuration (which is valid)

entities:
- <<: *entities
- entity: ccc
  name: ddd

Petro, thank you very much for explanations!

I found a way to add a new entity to the list (my original task):

type: vertical-stack
cards:
  - &my_card
    type: entities 
    title: Some title
    state_color: true
    entities: &ref_1
      - entity: binary_sensor.updater
        name: Updater-1
    style: |
      ha-card {
        background: green;
      }

  - <<: *my_card
    entities: &ref_2
      - entity: binary_sensor.updater
        name: Updater-2
      - <<: *ref_1

  - <<: *my_card
    entities: &ref_3
      - entity: binary_sensor.updater
        name: Updater-3
      - <<: *ref_2
      - <<: *ref_1

  - <<: *my_card
    entities: &ref_4
      - entity: binary_sensor.updater
        name: Updater-4
      - <<: *ref_3
      - <<: *ref_2
      - <<: *ref_1


Each new card inherits the card’s properties (like title, style) & entities.
But every new entity must be added to the top of the list - that is why the order is reverse (4,3,2,1).

I think this is more elegant:

type: vertical-stack
cards:
  - &my_card
    type: entities 
    title: Some title
    state_color: true
    entities: 
      - &ref_1
        entity: binary_sensor.updater
        name: Updater-1
    style: |
      ha-card {
        background: green;
      }

  - <<: *my_card
    entities: 
      - *ref_1
      - &ref_2
        entity: binary_sensor.updater
        name: Updater-2

  - <<: *my_card
    entities:
      - *ref_1
      - *ref_2
      - &ref_3
        entity: binary_sensor.updater
        name: Updater-3

  - <<: *my_card
    entities: 
      - *ref_1
      - *ref_2
      - *ref_3
      - &ref_4
        entity: binary_sensor.updater
        name: Updater-4