As I have written the playbook above, here's the error, which I hope is 
enough for troubleshooting purposes:





















































*<localhost> ESTABLISH LOCAL CONNECTION FOR USER: deploy<localhost> EXEC 
/bin/sh -c 'echo ~deploy && sleep 0'<localhost> EXEC /bin/sh -c '( umask 77 
&& mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501 
`" && echo ansible-tmp-1705330892.3380399-4159921-3325212893501="` echo 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501 
`" ) && sleep 0'Using module file 
/usr/local/lib/python3.9/site-packages/ansible/modules/stat.py<localhost> 
PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmphdv1no20 TO 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py<localhost>
 
EXEC /bin/sh -c 'chmod u+x 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
 
&& sleep 0'<localhost> EXEC /bin/sh -c '/usr/bin/env python 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_stat.py
 
&& sleep 0'<localhost> PUT 
/home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpi_3sa5v9 TO 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source<localhost>
 
EXEC /bin/sh -c 'chmod u+x 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
 
&& sleep 0'Using module file 
/usr/local/lib/python3.9/site-packages/ansible/modules/copy.py<localhost> 
PUT /home/deploy/.ansible/tmp/ansible-local-4159897gzoguc4w/tmpyre28n8_ TO 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py<localhost>
 
EXEC /bin/sh -c 'chmod u+x 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
 
&& sleep 0'<localhost> EXEC /bin/sh -c '/usr/bin/env python 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/AnsiballZ_copy.py
 
&& sleep 0'<localhost> EXEC /bin/sh -c 'rm -f -r 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/ 
> /dev/null 2>&1 && sleep 0'The full traceback is:Traceback (most recent 
call last):  File 
"/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
 
line 1700, in atomic_move    os.rename(b_src, b_dest)PermissionError: 
[Errno 1] Operation not permitted: 
b'/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source'
 
-> b'/tmp/installed.txt'During handling of the above exception, another 
exception occurred:Traceback (most recent call last):  File 
"/tmp/ansible_ansible.legacy.copy_payload_rmpe1ef8/ansible_ansible.legacy.copy_payload.zip/ansible/module_utils/basic.py",
 
line 1759, in atomic_move    os.rename(b_tmp_dest_name, 
b_dest)PermissionError: [Errno 1] Operation not permitted: 
b'/tmp/.ansible_tmp162o24fxinstalled.txt' -> b'/tmp/installed.txt'fatal: 
[bed-test-9-dy2 -> localhost]: FAILED! => changed=false  checksum: 
590d9e59d7b819e4c8fb2068a91aec5e760afc8e  diff: []  invocation:    
module_args:      _original_basename: tmpi_3sa5v9      attributes: null    
  backup: false      checksum: 590d9e59d7b819e4c8fb2068a91aec5e760afc8e    
  content: null      dest: /tmp/installed.txt      directory_mode: null    
  follow: false      force: true      group: null      local_follow: null  
    mode: null      owner: null      remote_src: null      selevel: null    
  serole: null      setype: null      seuser: null      src: 
/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source
  
    unsafe_writes: false      validate: null  msg: 'Unable to make 
b''/home/deploy/.ansible/tmp/ansible-tmp-1705330892.3380399-4159921-3325212893501/source''
 
into to /tmp/installed.txt, failed final rename from 
b''/tmp/.ansible_tmp162o24fxinstalled.txt'': [Errno 1] Operation not 
permitted: b''/tmp/.ansible_tmp162o24fxinstalled.txt'' -> 
b''/tmp/installed.txt'''*
On Monday, January 15, 2024 at 9:21:26 AM UTC-5 Todd Lewis wrote:

> You say "the report play does not work", but you don't tell us in what way 
> it doesn't work. Is there a template error, undefined variable, or 
> something else? Does running with -vv -D indicate anything? "Does not work" 
> is too vague. Okay, so it didn't do what you expected, but what did it do? 
> Show us the play log.
>
>
> On 1/15/24 8:00 AM, Dimitri Yioulos wrote:
>
> Good morning. 
>
> Let me start by saying that I hope I'm not overdoing my asks. I only do it 
> when I've tried, but failed, at a solution. Nextly, I hope your kind 
> answers help others, as well. That said, the following playbook returns 
> packages that are set for update:
>
> ---
>
> - hosts: all
>   gather_facts: false
>
>   tasks:
>     - name: Check packages to upgrade
>       dnf:
>         list: updates
>       register: packages
>
>     - name: Show packages to upgrade
>       debug:
>         msg: >-
>           {%- set output=[] -%}
>           {%- for p in packages.results -%}
>           {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) 
> }}
>           {%- endfor -%}
>           {{ output }}
>
>     - local_action:
>         module: copy
>         content: |
>           {% for host in ansible_play_hosts %}
>           {{ host }}:
>           The following packages will be updated
>
>           {%- set output=[] -%}
>           {%- for p in packages.results -%}
>           {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) 
> }}
>           {%- endfor -%}
>           {{ output }}
>           {% endfor -%}
>
>         dest: "/tmp/installed.txt"
>       run_once: yes
>       tags:
>         - report
>
> It works fine through the debug play:
>
> ok: [myhost] => {
>     "msg": [
>         "paho-c-1.3.13-2.el9",
>         "cpp-11.4.1-2.1.el9",
>         "glibc-headers-2.34-83.el9_3.7",
>         "gnutls-dane-3.7.6-23.el9",
>         "insights-client-3.2.2-1.el9_2",
>         "libblockdev-2.28-7.el9",
>         "libblockdev-loop-2.28-7.el9",
>         "libfastjson-0.99.9-5.el9",
>         ~
>
> However, the report play does not work. I would have thought that setting 
> it up like the debug play should do it, but no. How can I get that list of 
> updates, along with the hostname, into a textfile report?
>
> As ever, many thanks.
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/7348c423-e5f5-46d3-816c-95bb14712c0bn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/7348c423-e5f5-46d3-816c-95bb14712c0bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
> -- 
> Todd
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/91f51377-9e9c-4070-9e59-ab9c67a4ac01n%40googlegroups.com.

Reply via email to