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

feat/add/packer/steps #2412

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

feat/add/packer/steps #2412

wants to merge 4 commits into from

Conversation

pratapalakshmi
Copy link
Collaborator

@pratapalakshmi pratapalakshmi commented May 26, 2024

Depends-on: 2413

Summary by CodeRabbit

  • New Features

    • Added a GitHub Actions workflow for building AWS AMIs using Packer.
    • Introduced a new environment variable HASHING_KEY_SECRET for enhanced security.
    • Added multiple Ansible playbooks and scripts to streamline the Ballerina setup and deployment process.
    • Introduced Docker Compose configurations for HTTPS support and various services.
  • Improvements

    • Enhanced the Ballerina runtime setup with new tasks for creating directories, setting permissions, and configuring cron jobs.
    • Updated deployment conditions and configurations for better handling of VITE URLs and CORS origins.

Copy link

changeset-bot bot commented May 26, 2024

⚠️ No Changeset found

Latest commit: f7c4392

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 26, 2024

Walkthrough

This update introduces several new files and modifications aimed at enhancing the deployment and configuration process of the Ballerine project. Key additions include a GitHub Actions workflow for building AWS AMIs, various Ansible playbook tasks for setting up and deploying Ballerine, and Docker Compose configurations. These changes streamline the automation of environment setup, deployment, and runtime configuration, ensuring a more efficient and secure deployment process.

Changes

File/Directory Change Summary
.github/workflows/packer-build-ami.yml New GitHub Actions workflow for building AWS AMIs using Packer.
deploy/.env Added HASHING_KEY_SECRET environment variable.
deploy/ansible/ballerine_playbook/README.md Updated playbook command to include --skip-tags packer option.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml Added default_user, cloud_user, cloud_group, and updated install_dir path.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/cleanup-packer-build.yml New file for cleaning up Packer build credentials and restarting services.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/clone-ballerine.yml New file for cloning the Ballerine repository.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/deploy-ballerine.yml New file for deploying Ballerine using Docker Compose.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/install-docker.yml Removed tags and Python package installations for Docker.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml Replaced include_tasks with import_tasks and added specific tags.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine-runtime.yml New file for setting up Ballerina runtime environment.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine.yml Updated conditions for URL replacements and directory creation based on vite_api_url.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-init-config.yml New file for deploying cloud init configuration, creating user groups, and setting up sudo permissions.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-user-data.yml New file for setting up runtime user data.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/boot.sh New script for automating Ballerina project setup using Docker Compose.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/cloud-config.cfg New cloud configuration settings for default user ballerine.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/init-ssh.sh New script for setting up SSH keys for ballerine and ubuntu users.
deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/user-data.sh New script for setting up default user credentials for Ballerina.
deploy/aws_ami/defaults.cfg New cloud configuration settings for default user ballerine.
deploy/aws_ami/template.json.pkr.hcl New configuration for creating an AWS base image and provisioning an AWS instance using Ansible.
deploy/docker-compose-build-https.yml New Docker Compose configuration for Ballerina services with HTTPS support.
deploy/docker-compose-build.yml Added HASHING_KEY_SECRET environment variable.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant GitHub as GitHub Actions
    participant AWS as AWS
    participant Ansible as Ansible Playbook
    participant Docker as Docker Compose

    Dev->>GitHub: Push code changes
    GitHub->>AWS: Trigger Packer build AMI workflow
    AWS->>GitHub: Provide AMI details
    GitHub->>Ansible: Run playbook for setup and deployment
    Ansible->>AWS: Configure instances and deploy Ballerine
    Ansible->>Docker: Deploy Ballerine services
    Docker->>Dev: Services running with updated configurations
Loading

Poem

