infra-ansible

ansible script to ship alpine/ssh/wireguard

git clone https://9o.is/git/infra-ansible.git

commit 23d1f53d8fd2402554b03843a945f98cf0f14641
parent 8d0f4008e6c03146fddc8b3d10d656f8d0554dc7
Author: Jul <jul@9o.is>
Date:   Mon, 13 May 2024 20:10:13 +0800

set network interfaces

Diffstat:
Ahost/roles/setup/handlers/main.yml | 6++++++
Rhost/roles/hostname/tasks/main.yml -> host/roles/setup/tasks/hostname.yml | 0
Ahost/roles/setup/tasks/main.yml | 3+++
Ahost/roles/setup/tasks/networking.yml | 39+++++++++++++++++++++++++++++++++++++++
Mhost/site.yml | 6+++---
5 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/host/roles/setup/handlers/main.yml b/host/roles/setup/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: restart networking + service: + name: networking + state: restarted + diff --git a/host/roles/hostname/tasks/main.yml b/host/roles/setup/tasks/hostname.yml diff --git a/host/roles/setup/tasks/main.yml b/host/roles/setup/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- include_tasks: networking.yml +- include_tasks: hostname.yml diff --git a/host/roles/setup/tasks/networking.yml b/host/roles/setup/tasks/networking.yml @@ -0,0 +1,39 @@ +--- + +- name: set up /etc/network/interfaces + copy: + dest: /etc/network/interfaces + owner: root + group: root + mode: '0644' + content: | + source-directory /etc/network/interfaces.d + notify: restart networking + +- name: set up loopback interface + copy: + dest: /etc/network/interfaces.d/lo + owner: root + group: root + mode: '0644' + content: | + auto lo + iface lo inet loopback + notify: restart networking + +- name: set up {{ static_interface }} interface + copy: + dest: '/etc/network/interfaces.d/{{ static_interface }}' + owner: root + group: root + mode: '0644' + content: | + auto {{ static_interface }} + iface {{ static_interface }} inet static + address {{ static_ip }} + netmask {{ static_subnet }} + gateway {{ static_gateway }} + dns-nameservers {{ static_nameservers }} + mtu {{ static_mtu }} + notify: restart networking + diff --git a/host/site.yml b/host/site.yml @@ -1,5 +1,5 @@ --- -- name: Ansible Raw Setup +- name: Raw Setup hosts: servers gather_facts: false remote_user: root @@ -7,12 +7,12 @@ roles: - raw-setup -- name: Initiate +- name: Setup hosts: servers remote_user: root tags: init roles: - - hostname + - setup - openssh - name: Firewall