Answer the question
In order to leave comments, you need to log in
What is the best way to replace a string in docker-compose.yaml using Ansible?
there is a standard docker-compose.yaml
version: '3.1'
services:
app:
image: test/app
build:
context: ./
dockerfile: Dockerfile
container_name: app
restart: always
ports:
- '8080:8080'
- name: change internal port
lineinfile:
dest: "{{ project_path }}/docker-compose.yaml"
regexp: '8080:8080'
insertafter: '8080:8080'
line: ' - 80:8080'
Answer the question
In order to leave comments, you need to log in
Use jinja2 templates, don't use regexps like this. Then it will be both beautiful and understandable and convenient.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question