Issue
Tasks below, When I run the find command on the shell, I get output expected. When I debug it after registering the variable, I also get the output one per line.
When I run these tasks I wrote, I get a mess of output that just won't work no matter where I put the newline.
ansible.builtin.shell:
cmd: find / -xdev \( -perm -4000 -o -perm -2000 \) -type f | awk '{print "-a always,exit -F path=" $1 " -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged" }'
register: ps
- name: Put them into the rules file
ansible.builtin.lineinfile:
path: "/etc/audit/rules.d/audit.rules"
insertafter: EOF
line: "{{ ps.stdout_lines }}"
I've tried adding a newline to the end of the find both inside and outside of the quote but it's getting mashed up somehow.
What is a fix? and why is this not working as is ?
Solution
stdout
is raw output while stdout_lines
is an array that "{ ... }"
converts to a string (without newlines).
Answered By - Allan Wind Answer Checked By - Terry (WPSolving Volunteer)