Skip to content

Commit 7b4cfa0

Browse files
committed
add inventories/custom/osseclab_minimal
1 parent e6aaa29 commit 7b4cfa0

File tree

11 files changed

+193
-0
lines changed

11 files changed

+193
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
template: "{{ inventory_dir }}/templates/default_config.j2"
3+
gns3_url: "http://172.16.253.1"
4+
gns3_lab_user: "{{ ansible_user }}"
5+
gns3_lab_pass: "{{ ansible_ssh_pass }}"
6+
project_name: "osseclab"
7+
gns3_nodes_spec:
8+
- name: "NAT"
9+
template: "NAT"
10+
x: 100
11+
y: -200
12+
- name: "gateway"
13+
template: "gateway"
14+
x: 0
15+
y: -200
16+
- name: "lan1"
17+
template: "Ethernet switch"
18+
x: -200
19+
y: -50
20+
- name: "srv1"
21+
template: "linux-server"
22+
x: -100
23+
y: 50
24+
- name: "lan2"
25+
template: "Ethernet switch"
26+
x: 200
27+
y: -50
28+
- name: "srv2"
29+
template: "linux-server"
30+
x: 300
31+
y: 50
32+
- name: "management"
33+
template: "Ethernet switch"
34+
x: 0
35+
y: 200
36+
- name: "controller"
37+
template: "controller"
38+
x: -100
39+
y: 250
40+
- name: "natctrl"
41+
template: "NAT"
42+
x: -350
43+
y: 250
44+
gns3_links_spec:
45+
- ["gateway", "Ethernet1", "NAT", "nat0"]
46+
- ["gateway", "Ethernet0", "lan1", "Ethernet0"]
47+
- ["gateway", "Ethernet2", "lan2", "Ethernet0"]
48+
- ["lan1", "Ethernet2", "srv1", "Ethernet0"]
49+
- ["lan2", "Ethernet2", "srv2", "Ethernet0"]
50+
- ["natctrl", "nat0", "controller", "Ethernet1"]
51+
- ["management", "Ethernet0", "controller", "Ethernet0"]
52+
- ["management", "Ethernet2", "srv1", "Ethernet1"]
53+
- ["management", "Ethernet4", "srv2", "Ethernet1"]
54+
- ["management", "Ethernet5", "gateway", "Ethernet3"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
hostname: srv1
3+
interfaces:
4+
- id: "System eth0"
5+
ipv4_address: "11.12.13.1/24"
6+
ipv4_dns: "11.12.13.1"
7+
login_prompt: "localhost login:"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
hostname: gateway
3+
domain: example.com
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
hostname: srv1
3+
interfaces:
4+
- id: "System eth0"
5+
ipv4_address: "192.168.1.10/24"
6+
ipv4_gateway: "192.168.1.1"
7+
ipv4_dns: "192.168.1.1"
8+
# ipv6_address: "2001:db8:acad:1060::50/64"
9+
# ipv6_gateway: "fe80::d1:3"
10+
login_prompt: "localhost login:"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
hostname: srv2
3+
interfaces:
4+
- id: "System eth0"
5+
ipv4_address: "192.168.2.20/24"
6+
ipv4_gateway: "192.168.2.1"
7+
ipv4_dns: "192.168.1.1"
8+
# ipv6_address: "2001:db8:acad:3085::50/64"
9+
# ipv6_gateway: "fe80::3:3"
10+
login_prompt: "localhost login:"
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[openwrt]
2+
gateway
3+
4+
[controllers]
5+
controller
6+
7+
[servers]
8+
srv1
9+
srv2
10+
11+
12+
[end_hosts:children]
13+
servers
14+
15+
[linux:children]
16+
end_hosts
17+
controllers
18+
19+
[openwrt:vars]
20+
image_style=openwrt
21+
ansible_network_os=""
22+
ansible_connection=ssh
23+
24+
[linux:vars]
25+
image_style=centos
26+
ansible_network_os=""
27+
ansible_connection=ssh
28+
29+
[all:vars]
30+
ansible_user=root
31+
ansible_ssh_pass=testtest
32+
ansible_port=22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rm -f /etc/machine-id
2+
systemd-machine-id-setup
3+
hostnamectl set-hostname {{ hostname }}
4+
echo {{ hostname }} > /etc/hostname
5+
echo "" > /etc/motd
6+
sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/g' /etc/ssh/sshd_config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
rm -f /etc/machine-id
2+
systemd-machine-id-setup
3+
hostnamectl set-hostname controller
4+
echo controller > /etc/hostname
5+
echo "" > /etc/motd
6+
sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/g' /etc/ssh/sshd_config
7+
echo "curl -s https://raw.githubusercontent.com/goffinet/ansible-ccna-lab/master/tests/almalinux9-controller.sh -o setup.sh" > readme.txt
8+
echo "bash setup.sh ; reboot" >> readme.txt
9+
{% for interface in interfaces %}
10+
nmcli c mod "{{ interface['id'] }}" ipv4.method manual ipv4.addresses {{ interface['ipv4_address'] }}
11+
nmcli c mod "{{ interface['id'] }}" ipv4.dns {{ interface['ipv4_dns'] }}
12+
nmcli c up "{{ interface['id'] }}"
13+
{% endfor %}
14+
#disown %1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% if inventory_hostname in groups['clients'] and image_style == "centos" %}
2+
{% include 'clients_config.j2' %}
3+
{% endif %}
4+
{% if inventory_hostname in groups['servers'] and image_style == "centos" %}
5+
{% include 'servers_config.j2' %}
6+
{% endif %}
7+
{% if inventory_hostname == "gateway" and image_style == "openwrt" %}
8+
{% include 'openwrt_config.j2' %}
9+
{% endif %}
10+
{% if inventory_hostname == "controller" and image_style == "centos" %}
11+
{% include 'controller_config.j2' %}
12+
{% endif %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
passwd {{ ansible_ssh_pass }}
2+
uci set network.lan2=interface
3+
uci set network.lan2.type='bridge'
4+
uci set network.lan2.ifname='eth2'
5+
uci set network.lan2.proto='static'
6+
uci set network.lan2.ipaddr='192.168.2.1'
7+
uci set network.lan2.netmask='255.255.255.0'
8+
uci set network.lan2.ip6assign='60'
9+
uci set network.management=interface
10+
uci set network.management.type='bridge'
11+
uci set network.management.ifname='eth3'
12+
uci set network.management.proto='dhcp'
13+
uci commit network
14+
/etc/init.d/network restart
15+
uci set dhcp.lan.domain='{{ domain }}'
16+
uci set dhcp.lan2.domain='{{ domain }}'
17+
uci set dhcp.lan2=dhcp
18+
uci set dhcp.lan2.interface='lan2'
19+
uci set dhcp.lan2.start='100'
20+
uci set dhcp.lan2.limit='150'
21+
uci set dhcp.lan2.leasetime='12h'
22+
uci set dhcp.lan2.dhcpv6='server'
23+
uci set dhcp.lan2.ra='server'
24+
uci commit dhcp
25+
/etc/init.d/odhcpd restart
26+
uci set firewall.@zone[0].network="$(uci get firewall.@zone[0].network) lan2"
27+
uci commit firewall
28+
/etc/init.d/firewall restart
29+
uci set system.@system[0].hostname="{{ hostname }}"
30+
uci commit system
31+
echo $(uci get system.@system[0].hostname) > /proc/sys/kernel/hostname
32+
/etc/init.d/dnsmasq reload
33+
opkg update && opkg install python3 openssh-sftp-server
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
rm -f /etc/machine-id
2+
systemd-machine-id-setup
3+
hostnamectl set-hostname {{ hostname }}
4+
echo {{ hostname }} > /etc/hostname
5+
sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/g' /etc/ssh/sshd_config
6+
{% for interface in interfaces %}
7+
nmcli c mod "{{ interface['id'] }}" ipv4.method manual ipv4.addresses {{ interface['ipv4_address'] }}
8+
nmcli c mod "{{ interface['id'] }}" ipv4.gateway {{ interface['ipv4_gateway'] }}
9+
nmcli c mod "{{ interface['id'] }}" ipv4.dns {{ interface['ipv4_dns'] }}
10+
nmcli c up "{{ interface['id'] }}"
11+
{% endfor %}
12+
echo "" > /etc/motd

0 commit comments

Comments
 (0)