access other group values to current group during playbook execution

Im running a playbook, inside i have multiple tasks. Those tasks need to run based on hostgroups and it will generate variable's. now i need to access other group vars to current group tasks.

- name: storewriterid in bootstrapgrp
    module: lineinfile
    path: edjplaybooks/vars/main.yml
    insertafter: EOF
    line: "WRITER_NODE_ID: {{ WRITER_NODE_ID.stdout }}"
  when: "'writer' in group_names"
- name: bootstrap address
  become: yes
  become_user: edjruntime
  shell: |
       ip=$(wget -q -O -
       edjx node gen-env {{ CERTIFICATES }}/private.pem -i $ip -o runtime/.env -w "{{ WRITER_NODE_ID }}" "{{ flags }}"
  when: "'bootstrap' in group_names"

im trying print other(writer) group vars in bootstrap grpvars but still it is taking group condition. but if it run same task its picking from bootstrap grousvars(may be appending var from first time run). please ping me the solution