Skip to content

bilalhasson/orchestrate-dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Playbook for macOS Setup

This repository contains an Ansible playbook to set up a macOS machine with various tools and configurations. It is designed to automate the installation of essential software and configurations for development environments.

Table of Contents

Prerequisites

  1. Ensure SSH key exists ls ~/.ssh/id_*
    • If not ssh-keygen
  2. SSH key for GitHub
    • Create SSH key and add it to your GitHub account
    • Add SSH key to your macOS keychain
      eval "$(ssh-agent -s)"
      ssh-add ~/.ssh/<your-ssh-key>
  3. Python
  4. Create venv for Ansible
    • python3 -m venv ansible
    • source ansible/bin/activate
  5. Ansible
    • python3 -m pip install pipx
    • pipx install --include-deps ansible
  6. Install homebrew

Execute the Ansible Playbook to set up a macOS machine

Run the below command, and then enter your password when prompted.

ansible-playbook -i inventory playbooks/macos/main.yml --ask-become-pass

Other details

Ansible Structure

Ansible Structure

  ansible/
  group_vars/
     all/
        env_vars.yml
        env_vars.local.yml
  host_vars/
     localhost/
        env_vars.yml
  inventory/
     hosts
  playbooks/
     macos/
        main.yml
     roles/
        aws_login/
           main.yml
     playbooks.yml
Click to expand for more details

Problem

Setting up my laptop for work took way too long, getting the right tools, logging into the correct systems, cloning the right repos, etc.

Solution

This repository contains an Ansible playbook to set up a macOS machine with various tools and configurations. It is designed to automate the installation of essential software and configurations for development environments.

What I do when you execute the main playbook:

  1. Install:
    • VSCode
    • dependencies like curl, unzip and python packaging to allow for AWS install
    • AWS CLI
  2. Clone repositories defined in the group_clone_repos variable.
  3. Fetch environment variables from AWS Secrets Manager and create .env files defined in the group_clone_repos variable.
  4. Install Python packages using pipenv or npm as specified in the group_clone_repos variable.
  5. Setup the local development environment, npm i and pipenv install.
  6. Install Postgres version defined in the group_postgres_version variable.
  7. Install docker
  8. Build and run Docker containers for the cloned repositories, using the commands specified in the group_clone_repos variable.
  9. Make fixtures for the repositories, if specified in the group_clone_repos variable.
  10. Install postman
Variables

Variables

Create variables in the group_vars/all/env_vars.yml. There's a file already in there called env_vars.example.yml which you can rename to env_vars.yml.

python_interpreter: ".../bin/python"

# Directory for all the repos.
group_develop_dir: ".../repos/location"

# If SSO is required, set to true.
group_aws_sso_login_required: true

# AWS SSO
group_aws_details:
  region: eu-west-2
  output: json
  sso_start_url: https://d-9c6714caab.awsapps.com/start
  sso_region: eu-west-2
  sso_account_id: <sso_account_id>
  sso_role_name: <sso_role_name>

  ecr_login_url: <id>.dkr.ecr.<region>.amazonaws.com

# Default is `/tmp`, change if you want to use a different directory for temporary files.
override_executable_temp_dir: /tmp

# This is used to prefix the repo name when cloning repos.
group_repo_organization: <org or user>

group_clone_repos:
  backend-repo-name:
    service: "backend"
    install_pipenv: true # If pipenv is used, and you want to install set to true.
    pipenv_subdir: <sub_dir> # Specify the subdirectory of Pipfile if applicable.
    env_secret: # Environment secret for the repo. Uses aws secretsmanager.
      id: secret-id
      file: "{{ [group_develop_dir, '.../.env'] | path_join }}"
    load_fixtures: true
    docker:
      build_command: "make build"
      up_command: "make up"
      check_ports_before_fixtures:
        - port: 8001 # web
        - port: 5433 # db

  frontend-repo-name:
    service: "frontend"
    install_method: "npm"
    node_version: "20.18"
    env_secret:
      id: secret-id
      file: "{{ [group_develop_dir, 'frontend-repo-name', '.env.local'] | path_join }}"

# Postgres
group_postgres_version: 14

# If repo node version not provided, use this as a fallback.
group_fallback_node_version: "18"
Install Python and Ansible on macOS

Install Python and Ansible on macOS

  1. Create a Python virtual environment:
    python3 -m venv ansible
    source ansible/bin/activate
  2. Upgrade pip (recommended):
    pip install --upgrade pip
    pip install pipx
  3. Install Ansible inside the virtual environment:
    pipx install ansible
Roles

Roles

  • aws_login: Configures AWS CLI with login credentials.

About

This repository contains an Ansible playbook to set up a macOS machine with various tools and configurations. It is designed to automate the installation of essential software and configurations for development environments.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors