Combining local_action and delegate_to

I want this module to run locally on a host i delegate_to

  • name: Add Host to dhcp config
    local_action:
    module: lineinfile
    dest: /etc/dhcp/dhcpd.conf
    line: “host {{ inventory_hostname}} {hardware ethernet {{ macaddress }};fixed-address {{ inventory_hostname}}; }”
    notify: restart dhcpd

delegate_to: anarbitraryhost

Doesn’t seem to work - are local_action and delegate_to mutually exclusive?

local_action is the same as delegate_to: localhost.
So you can't use them together since it gives no meaning, either you want it to run on localhost or anarbitraryhost.

If you want to run in on both you need two tasks.