---
- name: 1. Node add Label (worker1)
  kubernetes.core.k8s:
    apply: yes
    definition:
      apiversion: v1
      kind: Node
      metadata:
        name: "{{ item }}"
        labels:
          cmoa: worker1
  with_items: 
  - "{{ ansible_hostname }}"
  when: ansible_default_ipv4.address in groups.worker1

- name: 2. Node add Label (worker2)
  kubernetes.core.k8s:
    definition:
      apiversion: v1
      kind: Node
      metadata:
        name: "{{ item }}"
        labels:
          cmoa: worker2
  with_items: 
  - "{{ ansible_hostname }}"
  when: ansible_default_ipv4.address in groups.worker2
