Creating a CyMaIs Role for Docker Containers 🚀

This guide explains how to create a new CyMaIs role for deploying Docker containers, using the existing docker-gitea role as a template. The guide was generated with ChatGPT and is based on the following conversation: :link: ChatGPT Conversation

:link: References


:pushpin: Steps to Create a New Docker Role

:one: Fork the Repository and Create a New Branch

  1. Navigate to CyMaIs GitHub and create a fork of the repository.
  2. Clone your fork locally:
    git clone https://github.com/<your-username>/cymais.git
    cd cymais
    
  3. Create a new branch for your changes:
    git checkout -b feature/docker-<your-service>
    

:two: Copy the docker-gitea Role as a Template

  1. Navigate to the roles/ directory:
    cd cymais/roles
    
  2. Copy the docker-gitea role and rename it:
    cp -r docker-gitea docker-<your-service>
    
  3. Update meta/main.yml, tasks/main.yml, and defaults/main.yml to match your new service.

:three: Modify the Playbook to Include the New Role

Edit the playbook.servers.yml file and add your new role under the roles section:

- hosts: all
  roles:
    - role: docker-<your-service>

:four: Add Necessary Variables

:pushpin: Domains Configuration

Update the 03_domains.yml file with:

<your_service>_domain: "your-service.example.com"

:pushpin: Ports Configuration

Update the 09_ports.yml file with:

<your_service>_port: "<your_port>"

:five: Set Environment Variables :open_file_folder:

Make sure to define the necessary environment variables in the appropriate environment files. Ansible will issue warnings if variables are not set, so double-check them before deployment.

:six: Commit and Push Your Changes

  1. Add your changes:
    git add .
    
  2. Commit your updates:
    git commit -m "Add new docker role for <your-service>"
    
  3. Push your changes to your fork:
    git push origin feature/docker-<your-service>
    

:seven: Create a Pull Request

  1. Navigate to your fork on GitHub.
  2. Open a Pull Request (PR) against the main CyMaIs repository.
  3. Provide a clear description of your changes and request a review.

:white_check_mark: Final Steps

  1. Test your role using ansible-playbook --check to verify configuration.
  2. Once everything is ready, deploy your new service!

This guide was created with the help of ChatGPT :robot:. If you have any questions or improvements, feel free to contribute to CyMaIs. :rocket: