I need help stripping the " " from around the joined list.
vars:
sox_files:
- '/etc/login.defs'
- '/etc/default/useradd'
- '/etc/passwd'
- '/etc/shadow'
- '/etc/group'
- '/etc/hosts'
- '/etc/audit/auditd.conf'
- name: Join the list of strings
debug:
msg: "{{ sox_files | join(' ') }}"
tags: bug
- name: Compress into archive
ansible.builtin.shell:
cmd: |
zip /tmp/sox/audit.zip "{{ sox_files | join(' ') }}"
When I run the playbook the zip command fails because the list of files is encapsulated in quotes.
TASK [Join the list of strings] *************************************************************************************************************************************************************
ok: [testhost] => {
“msg”: “/etc/login.defs /etc/default/useradd /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/audit/auditd.conf”
}
TASK [Compress into archive] ****************************************************************************************************************************************************************
fatal: [testhost]: FAILED! => {“changed”: true, “cmd”: “zip /tmp/sox/audit.zip "/etc/login.defs /etc/default/useradd /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/audit/auditd.conf"\n”, “delta”: “0:00:00.005151”, “end”: “2024-10-24 18:00:48.138459”, “msg”: “non-zero return code”, “rc”: 12, “start”: “2024-10-24 18:00:48.133308”, “stderr”: “”, “stderr_lines”: , “stdout”: “\tzip warning: name not matched: /etc/login.defs /etc/default/useradd /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/audit/auditd.conf\n\nzip error: Nothing to do! (/tmp/sox/audit.zip)”, “stdout_lines”: [“\tzip warning: name not matched: /etc/login.defs /etc/default/useradd /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/audit/auditd.conf”, “”, “zip error: Nothing to do! (/tmp/sox/audit.zip)”]}