community / community.general / 0.1.1 / module / digital_ocean_droplet Create and delete a DigitalOcean droplet Authors: Gurchet Rai (@gurch101) preview | supported by communitycommunity.general.digital_ocean_droplet (0.1.1) — module
Install with ansible-galaxy collection install community.general:==0.1.1
collections: - name: community.general version: 0.1.1
Create and delete a droplet in DigitalOcean and optionally wait for it to be active.
- name: create a new droplet digital_ocean_droplet: state: present name: mydroplet oauth_token: XXX size: 2gb region: sfo1 image: ubuntu-16-04-x64 wait_timeout: 500 ssh_keys: [ .... ] register: my_droplet
- debug: msg: "ID is {{ my_droplet.data.droplet.id }}, IP is {{ my_droplet.data.ip_address }}"
- name: ensure a droplet is present digital_ocean_droplet: state: present id: 123 name: mydroplet oauth_token: XXX size: 2gb region: sfo1 image: ubuntu-16-04-x64 wait_timeout: 500
- name: ensure a droplet is present with SSH keys installed digital_ocean_droplet: state: present id: 123 name: mydroplet oauth_token: XXX size: 2gb region: sfo1 ssh_keys: ['1534404', '1784768'] image: ubuntu-16-04-x64 wait_timeout: 500
id: aliases: - droplet_id description: - Numeric, the droplet id you want to operate on. ipv6: default: false description: - enable IPv6 for your droplet. required: false type: bool name: description: - String, this is the name of the droplet - must be formatted by hostname rules. size: aliases: - size_id description: - This is the slug of the size you would like the droplet created with. tags: description: - List, A list of tag names as strings to apply to the Droplet after it is created. Tag names can either be existing or new tags. required: false wait: default: true description: - Wait for the droplet to be active before returning. If wait is "no" an ip_address may not be returned. required: false type: bool image: aliases: - image_id description: - This is the slug of the image you would like the droplet created with. state: choices: - present - absent default: present description: - Indicate desired state of the target. region: aliases: - region_id description: - This is the slug of the region you would like your server to be created in. backups: default: false description: - indicates whether automated backups should be enabled. required: false type: bool volumes: description: - List, A list including the unique string identifier for each Block Storage volume to be attached to the Droplet. required: false ssh_keys: description: - array of SSH key Fingerprint that you would like to be added to the server. required: false user_data: description: - opaque blob of data which is made available to the droplet required: false monitoring: default: false description: - indicates whether to install the DigitalOcean agent for monitoring. required: false type: bool oauth_token: aliases: - API_TOKEN description: - DigitalOcean OAuth token. Can be specified in C(DO_API_KEY), C(DO_API_TOKEN), or C(DO_OAUTH_TOKEN) environment variables required: true unique_name: default: false description: - require unique hostnames. By default, DigitalOcean allows multiple hosts with the same name. Setting this to "yes" allows only one host per name. Useful for idempotence. type: bool wait_timeout: default: 120 description: - How long before wait gives up, in seconds, when creating a droplet. private_networking: default: false description: - add an additional, private network interface to droplet for inter-droplet communication. type: bool
data: description: a DigitalOcean Droplet returned: changed sample: droplet: backup_ids: [] created_at: '2014-11-14T16:36:31Z' disk: 20 features: - virtio id: 3164494 image: {} kernel: id: 2233 name: Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic version: 3.13.0-37-generic locked: true memory: 512 name: example.com networks: {} region: {} size: {} size_slug: 512mb snapshot_ids: [] status: new tags: - web vcpus: 1 volume_ids: [] ip_address: 104.248.118.172 ipv6_address: 2604:a880:400:d1::90a:6001 private_ipv4_address: 10.136.122.141 type: dict