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

Commit 4fd56de

Browse files
committed
Add support for Scaleway
1 parent 8f06cad commit 4fd56de

File tree

6 files changed

+166
-2
lines changed

6 files changed

+166
-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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
api_token: "{{ scaleway_token }}"
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: Create a Scaleway instance
26+
scaleway_compute:
27+
name: "{{ scaleway_server_name }}"
28+
size_id: "{{ scaleway_commercial_type }}"
29+
region_id: "{{ regions[scaleway_region] }}"
30+
image: "{{ image[0].id }}"
31+
wait: yes
32+
api_token: "{{ scaleway_token }}"
33+
register: streisand_server
34+
rescue:
35+
- fail:
36+
msg: "Unable to create the Scaleway server."
37+
38+
- name: Wait until the server has finished booting and OpenSSH is accepting connections
39+
wait_for:
40+
host: "{{ streisand_server.ip_address }}"
41+
port: 22
42+
search_regex: OpenSSH
43+
timeout: 600
44+
45+
- name: Create the in-memory inventory group
46+
add_host:
47+
name: "{{ streisand_server.ip_address }}"
48+
groups: streisand-host
49+
50+
- name: Set the streisand_ipv4_address variable
51+
set_fact:
52+
streisand_ipv4_address: "{{ streisand_server.ip_address }}"
53+
54+
- name: Set the streisand_server_name variable
55+
set_fact:
56+
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": "par1"
11+
"2": "ams1"
12+
13+
vars_prompt:
14+
- name: "scaleway_region"
15+
prompt: >
16+
What region should the server be located in?
17+
1. Paris
18+
2. 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+
...

0 commit comments

Comments
 (0)