Daenou / ansible-multiroom-audio

9 stars 0 forks source link

improve usage of ansible "loop" in acable and (new) snapclient roles #26

Closed nis65 closed 2 years ago

nis65 commented 2 years ago

Today I changed the snapclient role to support multiple snapclients per host: https://github.com/Daenou/ansible-multiroom-audio/pull/25

I more or less merged the acable ansible logic into the snapclient role.

To my understanding, the current loop logic is somewhat redundant. You have both

The former is used in tasks/main.yml to enable/start the systemd units and in handlers/main.yml to restart the systemd units.

On the other hand, the latter is used to create the config files in /etc/acable.conf.d/ and /etc/snapserver.conf.d.

I think it should be possible to use the _config dict to manage the systemd units and drop the former one...

nis65 commented 2 years ago

Hint from one of my colleagues:

I would rewrite that to:

snapclient_snapservers:
  - name: pidev
    snapclient_snapserver: pidev.iselin.net
    snapclient_sink: dmix:CARD=sndrpihifiberry,DEV=0 
  - name: hifi
    snapclient_snapserver: hifi.iselin.net
    snapclient_sink: dmix:CARD=sndrpihifiberry,DEV=0

And loop over it with something like this:

- name: do something
  debug:
    msg: "{{ item.name }} has {{ item.snapclient_snapserver }} and {{ item.snapclient_sink }}"
  loop: "{{ snapclient_snapservers }}"
  loop_control:
    label: "{{ item.name }}"
Daenou commented 2 years ago

Functionality is in dev branch