From 8cf5f5d5a9c01076a979662875677bbecc7559f6 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 16 Oct 2018 00:37:20 -0400 Subject: [PATCH] allow setting a floating ip in config when using digitalocean --- config.cfg | 3 +++ roles/cloud-digitalocean/tasks/main.yml | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config.cfg b/config.cfg index f1721e5e..d61e404c 100644 --- a/config.cfg +++ b/config.cfg @@ -108,9 +108,12 @@ cloud_providers: azure: size: Basic_A0 image: 18.04-LTS + # To use floating_ip, first allocate a floating IP via Digital Ocean, and + # then set floating_ip to the IP address that was allocated. digitalocean: size: s-1vcpu-1gb image: "ubuntu-18-04-x64" + floating_ip: false # Change the encrypted flag to "true" to enable AWS volume encryption, for encryption of data at rest. # Warning: the Algo script will take approximately 6 minutes longer to complete. # Also note that the documented AWS minimum permissions aren't sufficient. diff --git a/roles/cloud-digitalocean/tasks/main.yml b/roles/cloud-digitalocean/tasks/main.yml index aca66b7b..99ad9e39 100644 --- a/roles/cloud-digitalocean/tasks/main.yml +++ b/roles/cloud-digitalocean/tasks/main.yml @@ -60,8 +60,16 @@ ipv6: yes register: do + - name: "Assigning floating IP..." + digital_ocean_floating_ip: + oauth_token: "{{ algo_do_token }}" + ip: "{{ cloud_providers.digitalocean.floating_ip }}" + droplet_id: "{{ do.droplet.id }}" + when: + - cloud_providers.digitalocean.floating_ip + - set_fact: - cloud_instance_ip: "{{ do.droplet.ip_address }}" + cloud_instance_ip: "{% if cloud_providers.digitalocean.floating_ip %}{{ cloud_providers.digitalocean.floating_ip }}{% else %}{{ do.droplet.ip_address }}{% endif %}" ansible_ssh_user: root - name: Tag the droplet