--- # Dieses Playbook holt die devices.csv vom Schulserver # und baut daraus ein ansible inventory # Damit das geht, muss der ansible Benutzer des netboot-Servers # die devices.csv per scp vom Server holen können # - Frank Schiebel, 09/2023 - hosts: localhost gather_facts: false become: false vars: csv_hosts: "{{ out.stdout_lines|map('split', ';')|groupby('0') }}" ini_hosts: | {% for group in csv_hosts %} [{{ group.0 }}] {% for line in group.1 %} {{ line[1] }} mac={{ line[3] }} ip={{ line[4] }} type={{ line[8] }} pxe={{ line[10] }} {% endfor %} {% endfor %} tasks: - shell: scp linuxadmin@server:/etc/linuxmuster/sophomorix/default-school/devices.csv . - shell: cat devices.csv | grep -v ^# | grep -v ^$ register: out - copy: dest: devices.ini content: "{{ ini_hosts }}"