Compare commits

...

4 Commits

Author SHA1 Message Date
e7c3e1eed2 Update networks 2022-08-01 23:57:18 +02:00
6321f2a36e Fix heartbeat 2022-06-05 02:28:53 +02:00
5b76f14734 Add remote_server 2022-06-04 22:56:07 +02:00
fe000e168f Restore main file 2022-06-04 22:47:20 +02:00
11 changed files with 176 additions and 46 deletions

View File

@ -72,6 +72,10 @@ all:
ansible_host: 192.168.50.186
vars:
ip: 186
remote_server:
ansible_host:
ansible_become_password:
ansible_user: ubuntu
children:
raspberry:
hosts:

View File

@ -1,30 +1,25 @@
---
#- hosts: iron-man.lan
# roles:
# - ssh
# - ubuntu
#
#- hosts: prusa
# roles:
# - ssh
# - octoprint
# - ubuntu
- hosts: prusa
roles:
- ssh
- octoprint
- ubuntu
- hosts: docker_cluster
roles:
# - node_explorer
# - ssh
- node_explorer
- ssh
- docker-cluster
# - ubuntu
#
#- hosts: raspberry
# roles:
# - i2c-clock
- ubuntu
#- hosts: router.lan
# roles:
# - router
- hosts: raspberry
roles:
- i2c-clock
#- hosts: iron-man
# roles:
# - ssh
- hosts: router.lan
roles:
- router
- hosts: remote_server
roles:
- docker

View File

@ -1,2 +1,2 @@
node-02 IPaddr::192.168.50.100/24/eth0:0
node-02 ssh-external
node-02 ssh-external::start

View File

@ -0,0 +1,17 @@
- name: Clean docker system
become: yes
ansible.builtin.cron:
user: root
name: "clean docker system"
minute: "0"
hour: "3"
job: "/usr/bin/docker system prune -f"
- name: Clean docker image cache
become: yes
ansible.builtin.cron:
user: root
name: "clean docker system"
minute: "0"
hour: "3"
job: "/usr/bin/docker image prune -a -f"

View File

@ -0,0 +1,49 @@
---
- become: yes
block:
- name: install needed packages
apt:
update_cache: yes
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- name: add docker gpg key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: add docker repo
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
state: present
filename: docker
- name: install docker
apt:
update_cache: yes
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- name: add current user to docker group
user:
name: "{{ansible_user_id}}"
groups: docker
append: yes
- name: start and enable docker
systemd:
name: docker
state: started
enabled: true
- name: add current user to docker group
user:
name: "{{ ansible_user_id }}"
append: yes
groups: docker

View File

@ -0,0 +1,20 @@
---
- become: yes
block:
- name: install needed packages
apt:
update_cache: yes
pkg:
- docker.io
- name: start and enable docker
systemd:
name: docker
state: started
enabled: true
- name: add current user to docker group
user:
name: "{{ ansible_user_id }}"
append: yes
groups: docker

View File

@ -0,0 +1,8 @@
---
- import_tasks: install-docker-ce.yml
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "18.04"
- import_tasks: install-docker-io.yml
when: ansible_distribution == "Ubuntu" and ansible_distribution_version != "18.04"
- import_tasks: docker-cron.yml

View File

@ -4,7 +4,7 @@
path: build/dns
state: directory
- name: Create db.lan
- name: Create db lan
# become: yes
template:
src: etc/bind/db.lan.j2
@ -13,7 +13,7 @@
network: "{{ lan }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: Create db.lan
- name: Create reverse db lan
# become: yes
template:
src: etc/bind/db.reverse.j2
@ -21,3 +21,21 @@
vars:
network: "{{ lan }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: Create db iot
# become: yes
template:
src: etc/bind/db.lan.j2
dest: build/dns/db.iot
vars:
network: "{{ iot }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: Create reverse db iot
# become: yes
template:
src: etc/bind/db.reverse.j2
dest: build/dns/db.{{ iot.network_reverse }}
vars:
network: "{{ iot }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"

View File

@ -10,7 +10,7 @@ $ORIGIN {{ network.network_name }}.
@ IN NS dns.{{ network.network_name }}.
DNS IN A {{ network.network_prefix }}.100
DNS IN A {{ network.dns }}
{% for host in network.hosts %}
{{ host.name }} IN A {{ network.network_prefix }}.{{ host.ip }}

