Combining local_action and delegate_to

10 views
Skip to first unread message

Amir Al-Shourbaji

unread,
Mar 7, 2019, 12:18:29 PM3/7/19
to Ansible Project
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?

Kai Stian Olstad

unread,
Mar 7, 2019, 12:22:41 PM3/7/19
to ansible...@googlegroups.com
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.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages