Link state of different devices

This is my first post and I am sure this is super simple but I am just trying to get started.

I would like to “link” the state of one device to actions for another. e.g. when light X turns ON, turn light Y ON as well. When light X turns OFF turn Y OFF as well. I know I can do it with 2 automation rules but it seems that there would be a better way.

COPY SWITCH

This example shows a switch that copies another switch.

switch:
  - platform: template
    switches:
      copy:
        value_template: "{{ is_state('switch.source', 'on') }}"
        turn_on:
          service: switch.turn_on
          entity_id: switch.source
        turn_off:
          service: switch.turn_off
          entity_id: switch.source