The source files for this tutorial can be downloaded from its GitHub repository, or cloned into your current working directory using the command git clone https://github.com/ionos-cloud/module-ansible.git before changing into the module-ansible/docs/tutorials/07__introducing_the_application_load_balancer sub-directory.
01__create_jumpbox_and_nlb.yml
---- hosts:app-serversvars_files: - vars.ymltasks:# Apply some basic network configurations needed, since these VMs are# behind the NAT Gateway and don't have access to a 'full' DHCP server - name:Set our default routeansible.builtin.shell:"ip route add default via {{ nat_gateway.ip }} || true"# Arguably not the most robust solution, but while an approach based upon,# say, https://stackoverflow.com/a/67379573 would guarantee the resulting# file is always valid, assuming the level of indention doesn't change,# the following is simpler, and doesn't remove any comments that said file# might contain - name:Add our default route to /etc/netplan/50-cloud-init.yaml to make it persistentblockinfile:path:/etc/netplan/50-cloud-init.yamlinsertbefore:"match:"block:|<div data-gb-custom-block data-tag="filter" data-width='12' data-idth='12' data-first='true'>routes: - to:defaultvia:192.168.8.1</div> - name:Ensure 'DNS=212.227.123.16 212.227.123.17' is in the '[Resolve]' section of /etc/systemd/resolved.confcommunity.general.ini_file:path:/etc/systemd/resolved.confsection:Resolveoption:DNSvalue:212.227.123.16 212.227.123.17state:present - name:Restart the systemd-resolved serviceansible.builtin.service:name:systemd-resolvedstate:restarted - name:Update repositories cache and upgrade the systemansible.builtin.apt:upgrade:distupdate_cache:yescache_valid_time:3600 - name:Install nginxansible.builtin.package:name: - nginxstate:present - name:And create our per-host index.html files on the remote serversansible.builtin.template:src:templates/index.html.j2dest:/var/www/html/index.html