path of ip command is system dependent

- on centos: /usr/sbin/ip
- on ubuntu: /sbin/ip
This commit is contained in:
Will Szumski 2018-09-28 15:04:00 +01:00
parent cb50ef288a
commit 9ccf17a1da
3 changed files with 21 additions and 2 deletions

View File

@ -1,4 +1,15 @@
---
- name: Gather os specific variables
include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
skip: true
tags: vars
- name: Fail if source interface does not exist
fail:
msg: >
@ -13,8 +24,8 @@
source_type: direct
- name: Get source interface details
# NOTE(w-miller): The `ip` command may not be in $PATH, so use the full path.
command: /usr/sbin/ip -details link show {{ source_interface }}
command: >
{{ tenks_ip_path }} -details link show {{ source_interface }}
register: if_details
changed_when: false

4
ansible/vars/Debian.yml Normal file
View File

@ -0,0 +1,4 @@
---
# path to `ip` from the `iproute2` package
tenks_ip_path: /sbin/ip

4
ansible/vars/RedHat.yml Normal file
View File

@ -0,0 +1,4 @@
---
# path to `ip` from the `iproute2` package
tenks_ip_path: /usr/bin/ip