In fields of code where bunnies play,
A workflow hops to save the day.
With Docker, Ansible, and Packer's might,
Ballerine's future is shining bright.
Secrets hashed, and keys in hand,
Our code deploys across the land.
🐇✨🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pratapalakshmi pratapalakshmi changed the base branch from dev to update/ballerine/ansible/steps May 26, 2024 16:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b48986f and c8fc02f.
Files selected for processing (11)
  • .github/workflows/packer-build-ami.yml (1 hunks)
  • deploy/.env (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/clone-ballerine.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/install-docker.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine.yml (1 hunks)
  • deploy/aws_ami/defaults.cfg (1 hunks)
  • deploy/aws_ami/template.json.pkr.hcl (1 hunks)
  • deploy/docker-compose-build-https.yml (1 hunks)
  • deploy/docker-compose-build.yml (1 hunks)
Files skipped from review due to trivial changes (6)
  • deploy/.env
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/install-docker.yml
  • deploy/aws_ami/defaults.cfg
  • deploy/docker-compose-build-https.yml
  • deploy/docker-compose-build.yml
Additional comments not posted (3)
deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/clone-ballerine.yml (1)

1-8: Ensure the version parameter points to a stable branch or tag to avoid potential instability from using the 'dev' branch.

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml (1)

10-11: The task to clone the Ballerine repository has been added correctly. Ensure it integrates well with other tasks in the sequence.

Verification successful

The task to clone the Ballerine repository has been added correctly and integrates well with other tasks in the sequence. All referenced task files exist and are correctly defined.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the sequence of tasks in `main.yml` to ensure proper integration.
rg --type yaml $'import_tasks: clone-ballerine.yml' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml

Length of output: 159



Script:

#!/bin/bash
# Description: List all tasks in `main.yml` to review their sequence and integration.
cat deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml

Length of output: 293



Script:

#!/bin/bash
# Description: Check the existence of task files included in `main.yml`.
for task_file in install-docker.yml start-docker.yml clone-ballerine.yml setup-ballerine.yml; do
  if [ ! -f "deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/$task_file" ]; then
    echo "File not found: $task_file"
  else
    echo "File exists: $task_file"
  fi
done

Length of output: 1063

deploy/aws_ami/template.json.pkr.hcl (1)

1-61: The Packer template configurations are set up correctly. Verify the relative path for user_data_file to ensure it resolves correctly in all deployment scenarios.

Verification successful

Let's modify the script to search for the user_data_file pattern without specifying the file type.


Let's verify the existence and correct path of defaults.cfg to ensure it resolves correctly.


The defaults.cfg file exists at deploy/aws_ami/defaults.cfg, which matches the relative path specified in the Packer template. This confirms that the user_data_file path resolves correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct resolution of the `user_data_file` path in the Packer template.
rg --type hcl $'user_data_file' deploy/aws_ami/template.json.pkr.hcl

Length of output: 95



Script:

#!/bin/bash
# Description: Verify the correct resolution of the `user_data_file` path in the Packer template.
rg 'user_data_file' deploy/aws_ami/template.json.pkr.hcl

Length of output: 93



Script:

#!/bin/bash
# Description: Verify the existence and correct path of `defaults.cfg` in the repository.
fd 'defaults.cfg'

Length of output: 45

ansible.builtin.git:
repo: https://github.com/ballerine-io/ballerine.git
dest: "{{ install_dir }}"
key_file: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key_file parameter is empty. If SSH key authentication is required, please specify the key file.

Comment on lines 1 to 41
name: Packer build AWS AMI's
on:
workflow_dispatch:
branches:
- master

jobs:
plan:
environment: Terraform
defaults:
run:
working-directory: /home/runner/work/ballerine/deploy/aws_ami
runs-on: ubuntu-latest
name: Packer build Artifacts
steps:
- name: Checkout to Git
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1

- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: 1.8.7

- name: Run `packer init`
id: init
run: "packer init template.json.pkr.hcl"

- name: Run `packer validate`
id: validate
run: "packer validate template.json.pkr.hcl"

- name: Build AWS AMIs
run: "packer build template.json.pkr.hcl"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow for building AWS AMIs is set up correctly. Consider parameterizing the aws-region to enhance flexibility for different deployment scenarios.

-          aws-region: ap-south-1
+          aws-region: ${{ secrets.AWS_REGION }}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
name: Packer build AWS AMI's
on:
workflow_dispatch:
branches:
- master
jobs:
plan:
environment: Terraform
defaults:
run:
working-directory: /home/runner/work/ballerine/deploy/aws_ami
runs-on: ubuntu-latest
name: Packer build Artifacts
steps:
- name: Checkout to Git
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: 1.8.7
- name: Run `packer init`
id: init
run: "packer init template.json.pkr.hcl"
- name: Run `packer validate`
id: validate
run: "packer validate template.json.pkr.hcl"
- name: Build AWS AMIs
run: "packer build template.json.pkr.hcl"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

on:
workflow_dispatch:
branches:
- master
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change it to prod?

Comment on lines 19 to 24
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to use assume role instead hard coded creds

Base automatically changed from update/ballerine/ansible/steps to dev May 27, 2024 15:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ec5dc78 and 042fe4e.

Files selected for processing (21)
  • .github/workflows/packer-build-ami.yml (1 hunks)
  • deploy/.env (1 hunks)
  • deploy/ansible/ballerine_playbook/README.md (2 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml (2 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/cleanup-packer-build.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/clone-ballerine.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/deploy-ballerine.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/install-docker.yml (2 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine-runtime.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-init-config.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-user-data.yml (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/boot.sh (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/cloud-config.cfg (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/init-ssh.sh (1 hunks)
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/user-data.sh (1 hunks)
  • deploy/aws_ami/defaults.cfg (1 hunks)
  • deploy/aws_ami/template.json.pkr.hcl (1 hunks)
  • deploy/docker-compose-build-https.yml (1 hunks)
  • deploy/docker-compose-build.yml (1 hunks)
Files skipped from review due to trivial changes (12)
  • .github/workflows/packer-build-ami.yml
  • deploy/.env
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/cleanup-packer-build.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/clone-ballerine.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/deploy-ballerine.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/install-docker.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-user-data.yml
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/cloud-config.cfg
  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/init-ssh.sh
  • deploy/aws_ami/defaults.cfg
  • deploy/docker-compose-build.yml
Additional context used
Shellcheck
deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/boot.sh

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


[warning] 7-7: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)

deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/user-data.sh

[warning] 4-4: Use var=$(command) to assign output (or quote to assign string). (SC2209)

LanguageTool
deploy/ansible/ballerine_playbook/README.md

[style] ~4-~4: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase. (EN_WEAK_ADJECTIVE)
Context: ...on, a welcoming community, and it's all very easy to pick up - not to mention extremely p...


[style] ~4-~4: As an alternative to the over-used intensifier ‘extremely’, consider replacing this phrase. (EN_WEAK_ADJECTIVE)
Context: ...l very easy to pick up - not to mention extremely powerful and suited for just about any situation...


[style] ~13-~13: As an alternative to the over-used intensifier ‘really’, consider replacing this phrase. (EN_WEAK_ADJECTIVE)
Context: ...icial documentation on installing (it's really easy!), but here's a quick rundown of instal...


[uncategorized] ~49-~49: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...as the root user. ## Inventory set-up First you will need to clone the Ballerine re...


[style] ~77-~77: The phrase ‘pretty much’ can be informal. To strengthen your writing, consider removing it or replacing it with an adverb. (PRETTY_MUCH)
Context: ...you completed the above step then we're pretty much done with the inventory ## Setup your ...


[grammar] ~79-~79: This sentence should probably be started with a verb instead of the noun ‘Setup’. If not, consider inserting a comma for better clarity. (SENT_START_NN_DT)
Context: ...pretty much done with the inventory ## Setup your configuration vars for Ballerine ...


[uncategorized] ~82-~82: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nvironment variable, domain name, etc. First you need to open `deploy/ansible/baller...


[uncategorized] ~86-~86: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...ication start correctly - install_dir: The absolute path of your app's install...


[typographical] ~93-~93: Consider adding a comma. (IF_THEN_COMMA)
Context: ... complete setup config vars for your app then we are ready to deploy our app on your ...


[grammar] ~109-~109: Use the plural noun, or add a word such as ‘the’ or ‘some’ in front of ‘other’. (OTHER_NN)
Context: ...*: You can put your inventory file in other folder and then specify its path with the -i...

Markdownlint
deploy/ansible/ballerine_playbook/README.md

57-57: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


24-24: null (MD014, commands-show-output)
Dollar signs used before commands without showing output


31-31: null (MD014, commands-show-output)
Dollar signs used before commands without showing output


37-37: null (MD014, commands-show-output)
Dollar signs used before commands without showing output


53-53: null (MD014, commands-show-output)
Dollar signs used before commands without showing output


54-54: null (MD014, commands-show-output)
Dollar signs used before commands without showing output


61-61: null (MD014, commands-show-output)
Dollar signs used before commands without showing output


6-6: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


11-11: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


40-40: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


23-23: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


30-30: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


36-36: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified

Additional comments not posted (20)
deploy/ansible/ballerine_playbook/roles/setup-ballerine/templates/user-data.sh (1)

4-4: Use proper syntax for command substitution to avoid potential issues.

- default_user_password=admin
+ default_user_password=$(admin)

Likely invalid or redundant comment.

Tools
Shellcheck

[warning] 4-4: Use var=$(command) to assign output (or quote to assign string). (SC2209)

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-init-config.yml (3)

2-4: This task is correctly set up to deploy the cloud init config file.


6-8: The task to create the ballerine group is correctly configured.


18-25: The task to add sudoers group for the ballerine user is correctly configured.

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine-runtime.yml (2)

1-8: The task to create a runtime path folder is correctly configured with appropriate permissions and ownership.


23-30: The task to setup the SSH key for the ballerine user is correctly configured.

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine.yml (2)

26-31: LGTM! Ensure that vite_api_url is appropriately set in the environment to avoid skipping this task unintentionally.


32-37: LGTM! Ensure that vite_api_url is appropriately set in the environment to avoid skipping this task unintentionally.

deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml (3)

32-32: Remaining variable settings look good and are standard configurations.


32-32: LGTM! Ensure that the new installation directory is correctly reflected in all relevant file paths throughout the playbook.

Verification successful

The new installation directory ~/ballerine is correctly reflected in the file paths within the playbook, and there are no occurrences of the old path /home/ubuntu/ballerine.

  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine.yml: Correctly uses ~/ballerine.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct reflection of the new installation directory in file paths.

# Test: Search for the old and new directory paths in the playbook. Expect: Only occurrences of the new path.
rg --type yaml $'/home/ubuntu/ballerine|~/ballerine' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/*.yml

Length of output: 1288


6-9: LGTM! Ensure that these user and group settings are correctly utilized in the playbook tasks.

Verification successful

The variables default_user, cloud_user, and cloud_group are correctly utilized in the playbook tasks.

  • default_user is used in setup-ballerine-runtime.yml and setup-init-config.yml.
  • cloud_user is used in setup-ballerine-runtime.yml, setup-init-config.yml, and setup-user-data.yml.
  • cloud_group is used in setup-ballerine-runtime.yml, setup-init-config.yml, and setup-user-data.yml.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of user and group settings in the playbook.

# Test: Search for the usage of `default_user`, `cloud_user`, and `cloud_group`. Expect: Correct usage in tasks.
rg --type yaml $'{{\\s*(default_user|cloud_user|cloud_group)\\s*}}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/*.yml

Length of output: 1010



Script:

#!/bin/bash
# Description: Verify the usage of user and group settings in the playbook.

# Test: Search for the usage of `default_user`, `cloud_user`, and `cloud_group`. Expect: Correct usage in tasks.
rg --type yaml '{{\s*(default_user|cloud_user|cloud_group)\s*}}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/

Length of output: 252



Script:

#!/bin/bash
# Description: Verify the usage of user and group settings in the playbook.

# Test: Search for the usage of `default_user`, `cloud_user`, and `cloud_group`. Expect: Correct usage in tasks.
rg --type yaml '{{\s*default_user\s*}}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/
rg --type yaml '{{\s*cloud_user\s*}}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/
rg --type yaml '{{\s*cloud_group\s*}}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/

Length of output: 602



Script:

#!/bin/bash
# Description: Verify the usage of user and group settings in the playbook.

# Test: Search for the usage of `default_user`, `cloud_user`, and `cloud_group`. Expect: Correct usage in tasks.
grep -r '{{ default_user }}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/
grep -r '{{ cloud_user }}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/
grep -r '{{ cloud_group }}' deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/

Length of output: 2435

deploy/aws_ami/template.json.pkr.hcl (2)

54-61: Provisioning setup using Ansible appears correctly configured. Ensure that the skipped tags (deploy) are intended and correctly implemented in the playbook.


2-51: Updates to AWS resource identifiers and the use of a local timestamp for naming are appropriate. Ensure the correctness of the new AWS resource identifiers.

deploy/docker-compose-build-https.yml (6)

110-110: Volume definition for postgres15 is correctly set up for persisting PostgreSQL data.


67-77: Configuration for the ballerine-workflows-dashboard service appears correctly set up. Ensure that environment variables like WORKFLOW_DASHBOARD_PORT and DOMAIN_NAME are correctly defined and used.

Verification successful

The environment variables WORKFLOW_DASHBOARD_PORT and DOMAIN_NAME are correctly defined and used in the deploy/docker-compose-build-https.yml file. The WORKFLOW_DASHBOARD_PORT is used in the ports mapping, and DOMAIN_NAME is used in various URL definitions.

  • WORKFLOW_DASHBOARD_PORT is mapped to port 80.
  • DOMAIN_NAME is used in URL definitions for VITE_API_URL, BACKOFFICE_CORS_ORIGIN, WORKFLOW_DASHBOARD_CORS_ORIGIN, and KYB_EXAMPLE_CORS_ORIGIN.

These definitions and usages appear to be correct and consistent with the service configuration.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct definition and usage of environment variables.

# Test: Search for the environment variable definitions. Expect: Correct definitions and usage.
rg --type yaml $'WORKFLOW_DASHBOARD_PORT|DOMAIN_NAME' deploy/docker-compose-build-https.yml

Length of output: 458


14-28: Configuration for the ballerine-kyb-app service appears correctly set up. Ensure that environment variables like KYB_APP_PORT and DOMAIN_NAME are correctly defined and used.


1-13: Configuration for the ballerine-case-managment service appears correctly set up. Ensure that environment variables like BACKOFFICE_PORT and DOMAIN_NAME are correctly defined and used.

Verification successful

The environment variables BACKOFFICE_PORT and DOMAIN_NAME are defined in the deploy/.env file:

  • BACKOFFICE_PORT=5137
  • DOMAIN_NAME=""

These definitions are correctly referenced in the deploy/docker-compose-build-https.yml file.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct definition and usage of environment variables.

# Test: Search for the environment variable definitions. Expect: Correct definitions and usage.
rg --type yaml $'BACKOFFICE_PORT|DOMAIN_NAME' deploy/docker-compose-build-https.yml

Length of output: 442



Script:

#!/bin/bash
# Description: Verify the definitions of environment variables BACKOFFICE_PORT and DOMAIN_NAME in the repository.

# Search for the definitions of BACKOFFICE_PORT and DOMAIN_NAME in .env files and other configuration files.
rg 'BACKOFFICE_PORT|DOMAIN_NAME' --glob '*.env' --glob '*.yml' --glob '*.yaml' --glob '*.sh' --glob '*.config'

Length of output: 1817


29-53: Configuration for the ballerine-workflow-service service appears correctly set up. Ensure that database connectivity settings like DB_URL, DB_USER, and DB_PASSWORD are correctly defined and used.

Verification successful

The database connectivity environment variables DB_URL, DB_USER, and DB_PASSWORD are correctly defined in the environment files and are used in the application code. The definitions and usages align with the expected configuration.

  • DB_USER and DB_PASSWORD are defined in deploy/.env.
  • DB_URL is used in services/workflows-service/src/test/db-setup.ts.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct definition and usage of database connectivity settings.

# Test: Search for the database connectivity settings. Expect: Correct definitions and usage.
rg --type yaml $'DB_URL|DB_USER|DB_PASSWORD' deploy/docker-compose-build-https.yml

Length of output: 214



Script:

#!/bin/bash
# Description: Verify the definition of database connectivity environment variables.

# Test: Search for the definitions of DB_URL, DB_USER, and DB_PASSWORD in environment files.
rg 'DB_URL|DB_USER|DB_PASSWORD' --glob '*.env' --glob '*docker-compose*.yml'

Length of output: 1691



Script:

#!/bin/bash
# Description: Verify the usage of database connectivity environment variables in the application code.

# Test: Search for the usage of DB_URL, DB_USER, and DB_PASSWORD in the application code.
rg 'process.env.DB_URL|process.env.DB_USER|process.env.DB_PASSWORD' --glob '*.{js,ts}'

Length of output: 311


78-97: Configuration for the ballerine-postgres service appears correctly set up. Ensure that PostgreSQL settings like POSTGRES_USER and POSTGRES_PASSWORD are correctly defined and used.

Verification successful

The PostgreSQL settings POSTGRES_USER and POSTGRES_PASSWORD are correctly defined in multiple configuration files, including deploy/docker-compose-build-https.yml. However, their usage in the codebase is not explicitly found, which suggests they are primarily used within the Docker Compose configurations.

  • services/workflows-service/docker-compose.yml
  • services/workflows-service/docker-compose.db.yml
  • deploy/docker-compose-build-https.yml
  • deploy/docker-compose-dev.yml
  • deploy/docker-compose-build.yml

These settings are consistent across the configurations, ensuring that the PostgreSQL service will use the defined credentials.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct definition and usage of PostgreSQL settings.

# Test: Search for the PostgreSQL settings. Expect: Correct definitions and usage.
rg --type yaml $'POSTGRES_USER|POSTGRES_PASSWORD' deploy/docker-compose-build-https.yml

Length of output: 146



Script:

#!/bin/bash
# Description: Verify the usage of PostgreSQL settings in the codebase.

# Test: Search for the usage of POSTGRES_USER and POSTGRES_PASSWORD environment variables.
rg 'POSTGRES_USER|POSTGRES_PASSWORD' --type sh --type js --type ts --type py

Length of output: 78



Script:

#!/bin/bash
# Description: Verify the usage of PostgreSQL settings in the entire codebase.

# Test: Search for the usage of POSTGRES_USER and POSTGRES_PASSWORD environment variables in all file types.
rg 'POSTGRES_USER|POSTGRES_PASSWORD'

Length of output: 746

deploy/ansible/ballerine_playbook/README.md (1)

102-102: Update command to skip Packer-related tasks during playbook execution.

This change aligns with the PR's objective to manage dependencies between different automation tasks effectively. Ensure that the --skip-tags packer option is well-documented in the playbook's usage scenarios to avoid confusion.

@@ -0,0 +1,11 @@
#!/bin/bash

cd /home/ballerine/ballerine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling to the cd command to ensure the script exits if the directory change fails.

- cd /home/ballerine/ballerine
+ cd /home/ballerine/ballerine || exit
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cd /home/ballerine/ballerine
cd /home/ballerine/ballerine || exit
Tools
Shellcheck

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)


git checkout dev ; git pull

cd /home/ballerine/ballerine/deploy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the script exits if the directory change fails.

- cd /home/ballerine/ballerine/deploy
+ cd /home/ballerine/ballerine/deploy || exit
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cd /home/ballerine/ballerine/deploy
cd /home/ballerine/ballerine/deploy || exit
Tools
Shellcheck

[warning] 7-7: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164)

Comment on lines 18 to +25

- name: Replace VITE URL for workflow-dashboard
lineinfile:
path: '~/ballerine/apps/workflows-dashboard/.env.example'
regexp: '^(.*)VITE_API_URL(.*)$'
line: "VITE_API_URL=https://{{ vite_api_url }}/api/v1/"
backrefs: yes
when: vite_api_url is defined
when: vite_api_url != ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The search results indicate that the vite_api_url variable is defined in deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml but is set to an empty string. This means that unless it is overridden elsewhere, the condition vite_api_url != "" will not be met, and the task to replace the VITE URL will be skipped.

  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml: vite_api_url: ''

To ensure the task executes correctly, vite_api_url should be set to a non-empty value.

Analysis chain

LGTM! Ensure that vite_api_url is appropriately set in the environment to avoid skipping this task unintentionally.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set in the environment.

# Test: Search for the environment variable setting. Expect: Non-empty value.
rg --type yaml $'vite_api_url: \".+\"' deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml

Length of output: 111



Script:

#!/bin/bash
# Description: Search for the `vite_api_url` variable across the entire repository to ensure it is set somewhere.

# Test: Search for any occurrences of `vite_api_url` in the repository.
rg 'vite_api_url' --glob '!*node_modules*'

Length of output: 1662

Comment on lines 10 to +17

- name: Replace VITE URL for kyb-app
lineinfile:
path: '~/ballerine/apps/kyb-app/.env.example'
regexp: '^(.*)VITE_API_URL(.*)$'
line: "VITE_API_URL=https://{{ vite_api_url }}/api/v1/"
backrefs: yes
when: vite_api_url is defined
when: vite_api_url != ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The vite_api_url variable is defined in deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml but is set to an empty string. This means that unless it is overridden elsewhere, the condition when: vite_api_url != "" will not be met, and the task to replace the VITE URL for kyb-app will be skipped.

  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml: vite_api_url: ''

Please ensure that vite_api_url is set to a non-empty value in the environment or in the appropriate configuration file to avoid skipping this task unintentionally.

Analysis chain

LGTM! Ensure that vite_api_url is appropriately set in the environment to avoid skipping this task unintentionally.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set in the environment.

# Test: Search for the environment variable setting. Expect: Non-empty value.
rg --type yaml $'vite_api_url: \".+\"' deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml

Length of output: 111



Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set somewhere in the repository.

# Test: Search for the environment variable setting. Expect: Non-empty value.
rg --type yaml 'vite_api_url: ".+"' 

Length of output: 37



Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set somewhere in the repository.

# Test: Search for the environment variable setting. Expect: Non-empty value.
rg 'vite_api_url' 

Length of output: 1637

Comment on lines +2 to +9

- name: Replace VITE URL for backoffice
lineinfile:
path: '~/ballerine/apps/backoffice-v2/.env.example'
regexp: '^(.*)VITE_API_URL(.*)$'
line: "VITE_API_URL=https://{{ vite_api_url }}/api/v1/internal"
backrefs: yes
when: vite_api_url is defined
when: vite_api_url != ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The vite_api_url variable is defined but set to an empty string in deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml. This means that unless it is overridden elsewhere, the condition vite_api_url != "" will not be met, and the task will be skipped.

  • deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml: vite_api_url: ''

Please ensure that vite_api_url is set to a non-empty value in the environment or overridden in a relevant configuration file to avoid skipping the task unintentionally.

Analysis chain

LGTM! Ensure that vite_api_url is appropriately set in the environment to avoid skipping this task unintentionally.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set in the environment.

# Test: Search for the environment variable setting. Expect: Non-empty value.
rg --type yaml $'vite_api_url: \".+\"' deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml

Length of output: 111



Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set in the environment.

# Test: Search for the environment variable setting across all YAML files. Expect: Non-empty value.
rg --type yaml 'vite_api_url: ".+"'

Length of output: 37



Script:

#!/bin/bash
# Description: Verify that `vite_api_url` is set in the environment.

# Test: Search for the environment variable setting across all files. Expect: Non-empty value.
rg 'vite_api_url'

Length of output: 1637

Comment on lines +98 to +108
image: caddy:latest
restart: unless-stopped
container_name: caddy
ports:
- 80:80
- 443:443
volumes:
- "../deploy/caddy/Caddyfile:/etc/caddy/Caddyfile"
- "../deploy/./caddy/site:/srv"
- "../deploy/caddy/caddy_data:/data"
- "../deploy/caddy/caddy_config:/config"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification script has revealed that the necessary volume paths for the Caddy configurations do not exist in the repository. This will cause issues when attempting to use the caddy service as defined in the docker-compose file.

  • The Caddyfile does not exist.
  • The caddy_data directory does not exist.
  • The caddy_config directory does not exist.

Please ensure these files and directories are created and correctly configured.

Analysis chain

Configuration for the caddy service appears correctly set up. Ensure that volume settings for Caddy configurations are correctly defined and used.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct definition and usage of volume settings for Caddy configurations.

# Test: Search for the volume settings. Expect: Correct definitions and usage.
rg --type yaml $'Caddyfile|caddy_data|caddy_config' deploy/docker-compose-build-https.yml

Length of output: 237



Script:

#!/bin/bash
# Description: Verify the existence and contents of the volume paths for Caddy configurations.

# Check if the Caddyfile exists
if [ -f "../deploy/caddy/Caddyfile" ]; then
  echo "Caddyfile exists."
else
  echo "Caddyfile does not exist."
fi

# Check if the caddy_data directory exists
if [ -d "../deploy/caddy/caddy_data" ]; then
  echo "caddy_data directory exists."
else
  echo "caddy_data directory does not exist."
fi

# Check if the caddy_config directory exists
if [ -d "../deploy/caddy/caddy_config" ]; then
  echo "caddy_config directory exists."
else
  echo "caddy_config directory does not exist."
fi

Length of output: 351

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 042fe4e and f7c4392.

Files selected for processing (1)
  • .github/workflows/packer-build-ami.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/packer-build-ami.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants