diff --git a/test/legacy/Makefile b/test/legacy/Makefile index 1c04b4599d5..65a471a4a35 100644 --- a/test/legacy/Makefile +++ b/test/legacy/Makefile @@ -44,6 +44,11 @@ amazon_cleanup: azure_cleanup: python cleanup_azure.py -y --match="^$(CLOUD_RESOURCE_PREFIX)" +digital_ocean: $(CREDENTIALS_FILE) + ansible-playbook digital_ocean.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) ; \ + RC=$$? ; \ + exit $$RC; + gce_setup: python setup_gce.py "$(CLOUD_RESOURCE_PREFIX)" diff --git a/test/legacy/credentials.template b/test/legacy/credentials.template index b183e469381..72e30f9f56e 100644 --- a/test/legacy/credentials.template +++ b/test/legacy/credentials.template @@ -22,3 +22,5 @@ azure_cert_path: "{{ lookup('env', 'AZURE_CERT_PATH') }}" cloudflare_api_token: cloudflare_email: cloudflare_zone: + +digitalocean_oauth_token: "{{ lookup('env', 'DO_API_TOKEN') }}" diff --git a/test/legacy/digital_ocean.yml b/test/legacy/digital_ocean.yml new file mode 100644 index 00000000000..f87a5227b70 --- /dev/null +++ b/test/legacy/digital_ocean.yml @@ -0,0 +1,9 @@ +- hosts: localhost + connection: local + gather_facts: no + tags: + - test_digital_ocean + vars: + dummy_ssh_pub_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzTSH4WVqnK2kUgtbs2VryNUXBaox7SoXPmV4yMP4INPAndrtPTS3BRzBPrJwQSwjsT7y3kBLNIHGppxLFMoQTEL03WlMDfM1TthMT7Y5B65wOUMxdwbSn9zlblAqbbRg7XU/UgNZb+B2kBPepPRJlh1ap4CPTNrbzdKlmwqS4X3+hX/WM3Gt3S09eNxUKDBK18Fbf/yKvhXP4bGtD0cxYNKL4qoGjEZTkjiYQyC4TvfuZaUtOFpiMLPAt0V7ao2S2bKr8hAgxl9MtrJpa2q1FueAjljMSBWUhOjFgmO0SpWDcBu157vMtscmtUC2cMpQwAY2HQyMJAYs0HOa59dpUKtxBR3LwjXyZvL+RbjEbzZjp4JQSer/bB/jekrxHAIABCwdFmx6qBGNVqDdfT7o+OcEJaAvk4gKEFI24OU8k6WF4ss97VfxlvIT6Bq2p04oUsxN0qh9aSjRVfqJmhkSocf+1iGWGfa4DMFpeQAXCzUkhJS5ecYXSDmyMHGtl7OfhLnncUDHVRjhsmrCFb5kkHHVfNd601ixixydInlssUhQRRzhnJ+ciTh/x7ARDfwMendHTTHCj5sO1IvnOJdCcX4FTMKp1GLo6eaK738o9w4rWL0bs3kWJfxWg91QegwZW0r8xSJBtga7HyQafxivhwEN8knN8HuD47iBuAL+VTw== + roles: + - { role: test_digital_ocean, tags: test_digital_ocean } diff --git a/test/legacy/roles/test_digital_ocean/tasks/floating_ip.yml b/test/legacy/roles/test_digital_ocean/tasks/floating_ip.yml new file mode 100644 index 00000000000..2f456b2573f --- /dev/null +++ b/test/legacy/roles/test_digital_ocean/tasks/floating_ip.yml @@ -0,0 +1,38 @@ +--- + +- name: "Make sure that the Floating IP is absent" + digital_ocean_floating_ip: + state: absent + ip: "8.8.8.8" + oauth_token: "{{ digitalocean_oauth_token }}" + register: result + +- name: Verify that the Floating IP didn't change + assert: + that: + - "not result.changed" + +- name: "Create a Floating IP" + digital_ocean_floating_ip: + state: present + region: "lon1" + oauth_token: "{{ digitalocean_oauth_token }}" + register: result + +- name: Verify that a Floating IP was created + assert: + that: + - "result.changed" + +- name: "Destroy Floating IP" + digital_ocean_floating_ip: + state: absent + ip: "{{ result.data.floating_ip.ip }}" + region: "lon1" + oauth_token: "{{ digitalocean_oauth_token }}" + register: result + +- name: Verify that a Floating IP was deleted + assert: + that: + - " result.changed" diff --git a/test/legacy/roles/test_digital_ocean/tasks/main.yml b/test/legacy/roles/test_digital_ocean/tasks/main.yml new file mode 100644 index 00000000000..009ca43be57 --- /dev/null +++ b/test/legacy/roles/test_digital_ocean/tasks/main.yml @@ -0,0 +1,4 @@ +- name: SSH Key module tests + include: tasks/sshkey.yml +- name: Floating IPs module tests + include: tasks/floating_ip.yml diff --git a/test/legacy/roles/test_digital_ocean/tasks/sshkey.yml b/test/legacy/roles/test_digital_ocean/tasks/sshkey.yml new file mode 100644 index 00000000000..a6a964e70dc --- /dev/null +++ b/test/legacy/roles/test_digital_ocean/tasks/sshkey.yml @@ -0,0 +1,25 @@ +--- + +- name: Create ssh key + digital_ocean_sshkey: + name: test-key1 + ssh_pub_key: "{{ dummy_ssh_pub_key }}" + oauth_token: "{{ digitalocean_oauth_token }}" + register: result + +- name: Verify that SSH key was created + assert: + that: + - "result.changed" + +- name: "Delete ssh key" + digital_ocean_sshkey: + state: "absent" + fingerprint: "{{ result.data.ssh_key.fingerprint }}" + oauth_token: "{{ digitalocean_oauth_token }}" + register: result + +- name: Verify that SSH key was deleted + assert: + that: + - "result.changed"