Score:1

Ansible export to csv

la flag

I want to get a csv with a list of new updates in this form:

testvm-001.localdomain,ImageMagick-6.9.11.27-4.el7

testvm-001.localdomain,ImageMagick-libs-6.9.11.27-4.el7

I have a code that will display a list of updates, but I don’t know how to save it in csv in the right form.

- hosts: test
  vars:
    my_packages: "{{ dict(packages.results|groupby('name')) }}"
  tasks:
    - name: Count new update
      shell: hostname
      register: hostname
    - dnf:
        list: updates
      register: packages
    - debug:
        msg: |
          {% for name,versions in my_packages.items() %}
          {% set max_ver=versions|map(attribute='version')|max %}
          {% set p=versions|selectattr('version', '==', max_ver) %}
          {{ hostname.stdout }},{{ name }}-{{ p.0.version }}-{{ p.0.release }}
          {% endfor %}

ok: [10.0.0.2] => { "msg": "testvm-001.localdomain,ImageMagick-6.9.11.27-4.el7 \ntestvm-001.localdomain,ImageMagick-libs-6.9.11.27-4.el7 \ntestvm-001.localdomain,LibRaw-0.19.5-6.el7 \ntestvm-001.localdomain,NetworkManager-1.32.12-1.el7 \ntestvm-001.localdomain,NetworkManager-l2tp-1.20.0-1.el7 \ntestvm-001.localdomain,NetworkManager-l2tp-gnome-1.20.0-1.el7 \ntestvm-001.localdomain,NetworkManager-libnm-1.32.12-1.el7 \ntestvm-001.localdomain,NetworkManager-libreswan-1.2.16-1.el7 ...

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.