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/05__introducing_roles sub-directory.
01__create_jumpbox_and_nlb.yml
---# Unlike main.yml (which communicates with the IONOS Cloud Ansible module via# localhost), _this_ playbook is run on / within the VM- hosts:example-servervars:# roles that will be applied iterately at the _end_ of this play --- note# that 'common/base-server' is explicitly applied below (e.g. to update# the system's packages), while the nfs-server and -client roles are also# applied explicitly due to their role-specific parametersroles_to_apply: - common/fail2ban - docker-servertasks:# Perform some basic / preparatory tasks - name:Update repositories cache and upgrade the systemansible.builtin.apt:upgrade:distupdate_cache:yescache_valid_time:3600 - name:Gather the package factsansible.builtin.package_facts:manager:auto# An example of the simplest way to include a role - name:Apply the common 'base-server' roleinclude_role:name:common/base-server# Examples of how variables can be passed to included roles - name:Apply the 'nfs-server' roleinclude_role:name:nfs-servervars: - export_root:/export - export_specifier:"127.0.0.1(ro,sync,no_subtree_check,no_root_squash)" - name:Apply the 'nfs-client' roleinclude_role:name:nfs-clientvars:nfs_mount_point:/mntnfs_server_path:"127.0.0.1:/export"# And finally, an example of how one might apply a list of roles - name:And apply the remaining roles to target systeminclude_role:name:"{{ role }}"with_items:"{{ roles_to_apply }}"loop_control:loop_var:role