Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit 645ffef

Browse files
committed
Add support for Scaleway
1 parent 9ef81d2 commit 645ffef

File tree

7 files changed

+173
-2
lines changed

7 files changed

+173
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ See also:
5757
* Google Compute Engine (GCE)
5858
* Linode
5959
* Rackspace
60+
* Scaleway
6061

6162

6263
#### Other providers

deploy/streisand-new-cloud-server.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# Usage:
1111
# streisand-new-cloud-server \
12-
# --provider [amazon|azure|digitalocean|google|linode|rackspace] \
12+
# --provider [amazon|azure|digitalocean|google|linode|rackspace|scaleway] \
1313
# --site-config path/to/digitalocean-site.yml
1414
#
1515

@@ -19,7 +19,7 @@ set -o nounset
1919
DIR="$( cd "$( dirname "$0" )" && pwd)"
2020
PROJECT_DIR="${DIR}/.."
2121

22-
VALID_PROVIDERS="amazon|azure|digitalocean|google|linode|rackspace"
22+
VALID_PROVIDERS="amazon|azure|digitalocean|google|linode|rackspace|scaleway"
2323
export DEFAULT_SITE_VARS="${PROJECT_DIR}/global_vars/default-site.yml"
2424
export GLOBAL_VARS="${PROJECT_DIR}/global_vars/globals.yml"
2525

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# Example site specific configuration for a noninteractive Scaleway
3+
# deployment.
4+
#
5+
# Copy this and edit it as needed before running streisand-new-cloud-server.
6+
#
7+
8+
streisand_noninteractive: true
9+
confirmation: true
10+
11+
# The SSH private key that Ansible will use to connect to the Streisand node.
12+
#
13+
# The corresponding public key must be added to the Scaleway console
14+
# and the name given to it referenced below in the scaleway_ssh_name variable.
15+
# The corresponding public key must be uploaded to Scaleway and the name
16+
# given to it referenced below in the scaleway_ssh_name variable.
17+
streisand_ssh_private_key: "~/.ssh/id_rsa"
18+
19+
vpn_clients: 5
20+
21+
streisand_openconnect_enabled: yes
22+
streisand_openvpn_enabled: yes
23+
streisand_shadowsocks_enabled: yes
24+
streisand_ssh_forward_enabled: yes
25+
# By default sshuttle is disabled because it creates a `sshuttle` user that has
26+
# full shell privileges on the Streisand host
27+
streisand_sshuttle_enabled: no
28+
streisand_stunnel_enabled: yes
29+
streisand_tinyproxy_enabled: yes
30+
streisand_tor_enabled: no
31+
streisand_wireguard_enabled: yes
32+
33+
# Scaleway region.
34+
#
35+
# - fr-par1 (Paris)
36+
# - nl-ams1 (Amsterdam)
37+
#
38+
scaleway_region: "nl-ams1"
39+
40+
scaleway_server_name: streisand
41+
42+
# Add the Scaleway token here.
43+
scaleway_token: ""
44+
45+
# Definitions needed for Let's Encrypt HTTPS (or TLS) certificate setup.
46+
#
47+
# If these are both left as empty strings, Let's Encrypt will not be set up and
48+
# a self-signed certificate will be used instead.
49+
#
50+
# The domain to use for Let's Encrypt certificate.
51+
streisand_domain_var: ""
52+
# The admin email address for Let's Encrypt certificate registration.
53+
streisand_admin_email_var: ""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scaleway_commercial_type: DEV1-S
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
- set_fact:
3+
streisand_genesis_role: "genesis-scaleway"
4+
5+
- name: "Get the {{ streisand_ssh_private_key }}.pub contents"
6+
command: "cat {{ streisand_ssh_private_key }}.pub"
7+
register: ssh_key
8+
changed_when: False
9+
10+
- name: Set the Scaleway Token fact to the value that was entered, or attempt to retrieve it from the environment if the entry is blank
11+
set_fact:
12+
scaleway_token: "{{ scaleway_token | default( lookup('env', 'SCW_TOKEN') ) }}"
13+
14+
- block:
15+
- name: Add the SSH key to Scaleway if it does not already exist
16+
scaleway_sshkey:
17+
ssh_pub_key: "{{ ssh_key.stdout }}"
18+
state: present
19+
register: scaleway_ssh_key
20+
rescue:
21+
- fail:
22+
msg: "* The SSH key may already exist in the Scaleway console under a different name."
23+
24+
- block:
25+
- name: "Fetch image id for Ubuntu Bionic"
26+
scaleway_image_facts:
27+
region: "{{ regions[scaleway_region] }}"
28+
name: Ubuntu Bionic
29+
register: image
30+
31+
- name: Create a Scaleway instance
32+
scaleway_compute:
33+
name: "{{ scaleway_server_name }}"
34+
commercial_type: "{{ scaleway_commercial_type }}"
35+
region: "{{ regions[scaleway_region] }}"
36+
image: "{{ image[0].id }}"
37+
wait: yes
38+
register: streisand_server
39+
rescue:
40+
- fail:
41+
msg: "Unable to create the Scaleway server."
42+
43+
- name: Wait until the server has finished booting and OpenSSH is accepting connections
44+
wait_for:
45+
host: "{{ streisand_server.ip_address }}"
46+
port: 22
47+
search_regex: OpenSSH
48+
timeout: 600
49+
50+
- name: Create the in-memory inventory group
51+
add_host:
52+
name: "{{ streisand_server.ip_address }}"
53+
groups: streisand-host
54+
55+
- name: Set the streisand_ipv4_address variable
56+
set_fact:
57+
streisand_ipv4_address: "{{ streisand_server.ip_address }}"
58+
59+
- name: Set the streisand_server_name variable
60+
set_fact:
61+
streisand_server_name: "{{ scaleway_server_name | regex_replace('\\s', '_') }}"

