Hi,
I have a simple playbook that takes an IP address from the input file and update this IP including hostname under /etc/hosts.
The problem is that in the input file the IP is written with subnet – 1.1.1.1/24
While I need only the IP 1.1.1.1
Playbook :
- hosts: localhost
become: true
any_errors_fatal: true
gather_facts: False
vars_files:
- /opt/ input-file.yml
tasks:
- name: Update server etc/host with response ip
lineinfile:
path: /etc/hosts
line: “{{ lb_ext_ip }} hdfs”
state: present
backup: yes
Result in /etc/hosts
1.1.1.1/24 hdfs
Required results:
1.1.1.1 hdfs