Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Railway 2 #8

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To make all this work it makes some strong assumptions about the rails app it wi
4. Postgres as database;
5. Node/Yarn for javascript;
6. [Majestic Monolith](https://m.signalvnoise.com/the-majestic-monolith/) instead of Microservices;
7. Ubuntu 20.04;
7. Ubuntu 22.04;
8. No containers;

It relies the following services in AWS:
Expand All @@ -43,7 +43,7 @@ I've always been a fan of those "choose your own adventure" game books, so let's

Bug reports and pull requests are welcome on GitHub at https://github.com/FestaLab/railway. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/FestaLab/railway/blob/main/CODE_OF_CONDUCT.md).

If you with to submit pull requests, please check the [contribution guide](https://github.com/FestaLab/railway/blob/main/docs/CONTRIBUTION.MD) to make handling your credentials easier.
If you with to submit pull requests, please check the [contribution guide](https://github.com/FestaLab/railway/blob/main/docs/CONTRIBUTE.MD) to make handling your credentials easier.

## License

Expand Down
6 changes: 6 additions & 0 deletions ami_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
- role: app_bootstrap
param_name: "{{ app_name }}"
tags: app_bootstrap

post_tasks:
- name: Cleanup
file:
path: /home/app/{{ app_name }}
state: absent
4 changes: 2 additions & 2 deletions ami_aws_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
gather_facts: False

roles:
- role: aws_ec2_create
- role: aws/ec2_create
param_name: ami
param_instance_type: c5.2xlarge
param_instance_type: m6i.2xlarge
param_ami_id: "{{ aws_ami_id }}"
param_exact_count: 1
tags: aws_ec2_create
Expand Down
6 changes: 3 additions & 3 deletions ami_aws_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
register: register_instance_info

roles:

- role: aws_ami_create
- role: ami/snapshot
param_name: ami
param_instance_id: "{{ register_instance_info.instances[0].instance_id }}"
tags: aws_ami_create

- role: aws_ec2_destroy
- role: aws/ec2_destroy
param_instance_id: "{{ register_instance_info.instances[0].instance_id }} "
tags: aws_ec2_destroy
19 changes: 15 additions & 4 deletions ami_bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@

roles:

- role: ami_user
- role: ami/ulimit
tags: ulimit

- role: ami/dist_upgrade
tags: ami_dist_upgrade

- role: ami/repos
tags: ami_repos

- role: ami/log
tags: ami_log

- role: ami/user
param_name: ansible
param_comment: Ansible user
param_sudo: yes
tags: ansible_user

- role: ami_user
- role: ami/user
param_name: app
param_comment: Application user
param_sudo: yes
tags: user_app

- role: ami_ulimit
tags: ulimit

113 changes: 71 additions & 42 deletions ami_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,96 @@
- hosts: _railway_ec2_development_ami
remote_user: ansible
become: yes

pre_tasks:
- name: Set cflags and pkgconfig for all build scripts
lineinfile:
dest: "/etc/environment"
state: present
regexp: "^{{ item.key }}="
line: "{{ item.key }}={{ item.value}}"
with_items:
- key: CFLAGS
value: -O3
- key: CXXFLAGS
value: -O3

roles:
- role: ami_repos
tags: repos
- role: ami/purge_services
tags: ami_purge_services

- role: ami/time
tags: ami_time

- role: ami_dist_upgrade
tags: dist_upgrade
- role: ami/cron
tags: ami_cron

- role: ami_time
tags: time
- role: ami/ufw
tags: ami_ufw

- role: ami_cron
tags: cron
- role: ami/ssh
tags: ami_ssh

- role: ami_ufw
tags: ufw
- role: ami/buildtools
tags: ami_buildtools

- role: ami_ssh
tags: ssh
- role: ami/python
tags: ami_python

- role: ami_collectd
tags: collectd
- role: ami/rust
tags: ami_rust

- role: ami_purge_services
tags: purge_services
- role: ami/node
tags: ami_node

- role: ami_buildtools
tags: buildtools
- role: ami/redis
tags: ami_redis

- role: ami_python
tags: python
- role: ami/postgres
tags: ami_postgres

- role: ami_node
tags: node
- role: ami/sqlite
tags: ami_sqlite

- role: ami_postgres
tags: postgres
- role: ami/ffmpeg
tags: ami_ffmpeg

- role: ami_fonts
tags: fonts
- role: ami/pdf
tags: ami_pdf

- role: ami_chrome
tags: chrome
- role: ami/libjxl
tags: ami_libjxl

- role: ami_ffmpeg
tags: ffmpeg
- role: ami/libheif
tags: ami_libheif

- role: ami_pdf
tags: pdf
- role: ami/libspng
tags: ami_libspng

- role: ami_libjxl
tags: libjxl
- role: ami/mozjpeg
tags: ami_mozjpeg

- role: ami_mozjpeg
tags: libjxl
- role: ami/openjpeg
tags: ami_openjpeg

- role: ami_imagemagick
tags: imagemagick
- role: ami/imagemagick
tags: ami_imagemagick

- role: ami_libvips
tags: libvips
- role: ami/libvips
tags: ami_libvips

- role: ami_ruby
- role: ami/chrome
tags: ami_chrome

- role: ami/ruby
param_version: "{{ ruby_version }}"
tags: ruby
tags: ami_ruby

- role: aws/cloudwatch
param_nam/: "{{ ansible_environment }}"
param_hostname: ami
param_process_type: ami
tags: aws_cloudwatch

- role: ami/dist_upgrade
tags: ami_dist_upgrade
2 changes: 1 addition & 1 deletion bootstrap_ansible_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- name: Copy ec2 development key to local ssh folder
copy:
src: "roles/aws_ec2_create/files/ansible-ec2-development.pem"
src: "roles/aws/ec2_create/files/ansible-ec2-development.pem"
dest: ~/.ssh/ansible-ec2-development.pem
mode: 0600

Expand Down
2 changes: 1 addition & 1 deletion bootstrap_ansible_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- name: Copy ec2 production key to local ssh folder
copy:
src: "roles/aws_ec2_create/files/ansible-ec2-production.pem"
src: "roles/aws/ec2_create/files/ansible-ec2-production.pem"
dest: ~/.ssh/ansible-ec2-production.pem
mode: 0600

Expand Down
2 changes: 0 additions & 2 deletions bootstrap_aws.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---

- import_playbook: bootstrap_aws_vpc.yml
- import_playbook: bootstrap_aws_redis_cache.yml
- import_playbook: bootstrap_aws_redis_job.yml
- import_playbook: bootstrap_aws_rds.yml
15 changes: 0 additions & 15 deletions bootstrap_aws_redis_cache.yml

This file was deleted.

15 changes: 0 additions & 15 deletions bootstrap_aws_redis_job.yml

This file was deleted.

2 changes: 0 additions & 2 deletions contribute_bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
- hosts: localhost
gather_facts: False


tasks:

- name: Ensure credentials folder exist
file:
path: ../railway-credentials
Expand Down
4 changes: 2 additions & 2 deletions contribute_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
- name: Copy development EC2 key pair to the project
copy:
src: ../railway-credentials/ansible-ec2-development.pem
dest: roles/aws_ec2_create/files/ansible-ec2-development.pem
dest: roles/aws/ec2_create/files/ansible-ec2-development.pem

- name: Copy production EC2 key pair to the project
copy:
src: ../railway-credentials/ansible-ec2-production.pem
dest: roles/aws_ec2_create/files/ansible-ec2-production.pem
dest: roles/aws/ec2_create/files/ansible-ec2-production.pem


- name: Copy the development deploy key to the project
Expand Down
12 changes: 6 additions & 6 deletions contribute_teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@

- name: Copy the development EC2 key pair to the credentials folder
copy:
src: roles/aws_ec2_create/files/ansible-ec2-development.pem
src: roles/aws/ec2_create/files/ansible-ec2-development.pem
dest: ../railway-credentials/ansible-ec2-development.pem

- name: Clear development EC2 key pair
copy:
content: 'Replace this file with your development EC2 key pair and encrypt it with "ansible-vault encrypt roles/aws_ec2_create/files/ansible-ec2-development.pem"'
dest: roles/aws_ec2_create/files/ansible-ec2-development.pem
content: 'Replace this file with your development EC2 key pair and encrypt it with "ansible-vault encrypt roles/aws/ec2_create/files/ansible-ec2-development.pem"'
dest: roles/aws/ec2_create/files/ansible-ec2-development.pem

- name: Copy the production EC2 key pair to the credentials folder
copy:
src: roles/aws_ec2_create/files/ansible-ec2-production.pem
src: roles/aws/ec2_create/files/ansible-ec2-production.pem
dest: ../railway-credentials/ansible-ec2-production.pem

- name: Clear production EC2 key pair
copy:
content: 'Replace this file with your production EC2 key pair and encrypt it with "ansible-vault encrypt roles/aws_ec2_create/files/ansible-ec2-production.pem"'
dest: roles/aws_ec2_create/files/ansible-ec2-production.pem
content: 'Replace this file with your production EC2 key pair and encrypt it with "ansible-vault encrypt roles/aws/ec2_create/files/ansible-ec2-production.pem"'
dest: roles/aws/ec2_create/files/ansible-ec2-production.pem



Expand Down
22 changes: 11 additions & 11 deletions docs/CONTRIBUTE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ansible-playbook contribute_bootstrap.yml
```

This playbook will:
1 - Create a `railway-credentials` folder in the same folder that you clone `railway` to;
2 - Make a copy of the placeholder development vault to `railway-credentials`;
3 - Make a copy of the placeholder production vault to `railway-credentials`;
1. Create a `railway-credentials` folder in the same folder that you cloned `railway` to;
2. Make a copy of the placeholder development vault to `railway-credentials`;
3. Make a copy of the placeholder production vault to `railway-credentials`;

With this done, you can now go through STEP 5 of the INSTALL.MD file to get your credentials inserted.

Expand All @@ -22,14 +22,14 @@ ansible-playbook contribute_teardown.yml
```

This playbook will:
1 - Copy your current development vault to `railway-credentials`;
2 - Copy the placeholder development vault back to this project;
3 - Copy your current production vault to `railway-credentials`;
4 - Copy the placeholder production vault back to this project;
5 - Copy your current development key pair to `railway-credentials`;
6 - Clear the development key pair file;
7 - Copy your current development key pair to `railway-credentials`;
8 - Clear the development key pair file;
1. Copy your current development vault to `railway-credentials`;
2. Copy the placeholder development vault back to this project;
3. Copy your current production vault to `railway-credentials`;
4. Copy the placeholder production vault back to this project;
5. Copy your current development key pair to `railway-credentials`;
6. Clear the development key pair file;
7. Copy your current development key pair to `railway-credentials`;
8. Clear the development key pair file;

Then also run the teardown playbook to AWS, so it removes every resource that costs money:
```shell
Expand Down
2 changes: 1 addition & 1 deletion docs/FIRST_RUN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ If you open `ami.yml` this is what you will see:
Once again, if you don't care how this will happen, skip to 2.6. If you are actually interested in everything that goes into building a custom AMI, read on.

#### 2.1 Setup
Creates an EC2 instance using the base Ubuntu 20.04 LTS.
Creates an EC2 instance using the base Ubuntu 22.04 LTS.
1. Find the subnet for the development environment;
2. Find the security group for the development environment;
3. Provision an EC2 instance with the name `railway-ec2-development-ami` using the `development` key pair;
Expand Down
Loading