Skip to content
Snippets Groups Projects
Commit f06a05d4 authored by Nathan Rodet's avatar Nathan Rodet
Browse files

Merge remote-tracking branch 'origin/develop'

# Conflicts:
#	README.md
#	instance-scripts/config-files/atrium.yaml
#	instance-scripts/scripts/atrium.sh
#	instance-scripts/scripts/ttyd.sh
parents 79483141 7c96ad2c
No related branches found
No related tags found
No related merge requests found
# Alpha Project Manager
# Labo Rust
An Infrastructure as Code manager to deploy lab infrastructure and configure instances. Working with Atrium, Gitlab CI, Terraform, Cloud-init and Scaleway.
Infrastructure as Code project to deploy lab infrastructure and configure instances. Working with Atrium, Gitlab CI, Terraform, Cloud-init, bash scripts and Scaleway.
### How does it work ?
......@@ -30,11 +30,13 @@ After the resources provisionned with Terraform, Cloud-init will configure the i
After deployment, each resource can be accessed though HTTPS depending on their count number :
- https://desktop-0.rust-0.daag.alpha.grandlyon.com/
- https://code-0.rust-0.daag.alpha.grandlyon.com/
- https://terminal-0.rust-0.daag.alpha.grandlyon.com/
- https://rust-0.daag.alpha.grandlyon.com/
- https://desktop-1.rust-1.daag.alpha.grandlyon.com/
- https://code-1.rust-1.daag.alpha.grandlyon.com/
- https://terminal-1.rust-1.daag.alpha.grandlyon.com/
- https://rust-1.daag.alpha.grandlyon.com/
### Credentials
......@@ -57,7 +59,7 @@ Template are available to the link below.
In this example, you will find how to create a file to a defined path with cloud-init.
Content inside `%` are meant to be replaced with sed command to be able to use environment variables or user-data.
**example:**
**Example:**
```yaml
write_files:
- content: |
......@@ -94,7 +96,7 @@ sed -i "s/%atrium_count_index%/$(scw-userdata atrium_count_index)/g" /root/atriu
The example show how to curl a configuration file from repository to a defined path with cloud-init.
**example :**
**Example :**
```yaml
runcmd:
#
......@@ -111,11 +113,10 @@ runcmd:
## Use Gitlab variables in instances
### Example
From my instances, I should be able to access the variables as user-data using the command `scw-userdata <my-variable>` after declaring them in Terraform.
**Some documentation : https://blog.scaleway.com/introducing-scaleway-cloud-init-support/**
**Example : Declare in Terraform**
```HCL
user_data = {
atrium_count_index = count.index
......@@ -126,6 +127,11 @@ user_data = {
}
```
** Example : Retrieve in instance
```bash
scw-userdata atrium_count_index
```
## Setup Terraform Locally
First, you must setup 2 local files for your variables :
......@@ -164,7 +170,7 @@ Now, you can create a file for your variables information called **variables-loc
SCW_PROJECT_ID = ""
SCW_ACCESS_KEY = ""
SCW_SECRET_KEY = ""
INSTANCES_COUNT = "2"
INSTANCES_COUNT = ""
ENVIRONMENT = ""
```
......
......@@ -5,21 +5,21 @@ letsencrypt_email: %atrium_letsencrypt_email%
tls_mode: Auto
apps: # optional : applications served by atrium
- id: 1
name: Code %atrium_count_index%
name: Code
icon: web_asset
color: 4292030255
is_proxy: true
host: code-%atrium_count_index%
target: localhost:8080
- id: 2
name: Desktop %atrium_count_index%
name: Desktop
icon: web_asset
color: 4292030255
is_proxy: true
host: desktop-%atrium_count_index%
target: localhost:8081
- id: 3
name: Terminal %atrium_count_index%
name: Terminal
icon: terminal
color: 4292030255
is_proxy: true
......@@ -28,6 +28,8 @@ apps: # optional : applications served by atrium
secured: true
login: admin
password: %user_password%
roles:
- ADMINS
users:
- login: admin
password: %user_password_hash%
......
......@@ -9,7 +9,7 @@
# echo $(scw-userdata user_password) | argon2 $(echo $RANDOM | md5sum | head -c 10) -id -l 32 -e
#
export USER_PASSWORD_HASH=$(echo "$(scw-userdata user_password)" | argon2 "$(echo $RANDOM | md5sum | head -c 10)" -id -l 32 -e)
export USER_PASSWORD_HASH=$(echo -n "$(scw-userdata user_password)" | argon2 "$(echo $RANDOM | md5sum | head -c 12)" -id -l 32 -e)
mkdir -p /root/atrium/data && mkdir -p /root/atrium/letsencrypt_cache
curl https://forge.grandlyon.com/systemes-dinformation/alpha/projects/labo-rust/-/raw/develop/instance-scripts/config-files/atrium.yaml -o root/atrium/atrium.yaml
......
......@@ -5,9 +5,9 @@
#
mkdir -p /root/ttyd
curl https://github.com/tsl0922/ttyd/releases/download/1.7.2/ttyd.x86_64 -o root/ttyd/ttyd.x86_64
curl -k -L -s https://github.com/tsl0922/ttyd/releases/download/1.7.3/ttyd.x86_64 -o root/ttyd/ttyd.x86_64
chmod +x /root/ttyd/ttyd.x86_64
curl https://forge.grandlyon.com/systemes-dinformation/alpha/projects/labo-rust/-/raw/develop/instance-scripts/config-files/ttyd.service -o etc/systemd/system/ttyd.service
sed -i "s|%user_password%|$(scw-userdata user_password)|g" /etc/systemd/system/ttyd.service
systemctl enable ttyd.service && systemctl start ttyd.service
\ No newline at end of file
systemctl enable ttyd.service && systemctl start ttyd.service
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment