Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ansible/inventory/host_vars/example.org.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
ansible_user: ansible

configure_static_ip: false

interface:
name: enp35s0
ip: 1.2.3.4
# The following variables are only required if configure_static_ip is true
gateway: 1.2.3.4
netmask: 255.255.255.0
dns: 1.1.1.1
6 changes: 6 additions & 0 deletions ansible/roles/proxmox-initial/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Restart networking
become: true
service:
name: networking
state: restarted
12 changes: 12 additions & 0 deletions ansible/roles/proxmox-initial/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
upgrade: yes
update_cache: yes

- name: Configure the chosen IP address to be static
become: true
template:
src: etc/network/interfaces
dest: /etc/network/interfaces
when: configure_static_ip == true
notify:
- Restart networking

- name: Ensure the static IP address config has been applied
meta: flush_handlers

# https://gist.github.com/rothgar/8793800
- name: Template /etc/hosts file
become: true
Expand Down
20 changes: 20 additions & 0 deletions ansible/roles/proxmox-initial/templates/etc/network/interfaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto {{ interface.name }}
iface {{ interface.name }} inet static
address {{ interface.ip }}
gateway {{ interface.gateway }}
netmask {{ interface.netmask }}
dns-nameservers {{ interface.dns }}

# This is an autoconfigured IPv6 interface
# NOTICE: The IPv6 interface has been set to manual because of problems with ifupdown2 and auto-IPv6 configurations
iface {{ interface.name }} inet6 manual