Hello friends!
I would like a help you about a problem when I attempt to run a playbook in Ansible.
I’ve created a task in my playbook to add IP_address inside a file called hosts. But I’m facing a problem. I need to put the ip_address on the end of string K8_MASTER_NODE_IP= But searching the documentation Ansible I didn’t find it, but the only way found was until now is to put below the string, but in this way it doesn’t work for me. Someone, could me help me about this issue?
This is my script I have created.
- name: Adicionando o IP privado da instancia criado ao arquivo /installk8_s/hosts
ansible.builtin.lineinfile:
path: "/home/lpi1/Ansible/descomplicando_ansible/projeto_k8s_cluster/install_k8s/hosts"
regexp: "{{ item.private_ip_address }}"
firstmatch: true
insertafter: "[K8_MASTER_NODE_IP=]"
line: "{{ item.private_ip_address }}"
with_items: "{{ ec2.instances }}"
Thanks in advance.