From 96b5b5b6c0cd3ab1cb7aaff58e91f1aa80078b7e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 4 Aug 2014 15:59:45 +0900 Subject: [PATCH] ansible: debian_setup: add tasks for static ip --- ansible/debian_setup.static_ip.interfaces | 5 +++++ ansible/debian_setup.yml | 25 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 ansible/debian_setup.static_ip.interfaces diff --git a/ansible/debian_setup.static_ip.interfaces b/ansible/debian_setup.static_ip.interfaces new file mode 100644 index 0000000..fd94b19 --- /dev/null +++ b/ansible/debian_setup.static_ip.interfaces @@ -0,0 +1,5 @@ +auto eth0 +iface eth0 inet static +address 192.168.2.4 +netmask 255.255.255.0 +gateway 192.168.2.1 diff --git a/ansible/debian_setup.yml b/ansible/debian_setup.yml index 02a10eb..ec9fa1b 100644 --- a/ansible/debian_setup.yml +++ b/ansible/debian_setup.yml @@ -1,5 +1,28 @@ --- - hosts: all vars: + sudo: yes tasks: - - name: put interfaces file for fixed IP + - name: add line to source interfaces.d + lineinfile: dest=/etc/network/interfaces + line="source-directory interfaces.d" + backup=yes + - name: comment allow-hotplug eth0 + lineinfile: dest=/etc/network/interfaces + line="# allow-hotplug eth0" + regexp="allow-hotplug eth0" + backup=yes + - name: comment dhcp setup for eth0 + lineinfile: dest=/etc/network/interfaces + line="# iface eth0 inet dhcp" + regexp="iface eth0 inet dhcp" + backup=yes + - name: put interfaces file for static IP + copy: src=debian_setup.static_ip.interfaces + dest=/etc/network/interfaces.d/static_ip + notify: + - restart network service + + handlers: + - name: restart networking service + service: name=networking state=restarted