Use ansible fact for interface name when changing ip address

This commit is contained in:
2018-08-15 18:28:46 -04:00
parent a47606af4a
commit 6245307031
2 changed files with 7 additions and 3 deletions

View File

@@ -59,6 +59,10 @@
timeout: 180
when: cloned.changed
- include: ../roles/ansible-dependencies/tasks/main.yml
delegate_to: 10.0.0.211
when: cloned.changed
- include: ../roles/configure-interfaces/tasks/main.yml
delegate_to: 10.0.0.211
when: cloned.changed

View File

@@ -1,18 +1,18 @@
---
- setup:
- name: Copy interface file
template: src=../roles/configure-interfaces/templates/interfaces dest=/etc/network/interfaces
- name: Copy interface cfg file
vars:
interface_name: eth0
interface_name: {{ ansible_default_ipv4.interface }}
template: src=../roles/configure-interfaces/templates/eth.cfg.j2 dest=/etc/network/interfaces.d/{{ interface_name }}.cfg
- name: Up down interface
shell: "(sleep 3s; ifdown {{ interface_name }} && ifup {{ interface_name }};) &"
ignore_errors: true
vars:
interface_name: eth0
interface_name: {{ ansible_default_ipv4.interface }}
async: 100
poll: 0