From 95e0e803143756ef5d4cf7821b7e94b5fd13a7c7 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 6 Sep 2016 15:09:42 +0300 Subject: Add Ansible playbook to config LAN1 --- ansible/hosts | 2 + ansible/minipc-router.yml | 9 ++++ ansible/roles/lan1-dhcp-client/files/lan1-dhcp | 2 + ansible/roles/lan1-dhcp-client/tasks/main.yml | 7 +++ ansible/roles/sane-debian-system/tasks/main.yml | 63 ++++++++++++++++++++++ .../sane-debian-system/templates/sources.list.j2 | 1 + ansible/run-playbook | 16 ++++++ 7 files changed, 100 insertions(+) create mode 100644 ansible/hosts create mode 100644 ansible/minipc-router.yml create mode 100644 ansible/roles/lan1-dhcp-client/files/lan1-dhcp create mode 100644 ansible/roles/lan1-dhcp-client/tasks/main.yml create mode 100644 ansible/roles/sane-debian-system/tasks/main.yml create mode 100644 ansible/roles/sane-debian-system/templates/sources.list.j2 create mode 100755 ansible/run-playbook (limited to 'ansible') diff --git a/ansible/hosts b/ansible/hosts new file mode 100644 index 0000000..6ce6bac --- /dev/null +++ b/ansible/hosts @@ -0,0 +1,2 @@ +[router] +10.0.0.4 diff --git a/ansible/minipc-router.yml b/ansible/minipc-router.yml new file mode 100644 index 0000000..9f1308e --- /dev/null +++ b/ansible/minipc-router.yml @@ -0,0 +1,9 @@ +- hosts: router + remote_user: ansible + become: yes + vars: + debian_mirror: http://ftp.fi.debian.org/debian + hostname: router + distro: jessie + roles: + - lan1-dhcp-client diff --git a/ansible/roles/lan1-dhcp-client/files/lan1-dhcp b/ansible/roles/lan1-dhcp-client/files/lan1-dhcp new file mode 100644 index 0000000..81922ce --- /dev/null +++ b/ansible/roles/lan1-dhcp-client/files/lan1-dhcp @@ -0,0 +1,2 @@ +auto eth0 +iface eth0 inet dhcp diff --git a/ansible/roles/lan1-dhcp-client/tasks/main.yml b/ansible/roles/lan1-dhcp-client/tasks/main.yml new file mode 100644 index 0000000..fb5d06e --- /dev/null +++ b/ansible/roles/lan1-dhcp-client/tasks/main.yml @@ -0,0 +1,7 @@ +- name: "configure LAN1 (eth0) to be a DHCP client" + copy: + src: lan1-dhcp + dest: /etc/network/interfaces.d/lan1-dhcp + +- name: bring up LAN1 (eth0) + shell: ifup eth0 diff --git a/ansible/roles/sane-debian-system/tasks/main.yml b/ansible/roles/sane-debian-system/tasks/main.yml new file mode 100644 index 0000000..187539c --- /dev/null +++ b/ansible/roles/sane-debian-system/tasks/main.yml @@ -0,0 +1,63 @@ +# Set hostname. + +- name: set hostname + hostname: name={{ hostname }} + +- name: add hostname to /etc/hosts + lineinfile: + dest: /etc/hosts + regexp: '^127\.0\.0\.1' + line: "127.0.0.1 localhost {{ hostname }}" + owner: root + group: root + mode: 0644 + +# Configure the main sources.list using a Jinja2 template, because +# there's a whole bunch of repos and there's some conditional repos +# involved. + +- name: configure main sources.list + template: + src: sources.list.j2 + dest: /etc/apt/sources.list + +# Update lists, upgrade packages. + +- name: update apt package lists + apt: + update_cache: yes + cache_valid_time: 0 + +- name: upgrade packages + apt: + upgrade: dist + +- name: free up disk space by removing apt package cache + shell: | + apt"-get" clean + +# Install/configure packages that are always needed. + +- name: install acpi-support-base + apt: name=acpi-support-base + +- name: install ntp + apt: name=ntp + +- name: install locales + apt: name=locales + +- name: create en_GB.UTF-8 locale + locale_gen: state=present name=en_GB.UTF-8 + +- name: create fi_FI.UTF-8 locale + locale_gen: state=present name=fi_FI.UTF-8 + +# Get rid of bash-completion. It tends to irritate me more than it is +# ever helpful. + +- name: REMOVE bash-completion + apt: + name: bash-completion + state: absent + purge: yes diff --git a/ansible/roles/sane-debian-system/templates/sources.list.j2 b/ansible/roles/sane-debian-system/templates/sources.list.j2 new file mode 100644 index 0000000..841bfd3 --- /dev/null +++ b/ansible/roles/sane-debian-system/templates/sources.list.j2 @@ -0,0 +1 @@ +deb {{ debian_mirror }} {{ distro }} main non-free contrib diff --git a/ansible/run-playbook b/ansible/run-playbook new file mode 100755 index 0000000..c796862 --- /dev/null +++ b/ansible/run-playbook @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eu + +abspath() +{ + (cd "$1" && pwd) +} + +srcdir() +{ + abspath "$(dirname "$0")" +} + +export PASSWORD_STORE_DIR="$(srcdir)"/secrets +ansible-playbook -i hosts "$@" -- cgit v1.2.1