'What do the &,<<, * mean in this database.yml file?

Up until now I have only used database.yml with each parameter called out explicitly, in the file below it uses some characters I do not understand. What does each line and symbol(&, *, <<) mean? How do I read this file?

development: &default
  adapter: postgresql
  database: dev_development

test: &test
  <<: *default
  database: test_test


cucumber:
  <<: *test

production:
  <<: *default
  database: test_production


Solution 1:[1]

&default means you're labeling this set of attributes with some name for later use

<<: *default means you're including all attributes from group labeled as default

Solution 2:[2]

These represent node references (*) and associative array merges (<<) that refer to a node labeled with an anchor (&) tag -- wikipedia

Try it out yourself online.

Solution 3:[3]

They are a way to reference environments without having to repeat the same settings over and over (DRY it up).

test: &test
  <<: *default

&test creates a reference to those specific settings.

<<: *default says use the default settings for the test

cucumber:
  <<: *test

So now we know that for cucumber we want to use the settings from test.

Solution 4:[4]

In simple words, this notion resembles with the base and derived class.

In base class template, you mention all the common details with '&', which means it can be used to expand the other yaml section that needs these fields. Now when you create another section that is superset of config values of this 'base class' type structure, you use the '*' along with the base class anchor (i.e. the one started with '&'). You use '<<:' as yaml notion for actually placing the 'base class' section, that you can override later.

vsm:
  stub_nsx_mgr: &MGR_CTRL_STUB
    username: ADMIN
    password: $DEFAULT_PASSWORD
    deployment: ovf
    build: $PR_BUILD
    vmnics:
      - network: $MANAGEMENT_NETWORK_0
    vc: vc_0
    ovf_options:
      - --diskMode=$DISKMODE
      - --deploymentOption=$DEPLOYMENT_OPTION
$MGR_0:
    <<: *MGR_CTRL_STUB
    ovf_path_regex: 'appliance.*\.ovf'
    ovf_options:
      - --diskMode=$DISKMODE
      - --deploymentOption=$DEPLOYMENT_OPTION
$CTRL_0:
    <<: *MGR_CTRL_STUB
    ovf_options:
      - --diskMode=$DISKMODE
      - --allowExtraConfig
$CTRL_1:
    *MGR_CTRL_STUB

But, if you do not want to override the extended fields, you can skip '<<:'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 keymone
Solution 2 Sam Ruby
Solution 3 thenengah
Solution 4