From 3e003b10fadaef57758dfc549f4ca6d094c7fa66 Mon Sep 17 00:00:00 2001 From: Craig Francis Date: Tue, 7 Feb 2017 13:57:49 +0000 Subject: [PATCH] =?UTF-8?q?Reminder=20that=20lookup(=E2=80=98file=E2=80=99?= =?UTF-8?q?)=20can=20be=20used=20(#20649)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Reminder that lookup(‘file’) can be used Sometimes the block of text does not easily fit into a playbook, so this acts as a reminder (or a prompt for anyone who hasn't used this before) that the content could be stored in an separate file. I've also included `backup: yes` as I think this is a good example of where a backup might be needed. * Correct the not so "smart quotes" * Update blockinfile.py Replace – with an an ASCII - --- lib/ansible/modules/files/blockinfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/files/blockinfile.py b/lib/ansible/modules/files/blockinfile.py index e243c1352e..fd527be560 100755 --- a/lib/ansible/modules/files/blockinfile.py +++ b/lib/ansible/modules/files/blockinfile.py @@ -126,6 +126,12 @@ EXAMPLES = r""" address 192.0.2.23 netmask 255.255.255.0 +- name: insert/update configuration using a local file + blockinfile: + block: "{{ lookup('file', './local/ssh_config') }}" + dest: "/etc/ssh/ssh_config" + backup: yes + - name: insert/update HTML surrounded by custom markers after line blockinfile: path: /var/www/html/index.html