diff --git a/docs/docsite/rst/reference_appendices/common_return_values.rst b/docs/docsite/rst/reference_appendices/common_return_values.rst index 04f57ac3d6..7ef8c69e95 100644 --- a/docs/docsite/rst/reference_appendices/common_return_values.rst +++ b/docs/docsite/rst/reference_appendices/common_return_values.rst @@ -18,7 +18,7 @@ Common backup_file ``````````` -For those modules that implement `backup=no|yes` when manipulating files, a path to the backup file created. +For those modules that implement `backup=no|yes` when manipulating files, a path to the backup file created if original file was changed. .. code-block:: console diff --git a/docs/docsite/rst/reference_appendices/faq.rst b/docs/docsite/rst/reference_appendices/faq.rst index 4555570174..690b588678 100644 --- a/docs/docsite/rst/reference_appendices/faq.rst +++ b/docs/docsite/rst/reference_appendices/faq.rst @@ -826,11 +826,11 @@ and backups, which most file based modules also support: .. code-block:: yaml - - name: update config and backout if validation fails + - name: maintain config and backout if validation after change fails block: - - name: do the actual update, works with copy, lineinfile and any action that allows for `backup`. - template: src=template.j2 dest=/x/y/z backup=yes moreoptions=stuff - register: updated + - name: do the actual update, works with copy, lineinfile and any action that allows for `backup`. + template: src=template.j2 dest=/x/y/z backup=yes moreoptions=stuff + register: updated - name: run validation, this will change a lot as needed. We assume it returns an error when not passing, use `failed_when` if otherwise. shell: run_validation_commmand @@ -838,17 +838,20 @@ and backups, which most file based modules also support: become_user: requiredbyapp environment: WEIRD_REQUIREMENT: 1 + when: updated is changed rescue: - name: restore backup file to original, in the hope the previous configuration was working. copy: remote_src: true dest: /x/y/z src: "{{ updated['backup_file'] }}" + when: updated is changed always: - name: We choose to always delete backup, but could copy or move, or only delete in rescue. file: path: "{{ updated['backup_file'] }}" state: absent + when: updated is changed .. _jinja2_faqs: