From 7348dbeb95037cf0f52140670fe448a5cedd1caa Mon Sep 17 00:00:00 2001 From: Ruan Bekker Date: Sat, 17 Oct 2020 20:11:03 +0200 Subject: [PATCH] Create main.yml --- roles/static-ip/tasks/main.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 roles/static-ip/tasks/main.yml diff --git a/roles/static-ip/tasks/main.yml b/roles/static-ip/tasks/main.yml new file mode 100644 index 0000000..a2974fd --- /dev/null +++ b/roles/static-ip/tasks/main.yml @@ -0,0 +1,15 @@ +# https://github.com/vicchi/ansible-pi-lockdown/blob/master/roles/static-ip/tasks/main.yml +--- +- name: Configure static IP in /etc/dhcpcd.conf + become: yes + lineinfile: + dest: /etc/dhcpcd.conf + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + state: present + with_items: + - { regexp: "^interface eth[0-9]$", line: "interface {{ interface }}" } + - { regexp: "^static ip_address", line: "static ip_address={{ ipaddress }}" } + - { regexp: "^static routers", line: "static routers={{ routers }}" } + - { regexp: "^static domain_name_servers", line: "static domain_name_servers={{ dns_servers }}" } + notify: reboot