Reputation: 1
I am trying to run the ip link command using ansible on one box ip command located on /bin/ip and other box /usr/sbin/ip
- name: verify the MAC address
shell: /usr/sbin/ip link
- name: verify the MAC address
shell: /bin/ip link
how any thought to solve this problem
Upvotes: 0
Views: 107
Reputation: 44615
Here is a possible scenario that should put you on track:
/usr/sbin/ip
machine_a
machine_b
machine_c ip_cmd_path="/bin/ip"
- name: Demo run default cmd unless override
hosts: all
tasks:
- name: run ip command
shell: "{{ ip_cmd_path | default('/usr/sbin/ip') }} link"
You can adapt this to target groups rather than machines. You can also have your default command in a variable if needed. Finding the best option depends on your exact requirements.
Upvotes: 3