Hi@akhtar,
You can update your file using lineinfile module. This module can update the line in a file. But if you want to update multiple lines you need to use the item keyword in your code as shown below.
- name: Update hosts
lineinfile:
path: /etc/hosts
state: present
line: "{{ item }}"
with_items:
- '192.168.0.108 K8_slave'
- '192.168.0.105 K8_master'