playbooks/scaleway.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
- name: Provision the Scaleway Server
3+
# ===================================
4+
hosts: localhost
5+
connection: local
6+
gather_facts: yes
7+
8+
vars:
9+
regions:
10+
"1": "fr-par-1"
11+
"2": "nl-ams-1"
12+
13+
vars_prompt:
14+
- name: "scaleway_region"
15+
prompt: >
16+
What region should the server be located in?
17+
1. fr-par-1 (Paris)
18+
2. nl-ams-1 (Amsterdam)
19+
Please choose the number of your region. Press enter for default (#1) region.
20+
default: "1"
21+
private: no
22+
23+
- name: "scaleway_server_name"
24+
prompt: "\nWhat should the server be named? Press enter for default (streisand).\n"
25+
default: "streisand"
26+
private: no
27+
28+
- name: "scaleway_token"
29+
prompt: |
30+
31+
Tokens allow Streisand to create a Scaleway instance for you.
32+
New Personal Access Tokens can be generated in the Scaleway console.
33+
To generate a new token please do the following:
34+
* Go to https://console.scaleway.com/account/credentials
35+
* Click 'Generate New Token'
36+
* Give the token a purpose (it is arbitrary)
37+
* Copy the long string that is generated and paste it below.
38+
* Click 'Generate Token'
39+
If this field is left blank, the environment variable SCW_TOKEN will be used.
40+
41+
What is your Scaleway Token?
42+
private: no
43+
44+
- name: "confirmation"
45+
prompt: "\nStreisand will now set up your server. This process usually takes around ten minutes. Press Enter to begin setup...\n"
46+
47+
roles:
48+
- genesis-scaleway
49+
50+
- import_playbook: ssh-setup.yml
51+
- import_playbook: cloud-status.yml
52+
- import_playbook: streisand.yml
53+
...

streisand

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ read -r -p "Which provider are you using?
199199
6. Rackspace
200200
7. localhost (Advanced)
201201
8. Existing Server (Advanced)
202+
9. Scaleway
202203
: " reply
203204

204205
case "$reply" in
@@ -210,5 +211,6 @@ case "$reply" in
210211
6) run_genesis rackspace.yml;;
211212
7) local_provision;;
212213
8) existing_server;;
214+
9) run_genesis scaleway.yml;;
213215
*) echo; echo "Invalid provider selected."; exit 1;;
214216
esac

0 commit comments

Comments
 (0)