Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update faq.rst #2244

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Update faq.rst #2244

wants to merge 1 commit into from

Conversation

tdram
Copy link

@tdram tdram commented Dec 3, 2024

Using backup_file gives error as the name is now changed to backup in newer Ansible versions.

Please update.

Using `backup_file` gives error as the filename is now changed to `backup` in newer Ansible versions.

Please update.
@ansible-documentation-bot ansible-documentation-bot bot added the new_contributor This PR is the first contribution by a new community member. label Dec 3, 2024
@ansible-documentation-bot
Copy link
Contributor

Thanks for your Ansible docs contribution! We talk about Ansible documentation on Matrix at #docs:ansible.im if you ever want to join us and chat about the docs! We meet on Matrix every Tuesday. See the Ansible calendar for meeting details. We welcome additions to our weekly agenda items too. You can add the dawgs-meeting tag to a forum topic to bring it up at the next meeting.

@samccann
Copy link
Contributor

@mattclay - did backup_file change? I still see it here

@samccann samccann added the techreview needs technical review label Mar 20, 2025
@mattclay
Copy link
Member

@samccann No, it hasn't changed. I just tested the devel branch and the result still contains backup_file.

@tdram
Copy link
Author

tdram commented Mar 22, 2025

I still see it as backup

ansible --version ansible [core 2.17.9]

TASK [update : Debug] *************************************************************************************************************************************************** ok: [10.100.12.2] => { "updated": { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3.11" }, "backup": "/home/raw/file.txt.3876448.2025-03-22@07:58:37~", "changed": true, "diff": [

@mattclay
Copy link
Member

@tdram Can you provide a complete reproducer for what you're seeing?

@tdram
Copy link
Author

tdram commented Mar 24, 2025

Hi,

Please find:

  1. Playbook
  hosts: local
  remote_user: root
  tasks:
    - name: Add this line in the file
      ansible.builtin.lineinfile:
        backup: true
        path: /root/docs/file.txt
        line: "Hello"
      register: output
    - name: Debug
      ansible.builtin.debug:
        var: output

Output:


TASK [Gathering Facts] ******************************************************************************************************************************************************
ok: [10.100.12.2]

TASK [Add this line in the file] ********************************************************************************************************************************************
changed: [10.100.12.2]

TASK [Debug] ****************************************************************************************************************************************************************
ok: [10.100.12.2] => {
    "output": {
        "backup": "/root/docs/file.txt.3910784.2025-03-24@22:15:48~",
        "changed": true,
        "diff": [
            {
                "after": "",
                "after_header": "/root/docs/file.txt (content)",
                "before": "",
                "before_header": "/root/docs/file.txt (content)"
            },
            {
                "after_header": "/root/docs/file.txt (file attributes)",
                "before_header": "/root/docs/file.txt (file attributes)"
            }
        ],
        "failed": false,
        "msg": "line added"
    }
}

PLAY RECAP ******************************************************************************************************************************************************************
10.100.12.2            : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

When I tried to implement this with block and rescue, I used {{ updated['backup_file'] }}" as documented from here and it said backup_file is not defined and hence I debugged and used backup option instead of backup_file and it worked.

@mattclay
Copy link
Member

@tdram The example being updated in this PR is for the template module, not the lineinfile module. They have different return values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new_contributor This PR is the first contribution by a new community member. techreview needs technical review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants