Skip to content
moha-bekhPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloud-1

Automated deployment of the 42 Cloud-1 project.

The repository is split into:

  • iac/: infrastructure as code with Terraform on AWS.
  • cac/: configuration as code with Ansible.

Requirements

Install these tools on the machine that runs the deployment:

  • git
  • ssh
  • task
  • terraform
  • AWS credentials configured for Terraform
  • an SSH key at ~/.ssh/cloud-1

Optional for local checks:

  • ansible
  • ansible-galaxy

The Terraform AWS provider uses the standard AWS credential chain. For example:

aws configure

or export the usual environment variables:

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_DEFAULT_REGION=eu-west-3

Local Secrets

Secrets are intentionally ignored by Git. After cloning the repository, create the local files from the examples.

cp cac/group_vars/secrets.example.yml cac/group_vars/secrets.yml
cp iac/terraform.tfvars.example iac/terraform.tfvars

Edit cac/group_vars/secrets.yml:

user_name: change_me
user_pass: change_me
root_pass: change_me
wp_email: admin@example.com

Edit iac/terraform.tfvars:

github_token = "replace_me"

# Optional overrides
# aws_region    = "eu-west-3"
# instance_type = "t3.micro"

The GitHub token is used by the master instance to clone this repository during provisioning.

Runtime Env Files

The Inception .env file is generated by Ansible from:

cac/roles/worker/templates/env.j2

For manual local use only, an example exists at:

cac/roles/worker/files/inception/.env.example

Do not commit real .env, terraform.tfvars, secrets.yml, Terraform state files, private keys, or generated Inception secrets.

Usage

Deploy everything from scratch:

task up

This runs Terraform first, then runs the Ansible playbook from the master instance.

Useful commands:

task deploy          # Terraform init/apply only
task configure       # run Ansible against the current worker
task worker          # SSH into the worker
task master          # SSH into the master
task worker-reboot   # reboot the worker to test persistence
task destroy         # destroy AWS resources
task re              # destroy, recreate, and configure

Checks

Local syntax checks:

cd cac && make check
cd ../iac && terraform fmt -check && terraform validate

Before pushing, verify that no secret file is tracked:

git status --ignored

Ignored local files should appear with !!.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages