From d1c21d62b7e8bdcc2886e671c8ef332004f80d49 Mon Sep 17 00:00:00 2001 From: Jack Ivanov Date: Wed, 20 Nov 2019 12:30:40 +0100 Subject: [PATCH] Add Scaleway --- config.cfg | 1 - roles/cloud-scaleway/tasks/main.yml | 31 ++++++++++++++++++++++++++++- server.yml | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/config.cfg b/config.cfg index 9758959..7c361fe 100644 --- a/config.cfg +++ b/config.cfg @@ -11,7 +11,6 @@ users: ### Advanced users only below this line ### -# Changing the port not supported by Scaleway, the default (22) is always used ssh_port: 4160 # Store the PKI in a ram disk. Enabled only if store_pki (retain the PKI) is set to false diff --git a/roles/cloud-scaleway/tasks/main.yml b/roles/cloud-scaleway/tasks/main.yml index 28524b5..75f0a3c 100644 --- a/roles/cloud-scaleway/tasks/main.yml +++ b/roles/cloud-scaleway/tasks/main.yml @@ -21,6 +21,33 @@ {%- endfor -%}] - name: Create a server + scaleway_compute: + name: "{{ algo_server_name }}" + enable_ipv6: true + public_ip: dynamic + boot_type: local + state: present + image: "{{ images[0] }}" + organization: "{{ organization_id }}" + region: "{{ algo_region }}" + commercial_type: "{{ cloud_providers.scaleway.size }}" + wait: true + tags: + - Environment:Algo + - AUTHORIZED_KEY={{ lookup('file', SSH_keys.public)|regex_replace(' ', '_') }} + register: scaleway_compute + + - name: Patch the cloud-init + uri: + url: "https://cp-{{ region }}.scaleway.com/servers/{{ scaleway_compute.msg.id }}/user_data/cloud-init" + method: PATCH + body: "{{ lookup('template', 'files/cloud-init/base.yml') }}" + status_code: 204 + headers: + Content-Type: "text/plain" + X-Auth-Token: "{{ algo_scaleway_token }}" + + - name: Start the server scaleway_compute: name: "{{ algo_server_name }}" enable_ipv6: true @@ -44,4 +71,6 @@ - set_fact: cloud_instance_ip: "{{ algo_instance.msg.public_ip.address }}" - ansible_ssh_user: root + ansible_ssh_user: algo + ansible_ssh_port: "{{ ssh_port }}" + cloudinit: true diff --git a/server.yml b/server.yml index c418382..39653e9 100644 --- a/server.yml +++ b/server.yml @@ -12,6 +12,7 @@ delay: 10 timeout: 600 state: present + become: false when: cloudinit - block: