use ansible module copy instead of template for small files

In order to adapt files and their content on target servers I am used to using ansible copy module. owever, if you only have a small file with just one or a few lines, you can do so without creating a jinja2 template.

Here is the little cheat: Just use ansible’s copy module.

– copy:
  content: “env: {{ my_environment_var }}”
  dest: /app/env.cfg

That’s it. This creates a file with variable content, without need to create a template.

Leave a Reply

Your email address will not be published. Required fields are marked *