Skip to content

[Bug] zos_lineinfile when using backrefs adds trailing spaces #2371

@darnowak

Description

@darnowak

Is there an existing issue for this?

  • There are no existing issues.

Bug description

I am getting unneeded trailing spaces when using zos_lineinfiles with backrefs: true to modify line.
As an example I tested the following task to add # before the line starting with B:

- name: test
      zos_lineinfile:
        src: /tmp/test22.txt
        regexp: ^(B.+)$
        state: present
        line: '# \1'
        backrefs: true
      register: result

test22.txt is a simple test file IBM-1047 encoded.

A 11
B 22
C 33
D 44

After successful running the playbook, the file was modified as follows:

A 11
# B 22


C 33
D 44

IBM z/OS Ansible core Version

v1.15.0

IBM Z Open Automation Utilities

v1.3.6

IBM Enterprise Python

v3.13.x

ansible-version

v2.17.x

z/OS version

v2.5

Ansible module

zos_lineinfile

Playbook verbosity output.

ok: [xxx] => {
"msg": {
"backup_name": "",
"changed": true,
"cmd": "dsedhelper -d -c IBM-1047 -r /^(B.+)$/c\# \1/$ /tmp/test22.txt ",
"failed": false,
"found": 1,
"return_content": "{"cmd": "dsedhelper -d -c IBM-1047 -r /^(B.+)$/c\\# \1/$ /tmp/test22.txt ", "found": 1, "changed": true}",
"stdout": "{"cmd": "dsedhelper -d -c IBM-1047 -r /^(B.+)$/c\\# \1/$ /tmp/test22.txt ", "found": 1, "changed": true}",
"stdout_lines": [
"{"cmd": "dsedhelper -d -c IBM-1047 -r /^(B.+)$/c\\# \1/$ /tmp/test22.txt ", "found": 1, "changed": true}"
]
}
}

Ansible configuration.

Contents of the inventory

Contents of group_vars or host_vars

Metadata

Metadata

Assignees

Labels

BugSomething isn't working as designed.Needs TriageIssue need assessment by a team member(s)Waiting on dependencyThis issue requires a change on a dependency out of scope for this team but tracked by this team

Type

No type

Projects

Status

⚙ Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions