0

I plan to add few hundred of lines in some files using Ansible. My idea is to put all those lines in a file and then use a variable inside the playbook.

This is the first part.

The second one is that those variables (in my case some URLs) will be just part from a static text. For example:

Playbook:

- name: Adding ACL
lineinfile:
  path: /configs/haproxy.conf
  insertafter: \#\ Define\ hosts
  line: '    acl host_{{ URL }} hdr(host) -i {{ URL }}'

Any ideas how can I take the URL variable from another file, file that will contain hundred of entries??

razvanli
  • 1
  • 1
  • 2
    It will likely be better if you use a `template` instead of `lineinfile`, and manage the entire file's contents. – Michael Hampton Aug 22 '18 at 13:27
  • @MichaelHampton Thank you very much for your answer. Honestly I didn't know about templates, but I will check it in the Ansible doc. – razvanli Aug 22 '18 at 15:05

0 Answers0