View File

@ -4,6 +4,7 @@ authorative;
subnet {{ network.address }} netmask {{ network.mask }} {
option domain-name-servers {{ network.dns }};
option domain-name "{{ network.network_name }}";
option domain-search "lan", "iot";
option routers {{ network.gateway }};
default-lease-time 86400;
max-lease-time 86400;

View File

@ -20,23 +20,17 @@ lan:
- name: prusa
ip: 6
mac: b8:27:eb:c3:a6:6a
# - name: rpi3
- name: iron-man
ip: 7
mac: dc:a6:32:03:6d:fa
- name: rpi3a
ip: 8
mac: b8:27:eb:ff:2a:86
- name: hulk
ip: 21
mac: 24:4b:fe:05:e2:8b
- name: banner
ip: 22
mac: 52:54:00:49:04:51
- name: laptop
ip: 29
mac: 08:d4:0c:cc:ff:1f
mac: '52:54:00:49:04:51'
- name: hawkeye
ip: 23
mac: b4:8c:9d:5e:a1:8b
mac2: a0:ce:c8:77:c3:13
- name: android-sgs9
ip: 41
@ -46,10 +40,13 @@ lan:
mac: b8:63:4d:b6:4c:bc
- name: iphone
ip: 43
mac: b2:d9:6f:d9:31:e1
mac: 0c:19:f8:10:c2:b3
- name: apple-watch
ip: 44
mac: b2:b0:04:86:fc:90
mac: 9c:28:b3:24:bc:9c
- name: ipad-pro
ip: 45
mac: 38:88:a4:6e:95:a3
- name: node-01
ip: 101
@ -63,9 +60,15 @@ lan:
- name: node-04
ip: 104
mac: dc:a6:32:8b:7b:ab
- name: node-05
ip: 105
mac: 08:d4:0c:cc:ff:1f
iot:
network: 192.168.60
network_prefix: 192.168.60
network_reverse: 60.168.192
network_name: iot
dns: 192.168.50.100
hosts:
- name: hue-light
ip: 3
@ -73,16 +76,16 @@ iot:
- name: harmony-hub
ip: 4
mac: c8:db:26:06:7e:f9
- name: zhimi-airpurifier-m1_miio61353463
- name: airpurifier-bedroom
ip: 5
mac: 34:ce:00:a4:f6:75
- name: zhimi-airpurifier-mb3_mibt952D
- name: airpurifier-livingroom
ip: 6
mac: 50:ec:50:85:95:2d
- name: roborock
ip: 7
mac: 50:ec:50:0a:c3:94
- name: zhimi-humidifier-ca4_mibt1D0C
- name: humidifier
ip: 8
mac: 54:48:e6:5d:1d:0c
- name: yeelight-lightbar
@ -100,6 +103,9 @@ iot:
- name: bedroom-tv
ip: 16
mac: d8:a3:5c:7d:50:0a
- name: miibox
ip: 17
mac: 00:e0:4c:68:09:35
- name: nvidia-shield
ip: 18
mac: 00:04:4b:cd:a6:5b
@ -107,9 +113,14 @@ iot:
- name: nintendo-switch
ip: 19
mac: 64:b5:c6:6f:ff:a8
mac2: 00:0e:c6:c7:55:6f
- name: printer
ip: 20
mac: 38:9d:92:d0:6d:8e
- name: xbox-series-s
ip: 21
mac: a8:8c:3e:b0:aa:7a
- name: Sonos-LivingRoom
ip: 30
mac: 34:7e:5c:83:6f:c6
@ -119,12 +130,19 @@ iot:
- name: Sonos-Bathroom
ip: 32
mac: 5c:aa:fd:b9:4b:22
- name: Sonos-Bedroom2
ip: 33
mac: 78:28:ca:85:51:dc
- name: home-assistant
ip: 100
mac: dc:a6:32:f6:63:c1
- name: home-assistant-power
ip: 110
- name: usb-switch-1
ip: 111
mac: c8:2b:96:64:6a:37
- name: usb-switch-2
ip: 112
mac: c8:2b:96:64:68:a3
guest:
network: 192.168.70