Compare commits

...

3 Commits

Author SHA1 Message Date
Christer Warén
b059214c0a Update data directory location to be static in root user directory 2025-08-06 15:57:26 +03:00
Christer Warén
72af6d2110 Update DHCP server configuration 2025-08-06 15:51:31 +03:00
Christer Warén
587d9032ac Update network device configurations to INSTRUCTIONS.md 2025-08-06 15:28:04 +03:00
6 changed files with 212 additions and 151 deletions

View File

@@ -14,12 +14,12 @@
r1.net.tjas
```
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
!
hostname r1.net.tjas
!
boot-start-marker
@@ -61,28 +61,28 @@ interface FastEthernet0/1
interface FastEthernet0/1.10
description "TINU - INTERNET"
encapsulation dot1Q 10
ip address 192.168.1.1 255.255.255.0
ip address 192.168.1.1 255.255.255.224
ip helper-address 192.168.2.10
no snmp trap link-status
!
interface FastEthernet0/1.20
description "JUVA - INTRA"
encapsulation dot1Q 20
ip address 192.168.2.1 255.255.255.0
ip address 192.168.2.1 255.255.255.224
ip helper-address 192.168.2.10
no snmp trap link-status
!
interface FastEthernet0/1.30
description "AITO - TOIMISTO"
encapsulation dot1Q 30
ip address 192.168.3.1 255.255.255.0
ip address 192.168.3.1 255.255.255.224
ip helper-address 192.168.2.10
no snmp trap link-status
!
interface FastEthernet0/1.69
description "SIVE - HALLINTA"
encapsulation dot1Q 69
ip address 192.168.69.1 255.255.255.0
ip address 192.168.69.1 255.255.255.192
ip helper-address 192.168.69.20
no snmp trap link-status
!
@@ -95,11 +95,6 @@ ip classless
!
ip http server
!
access-list 1 permit 192.168.0.0
access-list 1 permit 192.168.1.0
access-list 1 permit 192.168.2.0
access-list 1 permit 192.168.3.0
access-list 1 deny any
!
control-plane
!
@@ -107,7 +102,7 @@ control-plane
line con 0
line aux 0
line vty 0 4
password ********
password TJAS1234
login
!
scheduler allocate 20000 1000
@@ -126,26 +121,27 @@ vlan 1
exit
vlan 10
name "TINU"
ip address 192.168.1.2 255.255.255.0
ip address 192.168.1.2 255.255.255.224
tagged 1
exit
vlan 20
name "JUVA"
no ip address
tagged 1-2
exit
vlan 30
name "AITO"
no ip address
tagged 1,3
exit
vlan 69
name "SIVE"
ip address 192.168.69.11 255.255.255.0
tagged 1,2,3
ip address 192.168.69.11 255.255.255.192
tagged 1-3
exit
ip authorized-managers 192.168.69.20
ip authorized-managers 192.168.69.20 255.255.255.255
ip ssh
password manager
```
s2.net.tjas
@@ -161,13 +157,13 @@ vlan 1
vlan 20
name "JUVA"
untagged 2-24
ip address 192.168.2.2 255.255.255.0
tagged 1
ip address 192.168.2.2 255.255.255.224
tagged 1-2
exit
vlan 69
name "SIVE"
ip address 192.168.69.12 255.255.255.0
tagged 1,2
ip address 192.168.69.12 255.255.255.192
tagged 1-2
exit
ip authorized-managers 192.168.69.20 255.255.255.255
ip ssh
@@ -186,14 +182,14 @@ vlan 1
exit
vlan 30
name "AITO"
untagged 2-24
ip address 192.168.3.2 255.255.255.0
tagged 1
ip address 192.168.3.2 255.255.255.224
tagged 1,13-24
untagged
exit
vlan 69
name "SIVE"
untagged 2-24
ip address 192.168.69.13 255.255.255.0
ip address 192.168.69.13 255.255.255.192
tagged 1
exit
ip authorized-managers 192.168.69.20 255.255.255.255

View File

