Ansible leverages YAML manifest files called Playbooks. The Playbook will describe the infrastructure to build and is processed from top down. Here is a simple Playbook that will provision two identical servers:
example.yml:
- hosts:localhostconnection:localgather_facts:falsetasks: - name:Provision a set of instancesionoscloudsdk.ionoscloud.server:datacenter:Examplename:server%02dauto_increment:truecount:2cores:4ram:4096image:25cfc4fd-fe2f-11e6-afc5-525400f64d8dimage_password:secretpasswordlocation:us/lasassign_public_ip:trueremove_boot_volume:truestate:presentregister:ionos
⚠️ If you are using names instead of UUIDs to reference objects and they contain field marked with no_log (such as passwords), they may not work, so please use UUIDs instead in those cases!
NOT WORKING:
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
display_name: test
db_password: test
register: cluster_response
- name: Delete Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
postgres_cluster: "{{ cluster_response.postgres_cluster.properties.display_name }}"
state: absent
In this case you should use the UUID of the cluster as the above example will not work:
WORKING:
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
display_name: test
db_password: test
register: cluster_response
- name: Delete Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
postgres_cluster: "{{ cluster_response.postgres_cluster.id }}"
state: absent