2023-09-13 16:14:09 +02:00
|
|
|
---
|
|
|
|
# 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
|
2023-09-07 13:10:12 +02:00
|
|
|
- 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 }}]
|
2023-09-13 16:14:09 +02:00
|
|
|
{% for line in group.1 %}
|
|
|
|
{{ line[1] }} mac={{ line[3] }} ip={{ line[4] }} type={{ line[8] }} pxe={{ line[10] }}
|
2023-09-07 13:10:12 +02:00
|
|
|
{% 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 }}"
|