@@ -106,20 +106,85 @@ authoritative;
# }
#}
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.2 192.168.1.254;
subnet 192.168.1.0 netmask 255.255.255.240 {
range 192.168.1.2 192.168.1.14;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
option broadcast-address 192.168.1.15;
host r1.net.tjas {
hardware ethernet 00:1d:46:dc:80:09;
fixed-address 192.168.1.1;
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.2 192.168.2.254;
host s1.net.tjas {
hardware ethernet 9c:8e:99:9b:c3:80;
fixed-address 192.168.1.2;
}
}
subnet 192.168.2.0 netmask 255.255.255.224 {
range 192.168.2.2 192.168.2.30;
option routers 192.168.2.1;
option broadcast-address 192.168.2.255;
option broadcast-address 192.168.2.31;
host r1.net.tjas {
hardware ethernet 00:1d:46:dc:80:09;
fixed-address 192.168.2.1;
}
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.2 192.168.3.254;
option routers 192.168.3.1;
option broadcast-address 192.168.3.255;
host s2.net.tjas {
hardware ethernet 00:24:a8:f1:c7:40;
fixed-address 192.168.2.2;
}
host olympus.intra.tjas {
hardware ethernet 90:1b:0e:5b:18:fa;
fixed-address 192.168.2.10;
}
}
subnet 192.168.3.0 netmask 255.255.255.224 {
range 192.168.3.2 192.168.3.30;
option routers 192.168.3.1;
option broadcast-address 192.168.3.31;
host r1.net.tjas {
hardware ethernet 00:1d:46:dc:80:09;
fixed-address 192.168.3.1;
}
host s3.net.tjas {
hardware ethernet 00:1f:fe:ab:9e:c0;
fixed-address 192.168.3.2;
}
}
subnet 192.168.69.0 netmask 255.255.255.192 {
range 192.168.69.2 192.168.69.62;
option broadcast-address 192.168.69.63;
host r1.net.tjas {
hardware ethernet 00:1d:46:dc:80:09;
fixed-address 192.168.69.1;
}
host s1.net.tjas {
hardware ethernet 9c:8e.99:9b:c3:80;
fixed-address 192.168.3.11;
}
host s2.net.tjas {
hardware ethernet 00:24:a8:f1:c7:40;
fixed-address 192.168.3.12;
}
host s3.net.tjas {
hardware ethernet 00:1f:fe:ab:9e:c0;
fixed-address 192.168.3.13;
}
host olympus.intra.tjas {
hardware ethernet 90:1b:0e:5b:18:fa;
fixed-address 192.168.69.20;
}
}

24
init.sh
View File

@@ -35,32 +35,32 @@ ti-header "Asennetaan PVJJK 1.VOS TJAS Infran riippuvuudet APT-paketinhallinnall
apt-get install -y python3-pip python3-venv jq git curl lsb-release
echo -e "\n\n"
mkdir -p ~/.ssh/keys/pvjjk-1vos-tjas &> /dev/null
if [[ ! -f ~/.ssh/keys/pvjjk-1vos-tjas/infra ]]
mkdir -p /root/.ssh/keys/pvjjk-1vos-tjas &> /dev/null
if [[ ! -f /root/.ssh/keys/pvjjk-1vos-tjas/infra ]]
then
ti-header "Generoidaan SSH-avain Infra-repon käyttöön..."
ssh-keygen -f ~/.ssh/keys/pvjjk-1vos-tjas/infra -t ed25519 -N '' -C $(hostname --fqdn)
ssh-keygen -f /root/.ssh/keys/pvjjk-1vos-tjas/infra -t ed25519 -N '' -C $(hostname --fqdn)
echo -e "\n\n"
fi
ti-header "Luodaan Ansiblelle virtuaalinen ympäristö..."
python3 -m venv ~/.venv/ansible
python3 -m venv /root/.venv/ansible
echo -e "\n\n"
ti-header "Asennetaan Ansiblen riippuvuudet..."
~/.venv/ansible/bin/pip3 install cryptography dnspython hvac jmespath netaddr pexpect
/root/.venv/ansible/bin/pip3 install cryptography dnspython hvac jmespath netaddr pexpect
echo -e "\n\n"
ti-header "Asennetaan Ansible..."
~/.venv/ansible/bin/pip3 install ansible
/root/.venv/ansible/bin/pip3 install ansible
echo -e "\n\n"
ti-header "Asennetaan Ansible kokoelmat..."
~/.venv/ansible/bin/ansible-galaxy collection install ansible.posix containers.podman --upgrade
/root/.venv/ansible/bin/ansible-galaxy collection install ansible.posix containers.podman --upgrade
echo -e "\n\n"
ti-header "Lisää SSH-avain Infra-repon käyttöön..."
cat ~/.ssh/keys/pvjjk-1vos-tjas/infra.pub
cat /root/.ssh/keys/pvjjk-1vos-tjas/infra.pub
echo -n "Onko avain lisätty Github-repoon? [K/E]"
while [[ -z $SSHKEY_QUESTION || ! -z $SSHKEY_QUESTION && $SSHKEY_QUESTION != "K" ]]
@@ -69,8 +69,8 @@ do
done
echo -e "\n\n"
mkdir -p ~/.ansible/vault &> /dev/null
if [[ ! -f ~/.ansible/vault/pvjjk-1vos-tjas ]]
mkdir -p /root/.ansible/vault &> /dev/null
if [[ ! -f /root/.ansible/vault/pvjjk-1vos-tjas ]]
then
ti-header "Syötä Ansible Vaultin salasana..."
echo -n "Salasana: "
@@ -80,14 +80,14 @@ then
if [[ ! -z $VAULT_PASSWORD ]]
then
echo "$VAULT_PASSWORD" > ~/.ansible/vault/pvjjk-1vos-tjas
echo "$VAULT_PASSWORD" > /root/.ansible/vault/pvjjk-1vos-tjas
fi
done
echo -e "\n\n"
fi
ti-header "Suoritetaan Infran asennus..."
~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d ~/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key ~/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file ~/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t installer
/root/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d /root/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key /root/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file /root/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t installer
echo -e "\n\n"
echo "

View File

@@ -2,7 +2,7 @@
- name: "Deployer - SSH - Add Authorized Keys"
ansible.builtin.template:
src: './files/ssh/authorized_keys'
dest: '~/.ssh/authorized_keys'
dest: '/root/.ssh/authorized_keys'
tags:
- ssh
@@ -24,14 +24,14 @@
- name: "Deployer - Yggdrasil - Configure - Create Folder"
ansible.builtin.file:
path: "~/data/yggdrasil/"
path: "/root/data/yggdrasil/"
state: directory
tags:
- yggdrasil
- name: "Deployer - Yggdrasil - Configure - Create Subfolders"
ansible.builtin.file:
dest: '~/data/yggdrasil/{{ item.path }}'
dest: '/root/data/yggdrasil/{{ item.path }}'
state: directory
with_filetree: './files/yggdrasil/'
loop_control:
@@ -44,7 +44,7 @@
- name: "Deployer - Yggdrasil - Configure - Generating & Transferring Files"
ansible.builtin.template:
src: '{{ item.src }}'
dest: '~/data/yggdrasil/{{ item.path }}'
dest: '/root/data/yggdrasil/{{ item.path }}'
register: deployerTaskY1
with_filetree: './files/yggdrasil/'
loop_control:
@@ -71,7 +71,7 @@
containers.podman.podman_image:
name: pvjjk-1vos-tjas/nginx
tag: latest
path: "~/data/yggdrasil"
path: "/root/data/yggdrasil"
build:
format: docker
force: true
@@ -120,7 +120,7 @@
- name: "Deployer - MariaDB - Create Folder"
ansible.builtin.file:
path: ~/data/mariadb
path: /root/data/mariadb
state: directory
tags:
- mariadb
@@ -140,7 +140,7 @@
restart: on
network: host
volumes:
- "~/data/mariadb:/var/lib/mysql"
- "/root/data/mariadb:/var/lib/mysql"
restart_policy: always
env:
MYSQL_ROOT_PASSWORD: "{{ config.mariadb.users.root.password }}"
@@ -207,14 +207,14 @@
- name: "Deployer - PowerDNS - Configure - Create Folder"
ansible.builtin.file:
path: "~/data/powerdns/"
path: "/root/data/powerdns/"
state: directory
tags:
- powerdns
- name: "Deployer - PowerDNS - Configure - Create Subfolders"
ansible.builtin.file:
dest: '~/data/powerdns/{{ item.path }}'
dest: '/root/data/powerdns/{{ item.path }}'
state: directory
with_filetree: './files/powerdns/'
loop_control:
@@ -227,7 +227,7 @@
- name: "Deployer - PowerDNS - Configure - Generating & Transferring Files"
ansible.builtin.template:
src: '{{ item.src }}'
dest: '~/data/powerdns/{{ item.path }}'
dest: '/root/data/powerdns/{{ item.path }}'
register: deployerTaskP1
with_filetree: './files/powerdns/'
loop_control:
@@ -253,7 +253,7 @@
network: host
restart_policy: always
volumes:
- "~/data/powerdns/config.conf:/etc/powerdns/pdns.conf:ro"
- /root/data/powerdns/config.conf:/etc/powerdns/pdns.conf:ro"
when:
- (deployerTaskP1 is defined and deployerTaskP1.changed) or deployerTaskP1 is undefined or (deployerTaskP2 is defined and deployerTaskP2.changed) or deployerTaskP2 is undefined
tags:
@@ -261,14 +261,14 @@
- name: "Deployer - Nginx - Configure - Create Folder"
ansible.builtin.file:
path: "~/data/nginx/"
path: "/root/data/nginx/"
state: directory
tags:
- nginx
- name: "Deployer - Nginx - Configure - Create Subfolders"
ansible.builtin.file:
dest: '~/data/nginx/{{ item.path }}'
dest: '/root/data/nginx/{{ item.path }}'
state: directory
with_filetree: './files/nginx/'
loop_control:
@@ -281,7 +281,7 @@
- name: "Deployer - Nginx - Configure - Generating & Transferring Files"
ansible.builtin.template:
src: '{{ item.src }}'
dest: '~/data/nginx/{{ item.path }}'
dest: '/root/data/nginx/{{ item.path }}'
register: deployerTaskN1
with_filetree: './files/nginx/'
loop_control:

View File

@@ -12,14 +12,14 @@
- "task.stdout.find('0 upgraded, 0 newly installed, 0 to remove') == -1"
- name: "Init : Python 3 : Configure - Virtual Environment : Test"
ansible.builtin.raw: "~/.venv/ansible/bin/pip3"
ansible.builtin.raw: "/root/.venv/ansible/bin/pip3"
register: task632
changed_when: false
failed_when: false
- name: "Init : Python 3 : Configure - Virtual Environment : Delete"
ansible.builtin.file:
path: "~/.venv/ansible"
path: "/root/.venv/ansible"
state: absent
when:
- "task632.stdout.find(\"ModuleNotFoundError: No module named 'pip'\") != -1"
@@ -29,7 +29,7 @@
name: pip
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
- name: "Installer : Tools : Install"
@@ -102,22 +102,22 @@
name: ansible
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
tags:
- ansible
- name: "Installer : Ansible : Create Folder"
ansible.builtin.file:
path: ~/bin
path: /root/bin
state: directory
tags:
- ansible
- name: "Installer : Ansible : Create Symbolic Links"
ansible.builtin.file:
src: ~/.venv/ansible/bin/{{ binary }}
dest: ~/bin/{{ binary }}
src: /root/.venv/ansible/bin/{{ binary }}
dest: /root/bin/{{ binary }}
state: link
vars:
binaries:
@@ -144,7 +144,7 @@
name: "{{ library }}"
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
vars:
libraries:
@@ -164,7 +164,7 @@
name: pymysql
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
tags:
- mariadb
@@ -184,7 +184,7 @@
name: "PVJJK 1.VOS TJAS - Infra - Maintenance"
hour: "*/3"
minute: "0"
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d ~/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key ~/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file ~/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t maintenance"
job: "/root/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d /root/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key /root/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file /root/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t maintenance"
tags:
- cron
@@ -192,6 +192,6 @@
ansible.builtin.cron:
name: "PVJJK 1.VOS TJAS - Infra - Deployer"
minute: "*/5"
job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d ~/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key ~/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file ~/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t deployer"
job: "/root/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/cwchristerw/tjas-infra -d /root/.ansible/pull/pvjjk-1vos-tjas/infra --accept-host-key --private-key /root/.ssh/keys/pvjjk-1vos-tjas/infra --vault-password-file /root/.ansible/vault/pvjjk-1vos-tjas tasks.yml -t deployer"
tags:
- cron

View File

@@ -4,7 +4,7 @@
name: "{{ library }}"
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
vars:
libraries:
@@ -24,7 +24,7 @@
name: ansible
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
- name: "Maintenance : MariaDB : Dependencies / Python Library : pymysql"
@@ -32,7 +32,7 @@
name: pymysql
state: latest
extra_args: --upgrade
virtualenv: ~/.venv/ansible
virtualenv: /root/.venv/ansible
virtualenv_command: "python3 -m venv"
- name: "Maintenance : Podman : Prune"