But the YAML parser wasn’t happy with this. Its rather weak error message didn’t give me much clue, so I resorted to ChatGPT + Google. “They” suggested:
This works. – But why does the first version not work? I usually do not write my actions with the explicit module specifier (but rather as the action “heading”) , and it feels annoying that in this one situation I have to do use “module:”.
I am confused. I clearly miss something here…
ps: Bonus question: Is it possible to apply the local_action direction to multiple actions (via a block construct maybe)? – My AI didn’t think so, but that doesn’t mean too much.
I personally think it’s better to use the delegate_to: localhost parameter than to use local_action … for one, just the reading of the playbook is simpler from an indentation perspective…
I think the first block you have didn’t work because of the indentation - with local_action, I believe it flattens the indentation of the module parameters. Again, I personally like everything uniform, so I prefer delegate_to…
So I think this block should work fine as well, and do the same thing:
I agree with @jrglynn2’s observation on using delegate_to, I never use local_action. And when using a block, you can set delegate_to on that level to make it apply to all tasks in the block
Since delegate_to: localhost has already been suggested I’m just going to clarify that action and local_action do not allow for unknown entries in their args in YAML form only in k=v, which assumes they are the ‘module/action plugin’, so these are all the valid forms: