Repository URL to install this package:
Version:
6.0.0 ▾
|
.. |
changelogs |
meta |
plugins |
scripts |
CHANGELOG.rst |
COPYING |
FILES.json |
MANIFEST.json |
README.md |
codecov.yml |
This collection contains modules and plugins to assist in automating DigitalOcean infrastructure and API interactions with Ansible.
Tested with the current Ansible 2.9 and 2.10 releases and the current development version of Ansible. Ansible versions before 2.9.10 are not supported.
Before using the DigitalOcean collection, you need to install it with the Ansible Galaxy CLI:
ansible-galaxy collection install community.digitalocean
You can also include it in a requirements.yml
file and install it via ansible-galaxy collection install -r requirements.yml
, using the format:
--- collections: - name: community.digitalocean
It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example community.digitalocean.digital_ocean_droplet
:
--- - hosts: localhost gather_facts: false connection: local vars: oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" tasks: - name: Create SSH key community.digitalocean.digital_ocean_sshkey: oauth_token: "{{ oauth_token }}" name: mykey ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example" state: present register: my_ssh_key - name: Create a new Droplet community.digitalocean.digital_ocean_droplet: oauth_token: "{{ oauth_token }}" state: present name: mydroplet unique_name: true size: s-1vcpu-1gb region: sfo3 image: ubuntu-20-04-x64 wait_timeout: 500 ssh_keys: - "{{ my_ssh_key.data.ssh_key.id }}" register: my_droplet - name: Show Droplet info ansible.builtin.debug: msg: | Droplet ID is {{ my_droplet.data.droplet.id }} First Public IPv4 is {{ (my_droplet.data.droplet.networks.v4 | selectattr('type', 'equalto', 'public')).0.ip_address | default('<none>', true) }} First Private IPv4 is {{ (my_droplet.data.droplet.networks.v4 | selectattr('type', 'equalto', 'private')).0.ip_address | default('<none>', true) }} - name: Tag a resource; creating the tag if it does not exist community.digitalocean.digital_ocean_tag: oauth_token: "{{ oauth_token }}" name: "{{ item }}" resource_id: "{{ my_droplet.data.droplet.id }}" state: present loop: - staging - dbserver
If upgrading older playbooks which were built prior to Ansible 2.10 and this collection's existence, you can also define collections
in your play and refer to this collection's modules as you did in Ansible 2.9 and below, as in this example:
--- - hosts: localhost gather_facts: false connection: local collections: - community.digitalocean tasks: - name: Create ssh key digital_ocean_sshkey: oauth_token: "{{ oauth_token }}" ...
If you want to develop new content for this collection or improve what's already here, the easiest way to work on the collection is to clone it into one of the configured COLLECTIONS_PATHS
, and work on it there.
ansible-test
The tests
directory contains configuration for running sanity and integration tests using ansible-test
.
You can run the collection's test suites with the commands:
ansible-test sanity --docker -v --color
ansible-test integration --docker -v --color
Note: To run integration tests, you must add an integration_config.yml
file with a valid DigitalOcean API key (using variable do_api_key
).
See the changelog.
Releases are automatically built and pushed to Ansible Galaxy for any new tag. Before tagging a release, make sure to do the following:
galaxy.yml
and this README's requirements.yml
example with the new version
for the collection. Make sure all new modules have references above.antsibull-changelog
installed.changelogs/fragments
.antsibull-changelog release
.galaxy.yml
.After the version is published, verify it exists on the DigitalOcean Collection Galaxy page.
GNU General Public License v3.0 or later.
See COPYING to see the full text.