I found this blockinfile issue, where a user suggested adding a number after the \"|\" in the \"block: |\" line, but gives a syntax error. Basically, I want to use blockinfile m
I was trying to use YAML feature called "Block Indentation Indicator" from the other answer, but it did not work for me (ansible 2.9.10.post0). Ugly, but working solution is:
- name: docker-compose.yml - service has links to another container
lineinfile:
path: "/path/to/docker-compose.yml"
insertafter: "service:"
line: " links:\n - apache2:proxy.example.com\n - apache2:proxy2.example.com"
You basically need to put as many spaces as necessary before elements. And use \n for newlines.