register: variable as {{item}}?

  • shell: alternatives --display {{ item }} | grep “best” | grep “jre1.7.0_75”
    sudo: yes
    register: “{{ item }}”
    ignore_errors:
    with_items:
  • java
  • javaws
  • jcontrol

I’ve tried several iterations of this, all fail. Is there any way this can work? I don’t want to have to create 3 individual plays for each item. I have a much longer check coming up - like 25+ checks - and that will suck if I can’t do something like the above.

What’s stopping you from registering this loop task with one variable? The iterated results get registered in a .results list .

Nothing’s stopping me. I don’t know what you’re referring to.

​I meant, don;t use the jinja variable construct on register, just a plain
variable.
A registered variable on with_items will have a list of registered results.

Perhaps you need to to show us what you try to do with the registereed
variable(s) later on.

I plan to run ‘alternatives --install {{ item }} yadayada’ for each in the list which will be only those items for which the above shell: command failed. I don’t want to run it against all three all the time. So are you saying that using a register: with multiple items will result in a list of register[item0].dict_of_variables, register[item1].dict_of_variables, etc?