Skip to content

Commit

Permalink
Merge pull request #380 from cradle8810/mai_raspi3
Browse files Browse the repository at this point in the history
Initial mai.hayaworld.home
  • Loading branch information
cradle8810 authored Nov 17, 2024
2 parents b543c42 + 5fa0cad commit 36f2705
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 2 deletions.
70 changes: 70 additions & 0 deletions inventories/host_vars/mai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
apt:
- curl
- dnsmasq
- dstat
- htop
- rsyslog

mai_info: "{{ network | selectattr('shortname', 'eq', 'mai') }}"
mai_ipv4: "{{ mai_info[0].ipv4 }}"
mai_interface: "{{ mai_info[0].interface }}"

dnsmasq:
domain: hayaworld.home
local: /hayaworld.home/
listen_address: "{{ mai_ipv4 }}"
interface: "{{ mai_interface }}"
dhcp_range:
start: 192.168.1.151
end: 192.168.1.191
netmask: 255.255.255.0
ttl: "12h"
dhcp_option:
ntp_server: 210.130.188.10
dns_server: "{{ mai_ipv4 }}"
router: "{{ subnet.gw4 }}"
netmask: "255.255.255.0"
dns:
cache_size: 4000
NXDOMAIN_hosts: /etc/dnsmasq.d/NXDOMAIN.conf
logs:
log_facility: local5

services_start:
- dnsmasq
- rsyslog
- ssh
- systemd-journald

firewall:
policy: deny
allow_rules:
- name: "SSH from service line"
proto: "tcp"
src: "192.168.1.0/24"
port: '22'
- name: "Zabbix from Zabbix-server"
proto: "tcp"
src: "192.168.1.106/24"
port: "10050"
- name: "DNS from service line"
proto: "tcp"
src: "192.168.1.0/24"
port: "53"
- name: "DNS(UDP) from service line"
proto: "udp"
src: "192.168.1.0/24"
port: "53"
- name: "DHCP from service line"
proto: "udp"
src: "any"
port: "67"
- name: "DHCP Client from service line"
proto: "udp"
src: "any"
port: "68"
- name: "Runner Docker ssh"
proto: "tcp"
src: "172.17.0.0/16"
port: "22"
5 changes: 5 additions & 0 deletions inventories/host_vars/networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ network:
ipv4: 192.168.1.131
shortname: jenkins
sshuser: hayato
- hostname: mai.hayaworld.home
interface: eth0
ipv4: 192.168.1.150
shortname: mai
sshuser: hayato
- hostname: skylark.hayaworld.home
interface: ens160
ipv4: 192.168.1.200
Expand Down
3 changes: 3 additions & 0 deletions inventories/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
[jenkins]
192.168.1.131 ansible_user=hayato

[mai]
192.168.1.150 ansible_user=hayato

[skylark]
192.168.1.200 ansible_user=hayato

Expand Down
57 changes: 57 additions & 0 deletions mai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
- name: Play for mai.hayaworld.home
hosts: mai
remote_user: hayato
gather_facts: true
become: true

vars_files:
- inventories/host_vars/rui/NXDOMAIN.yml
- inventories/host_vars/rui/CNAME.yml
- inventories/host_vars/mai.yml
- inventories/host_vars/networks.yml

handlers:
- name: Restart handler tasks
ansible.builtin.import_tasks:
file: handlers/main.yml

tasks:
- name: Common Settings
ansible.builtin.import_tasks:
file: tasks/all/main.yml

- name: Stop systemd-resolved
ansible.builtin.import_tasks:
file: tasks/rui/stop-systemd-resolved.yml
tags:
- dnsmasq

- name: Setup dnsmask
ansible.builtin.import_tasks:
file: tasks/rui/dnsmasq.yml
tags:
- dnsmasq

- name: Show hosts(5)
ansible.builtin.debug:
msg: "{{ lookup('template', './templates/rui/etc/hosts.j2') }}"
tags:
- debug
- dnsmasq
- dryrun

- name: Setup journalctl
ansible.builtin.import_tasks:
file: tasks/rui/journalctl.yml

- name: Setup rsyslog
ansible.builtin.import_tasks:
file: tasks/rui/rsyslog-rui.yml
tags:
- rsyslog
- dnsmasq

- name: Make Started Services
ansible.builtin.import_tasks:
file: tasks/service_start.yml
2 changes: 1 addition & 1 deletion tasks/all/netplan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
network:
version: 2
ethernets:
ens160:
"{{ hostinfo[0].interface }}":
addresses:
- "{{ ipv4_addr }}/{{ subnet.mask }}"
nameservers:
Expand Down
1 change: 0 additions & 1 deletion tasks/all/usermod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
shell: "{{ item.shell }}"
state: "present"
system: true
uid: "{{ item.uid }}"
loop:
"{{ all.vars.user }}"

Expand Down
6 changes: 6 additions & 0 deletions templates/mai/etc/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_
_ __ ___ __ _(_)
| '_ ` _ \ / _` | |
| | | | | | (_| | |
|_| |_| |_|\__,_|_|

0 comments on commit 36f2705

Please sign in to comment.