--- - name: remove IPv6 address for localhost shell: sed -i '/::1/s/localhost //' /etc/hosts - name: add IPv4 address for localhost shell: sed -i '/127.0.0.1/s/$/ localhost/' /etc/hosts