diff --git a/auto-complete.sh b/auto-complete.sh index ec97875..329283d 100755 --- a/auto-complete.sh +++ b/auto-complete.sh @@ -4,7 +4,7 @@ function libs() { if [ "$1" != "" ]; then - COMPREPLY=($(compgen -W "all xelatex-thesis network-scanning network-adhoc raspi-docker tech-list faq sensor-node ssh-tunneling iptables poc-datacollector help" "${COMP_WORDS[$COMP_CWORD]}")) + COMPREPLY=($(compgen -W "all xelatex-thesis infrastructure-as-code network-scanning network-adhoc raspi-docker tech-list faq sensor-node ssh-tunneling iptables poc-datacollector help" "${COMP_WORDS[$COMP_CWORD]}")) fi } diff --git a/build.sh b/build.sh index bf5d1e9..10152f2 100755 --- a/build.sh +++ b/build.sh @@ -35,6 +35,8 @@ usage () echo "" echo -e " ${txtg}iptables:${NOCOLOR} This tutorial demonstrates, howto setup iptables & howto use it " echo "" + echo -e " ${txtg}infrastructure-as-code:${NOCOLOR} This tutorial demonstrates, howto use ansible to implement Infrastructure as Code " + echo "" echo -e " ${txtg}network-scanning:${NOCOLOR} This tutorial demonstrates some common nmap port scanning scenarios and explains the output. " echo "" echo -e " ${txtg}network-adhoc:${NOCOLOR} This tutorial demonstrates, howto setup ad-hoc network & howto use it " @@ -114,6 +116,13 @@ do COMMAND_CREATE=1 ;; + infrastructure-as-code) + DESC="infrastructure-as-code" ; + build="build.sh" ; + docdir="infrastructure-as-code" ; + COMMAND_CREATE=1 + ;; + xelatex-thesis) DESC="xelatex-thesis" ; build="build.sh" ; diff --git a/infrastructure-as-code/antora.yml b/infrastructure-as-code/antora.yml new file mode 100644 index 0000000..144a7b2 --- /dev/null +++ b/infrastructure-as-code/antora.yml @@ -0,0 +1,5 @@ + name: swarmlab_infrastructure-as-code + title: swarmlab_infrastructure-as-code + version: docs + nav: + - modules/ROOT/nav.adoc diff --git a/infrastructure-as-code/modules/ROOT/images/adhoc.png b/infrastructure-as-code/modules/ROOT/images/adhoc.png new file mode 100644 index 0000000..6256678 Binary files /dev/null and b/infrastructure-as-code/modules/ROOT/images/adhoc.png differ diff --git a/infrastructure-as-code/modules/ROOT/images/swarmlab.png b/infrastructure-as-code/modules/ROOT/images/swarmlab.png new file mode 100644 index 0000000..d94ea42 Binary files /dev/null and b/infrastructure-as-code/modules/ROOT/images/swarmlab.png differ diff --git a/infrastructure-as-code/modules/ROOT/images/trafic.png b/infrastructure-as-code/modules/ROOT/images/trafic.png new file mode 100644 index 0000000..d7e160a Binary files /dev/null and b/infrastructure-as-code/modules/ROOT/images/trafic.png differ diff --git a/infrastructure-as-code/modules/ROOT/images/vehigle.png b/infrastructure-as-code/modules/ROOT/images/vehigle.png new file mode 100644 index 0000000..46d0c6b Binary files /dev/null and b/infrastructure-as-code/modules/ROOT/images/vehigle.png differ diff --git a/infrastructure-as-code/modules/ROOT/nav.adoc b/infrastructure-as-code/modules/ROOT/nav.adoc new file mode 100644 index 0000000..a1d398a --- /dev/null +++ b/infrastructure-as-code/modules/ROOT/nav.adoc @@ -0,0 +1 @@ +* xref:index.adoc[ansible] diff --git a/infrastructure-as-code/modules/ROOT/pages/index-setup.adoc b/infrastructure-as-code/modules/ROOT/pages/index-setup.adoc new file mode 100644 index 0000000..8f48287 --- /dev/null +++ b/infrastructure-as-code/modules/ROOT/pages/index-setup.adoc @@ -0,0 +1,354 @@ += Setup + +TIP: Tested on a Raspberry Pi with "Buster" + +== Intro + +networkd is a small and lean service to configure network interfaces, designed mostly for server use cases in a world with hotplugged and virtualized networking. Its configuration is similar in spirit and abstraction level to ifupdown, but you don't need any extra packages to configure bridges, bonds, vlan etc. It is not very suitable for managing WLANs yet; NetworkManager is still much more appropriate for such Desktop use cases. + + There are mainly three setups to have a peer to peer network: + +* unprotected ad-hoc interface by configuring the WiFi device +* unprotected ad-hoc interface using wpa_supplicant (Recommended) +* Only with suitable (RSN-IBSS capable) USB dongle: +* protected ad-hoc interface using wpa_supplicant and WPA encryption (best solution if possible) +* ad-hoc interface with additional USB/WiFi dongle for uplink to internet router + + +== Install systemd-networkd + +=== deinstall classic networking and install it! + +* *sudo su* # if not already done + +*deinstall* +[source,sh] +---- +systemctl daemon-reload +systemctl disable --now ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog +apt --autoremove purge -f ifupdown dhcpcd dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog +rm -r /etc/network /etc/dhcp + +# setup/enable systemd-resolved and systemd-networkd + +systemctl disable --now avahi-daemon libnss-mdns +apt --autoremove -f purge avahi-daemon +apt install -f libnss-resolve +ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf +apt-mark hold avahi-daemon dhcpcd dhcpcd5 ifupdown isc-dhcp-client isc-dhcp-common libnss-mdns openresolv raspberrypi-net-mods rsyslog +systemctl enable systemd-networkd.service systemd-resolved.service +---- + + +== Install optional + +[source,sh] +---- +apt-get install raspberrypi-kernel-headers -y +---- + + + +=== setup wired connection + +*wired connection* +[source,sh] +---- +cat > /etc/systemd/network/04-wired.network < +Gateway=192.168.1.1 // <2> +DNS=8.8.8.8 1.1.1.1 // <3> +MulticastDNS=yes +EOF +---- +<1> use your settings +<2> use your settings +<2> use your settings + + +=== Reboot + +NOTE: reboot + +== Config + + +=== NSS + +*config nss* +[source,sh] +---- +apt --autoremove purge avahi-daemon +apt-mark hold avahi-daemon +apt install -f libnss-resolve + +echo "" +echo "For troubleshooting you may have a look at /etc/nsswitch.conf. It should contain a line like this:" +echo "" +echo "hosts: files resolve [!UNAVAIL=return] dns" +echo "" +echo "" +echo "" +echo "" +---- + + +=== DNS + + +*config dns* +[source,sh] +---- + +echo "" +echo "Configure DNS stub listener interface" +echo "" + +echo "Here we have to symlink /etc/resolv.conf to the stub listener:" +echo "" +echo " exec4you ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf" +ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf +echo "" + +echo "Check name resolution" + + +resolvectl status +---- + +== unprotected ad-hoc interface using wpa_supplicant + +Follow *Install systemd-networkd* + +Then come back here. + +TIP: unprotected + +* *sudo su* # if not already done + +[source,sh] +---- + +cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf < /etc/wpa_supplicant/wpa_supplicant-wlan1.conf <running Containers->Actions [microservice-ansible_masterservice_1] + +*** connect [Open a terminal and Run] + +=== find examples + +* Run "microservice-ansible" + +** Instances->running Containers->Actions [microservice-ansible_masterservice_1] + +*** connect [Project BaseDir] + +cd in [Project BaseDir]/examples + +=== Attach network + +* Run "microservice-ansible" + +** Instances->running Containers->Actions [microservice-ansible_masterservice_1] + +*** Networks->"Select Network" + + +== Scenario + +=== run swarm + +* Run "hybrid-linux" + +** Labroom->"Swarmlab LabRoom Deploy - Local "->Actions [hybrid-linux] + +*** Number of Instances (e.g. 5) -> Up + +=== run ansible + +* Run "microservice-ansible" + +** Instances->running Containers->Actions [microservice-ansible_masterservice_1] + +*** connect [Open a terminal and Run] + +=== Attach network + +* Run "microservice-ansible" + +** Instances->running Containers->Actions [microservice-ansible_masterservice_1] + +*** Networks->"Select Network" [network hybrid linux] + + +==== +Terminal: microservice-ansible + +cd /home/docker/project/examples + +edit inverntory.yml (ifconfig, nmap etc) + +run fluentd.yml.sh + +==== + + + + + diff --git a/infrastructure-as-code/run/build-intro.sh b/infrastructure-as-code/run/build-intro.sh new file mode 100755 index 0000000..af181d8 --- /dev/null +++ b/infrastructure-as-code/run/build-intro.sh @@ -0,0 +1,4 @@ +antora --fetch /antora/site-intro.yml +antora /antora/site-intro.yml +ifconfig +http-server build/site -c-1 diff --git a/infrastructure-as-code/run/build.sh b/infrastructure-as-code/run/build.sh new file mode 100755 index 0000000..7122c21 --- /dev/null +++ b/infrastructure-as-code/run/build.sh @@ -0,0 +1,4 @@ +antora --fetch /antora/site.yml +antora /antora/site.yml +ifconfig +http-server build/site -c-1 diff --git a/infrastructure-as-code/site.yml b/infrastructure-as-code/site.yml new file mode 100644 index 0000000..a2d0792 --- /dev/null +++ b/infrastructure-as-code/site.yml @@ -0,0 +1,21 @@ +site: + title: Swarmlab infrastructure-as-code + url: http://docs.swarmlab.io/SwarmLab-HowTos/swarmlab/docs + start_page: swarmlab_infrastructure-as-code::index.adoc +content: + sources: + - url: https://git.swarmlab.io:3000/docs/Documentation.git + branches: master + start_path: infrastructure-as-code +ui: + bundle: + url: https://git.swarmlab.io:3000/docs/docs/raw/branch/master/ui-bundle.zip + snapshot: true + supplemental_files: ./supplemental-ui +asciidoc: + attributes: + :plantuml-server-url: http://www.plantuml.com/plantuml + extensions: + - '@djencks/asciidoctor-mathjax' + - asciidoctor-plantuml + diff --git a/site.yml b/site.yml index 32808a7..fec440c 100644 --- a/site.yml +++ b/site.yml @@ -45,6 +45,10 @@ content: - url: https://git.swarmlab.io:3000/docs/Documentation.git branches: master start_path: xelatex-thesis + + - url: https://git.swarmlab.io:3000/docs/Documentation.git + branches: master + start_path: infrastructure-as-code ui: bundle: url: https://git.swarmlab.io:3000/docs/docs/raw/branch/master/ui-bundle.zip