Hi
I’m using lineinfile to include new value inside a file
*Original line *
Kafka-list= kafka1:9092;kafka2:9092;kafka3:9092
I need to replace the value with parameters that are managed inside a
configuration – I need to include all server hostname that are under
kafka_server_details section
The line format should be
<kafka-server-hostname>:<kafka-port>;<kafka-server-hostname>:<kafka-port>;
……
The list can include 1 or more servers
*Configuration File : *
kafka_server_details:
- {ip: 1.1.1.1 , hostname: kafka1.cluster1.com }
- {ip: 1.1.1.2 , hostname: kafka2.cluster1.com }
- {ip: 1.1.1.3 , hostname: kafka3.cluster1.com }
kafka_port: 9092
*Playbook *
- name: Update flow.properties file
lineinfile:
path: /opt/flow.properties
regexp: "{{ item.from }}"
line: "{{ item.replace_with }}"
with_items:
- { from: lab=, replace_with: lab=1 }
- { from: Kafka-list=, replace_with: "Kafka-list= {{
kafka_server_details.hostname }}:{{ kafka_port }} ; {{
kafka_server_details.hostname }}:{{ kafka_port }} ; {{
kafka_server_details.hostname }}:{{ kafka_port }} ; " }
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5160269d-f999-4aef-86e3-45fe73995f39n%40googlegroups.com.