diff --git a/inventories/host_vars/mai.yml b/inventories/host_vars/mai.yml new file mode 100644 index 0000000..c0475c4 --- /dev/null +++ b/inventories/host_vars/mai.yml @@ -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" diff --git a/inventories/host_vars/networks.yml b/inventories/host_vars/networks.yml index 7e7c197..13638cb 100644 --- a/inventories/host_vars/networks.yml +++ b/inventories/host_vars/networks.yml @@ -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 diff --git a/inventories/hosts b/inventories/hosts index 0c22a82..1b4cdfc 100644 --- a/inventories/hosts +++ b/inventories/hosts @@ -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 diff --git a/mai.yml b/mai.yml new file mode 100644 index 0000000..8fcfe60 --- /dev/null +++ b/mai.yml @@ -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 diff --git a/tasks/all/netplan.yml b/tasks/all/netplan.yml index 0344b62..85e53fd 100644 --- a/tasks/all/netplan.yml +++ b/tasks/all/netplan.yml @@ -12,7 +12,7 @@ network: version: 2 ethernets: - ens160: + "{{ hostinfo[0].interface }}": addresses: - "{{ ipv4_addr }}/{{ subnet.mask }}" nameservers: diff --git a/tasks/all/usermod.yml b/tasks/all/usermod.yml index c4589ce..bfc5b54 100644 --- a/tasks/all/usermod.yml +++ b/tasks/all/usermod.yml @@ -15,7 +15,6 @@ shell: "{{ item.shell }}" state: "present" system: true - uid: "{{ item.uid }}" loop: "{{ all.vars.user }}" diff --git a/templates/mai/etc/motd b/templates/mai/etc/motd new file mode 100644 index 0000000..e3b0393 --- /dev/null +++ b/templates/mai/etc/motd @@ -0,0 +1,6 @@ + _ + _ __ ___ __ _(_) +| '_ ` _ \ / _` | | +| | | | | | (_| | | +|_| |_| |_|\__,_|_| +