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
---- hosts:localhostconnection:localgather_facts:falsevars_files: - ../vars.yml - vars.ymltasks:# ======================================================================= - name:Display EULAansible.builtin.pause:prompt:"{{ IONOS_UNSUPPORTED_EULA }}"register:INTERACTIVE_EULA_ACCEPTEDwhen:IONOS_UNSUPPORTED_EULA_ACCEPTED != "yes" - name:Confirm acceptance of EULAansible.builtin.assert:that: - IONOS_UNSUPPORTED_EULA_ACCEPTED == "yes" or INTERACTIVE_EULA_ACCEPTED.user_input == "yes"# ======================================================================= - name:Create the datacenter '{{ datacenter_name }}' in {{ location }}ionoscloudsdk.ionoscloud.datacenter:name:"{{ datacenter_name }}"location:"{{ location }}"state:presentregister:datacenter_response - name:Create the server '{{ server_name }}'ionoscloudsdk.ionoscloud.server:datacenter:"{{ datacenter_response.datacenter.properties.name }}"name:"{{ server_name }}"cores:"1"ram:"1024"cpu_family:"{{ datacenter_response.datacenter.properties.cpu_architecture[0].cpu_family }}"assign_public_ip:truedisk_type:HDDvolume_size:"10"image:"{{ image_alias }}"image_password:"{{ default_password }}"ssh_keys: - "{{ ssh_public_key }}"state:presentwait:truewait_timeout:"{{ wait_timeout }}"register:create_server_response# Borrowed from 3__jumpbox_with_internal_server - name:Create a local ssh_config fileansible.builtin.template:src:templates/ssh_config.j2dest:ssh_config - name:Create a local / 'nested' Ansible inventory.yml fileansible.builtin.shell:cmd:| (cat <<EOF --- servers: hosts: example-server: all: vars: ansible_ssh_common_args: "-F ssh_config" EOF ) > inventory.yml - name:Delete any pre-existing ssh_known_hosts_tmp fileansible.builtin.shell:rm -f ssh_known_hosts_tmp