From d12b3565324d598d77335149c291430310fe124b Mon Sep 17 00:00:00 2001 From: Florian Pritz <bluewind@xinu.at> Date: Wed, 27 Jul 2016 22:26:37 +0200 Subject: [PATCH] Move network config to common This allows to change it after deployment Signed-off-by: Florian Pritz <bluewind@xinu.at> --- host_vars/orion.archlinux.org | 6 ++++++ playbooks/orion-provision.yml | 5 ----- roles/common/handlers/main.yml | 5 +++++ roles/common/tasks/main.yml | 5 +++++ roles/common/templates/10-static-ethernet.network.j2 | 11 +++++++++++ .../templates/10-static-ethernet.network.j2 | 12 +----------- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 host_vars/orion.archlinux.org create mode 100644 roles/common/handlers/main.yml create mode 100644 roles/common/templates/10-static-ethernet.network.j2 mode change 100644 => 120000 roles/install_arch/templates/10-static-ethernet.network.j2 diff --git a/host_vars/orion.archlinux.org b/host_vars/orion.archlinux.org new file mode 100644 index 000000000..c5fc70ceb --- /dev/null +++ b/host_vars/orion.archlinux.org @@ -0,0 +1,6 @@ +--- +ipv4_address: "88.198.91.70" +ipv6_address: "2a01:4f8:160:6087::1/128" +ipv4_gateway: "88.198.91.65" +ipv6_gateway: "fe80::1" +filesystem: btrfs diff --git a/playbooks/orion-provision.yml b/playbooks/orion-provision.yml index 1a97b95fc..9137d823c 100644 --- a/playbooks/orion-provision.yml +++ b/playbooks/orion-provision.yml @@ -8,10 +8,5 @@ remote_user: root vars: - hostname: orion - ipv4_address: "88.198.91.70" - ipv6_address: "2a01:4f8:160:6087::1/128" - ipv4_gateway: "88.198.91.65" - ipv6_gateway: "fe80::1" - filesystem: btrfs roles: - install_arch diff --git a/roles/common/handlers/main.yml b/roles/common/handlers/main.yml new file mode 100644 index 000000000..19aee0c90 --- /dev/null +++ b/roles/common/handlers/main.yml @@ -0,0 +1,5 @@ +--- + +- name: restart networkd + service: name=systemd-networkd state=restarted + diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index a512fa8e3..64d33225f 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -32,3 +32,8 @@ - name: generate ssh key for root command: ssh-keygen -b 4096 -N "" -f /root/.ssh/id_rsa creates="/root/.ssh/id_rsa" + +- name: configure network + template: src=10-static-ethernet.network.j2 dest=/etc/systemd/network/10-static-ethernet.network owner=root group=root mode=0644 + notify: + - restart networkd diff --git a/roles/common/templates/10-static-ethernet.network.j2 b/roles/common/templates/10-static-ethernet.network.j2 new file mode 100644 index 000000000..e36edaa35 --- /dev/null +++ b/roles/common/templates/10-static-ethernet.network.j2 @@ -0,0 +1,11 @@ +[Match] +Name=e* + +[Network] +DNS=213.133.98.98 +DNS=213.133.99.99 +DNS=213.133.100.100 +Address={{ ipv4_address }} +Address={{ ipv6_address }} +Gateway={{ ipv4_gateway }} +Gateway={{ ipv6_gateway }} diff --git a/roles/install_arch/templates/10-static-ethernet.network.j2 b/roles/install_arch/templates/10-static-ethernet.network.j2 deleted file mode 100644 index e36edaa35..000000000 --- a/roles/install_arch/templates/10-static-ethernet.network.j2 +++ /dev/null @@ -1,11 +0,0 @@ -[Match] -Name=e* - -[Network] -DNS=213.133.98.98 -DNS=213.133.99.99 -DNS=213.133.100.100 -Address={{ ipv4_address }} -Address={{ ipv6_address }} -Gateway={{ ipv4_gateway }} -Gateway={{ ipv6_gateway }} diff --git a/roles/install_arch/templates/10-static-ethernet.network.j2 b/roles/install_arch/templates/10-static-ethernet.network.j2 new file mode 120000 index 000000000..d73e3a3b2 --- /dev/null +++ b/roles/install_arch/templates/10-static-ethernet.network.j2 @@ -0,0 +1 @@ +../../common/templates/10-static-ethernet.network.j2 \ No newline at end of file -- GitLab