testnet-ops/service-provider-setup
nabarun f597e5dfc7 Add result with endpoints to service-provider-setup README (#11)
Part of [Service Provider setup](https://www.notion.so/Service-provider-setup-a09e2207e1f34f3a847f7ce9713b7ac5)
- Add tasks to create DNS records for daemon
- Add DNS resolution check with retries for daemon URL

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: cerc-io/testnet-ops#11
2024-10-08 12:41:36 +00:00
..
templates Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
vars Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
.gitignore Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00
deploy-backend.yml Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00
deploy-frontend.yml Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00
README.md Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
run-laconic-console.yml Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
run-laconicd.yml Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00
service-provider-setup.yml Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00
setup-container-registry.yml Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00
setup-dns.yml Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
setup-k8s.yml Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
setup-system.yml Add result with endpoints to service-provider-setup README (#11) 2024-10-08 12:41:36 +00:00
setup-user.yml Add ansible playbook to automate service provider setup (#10) 2024-10-01 12:17:10 +00:00

service-provider-setup

Setup Ansible

To get started, follow the installation guide to setup ansible on your machine

Prerequisites

  • Set up a DigitalOcean Droplet with passwordless SSH access

  • Buy a domain and configure nameservers pointing to DigitalOcean

  • Generate a DigitalOcean access token, used for API authentication and managing cloud resources

Setup a new User

  • Create a new hosts.ini file:

    cp ../hosts.example.ini hosts.ini
    
  • Edit the hosts.ini file to run the playbook on a remote machine:

    [root_host]
    <host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
    
    • Replace <host_name> with the desired hostname of the remote machine
    • Replace <target_ip> with the IP address or hostname of the target machine
    • Replace <ssh_user> with root
  • Verify that you are able to connect to the host using the following command:

    ansible all -m ping -i hosts.ini
    
    # Expected output:
    
    # <host_name> | SUCCESS => {
    #  "ansible_facts": {
    #      "discovered_interpreter_python": "/usr/bin/python3.10"
    #  },
    #  "changed": false,
    #  "ping": "pong"
    # }
    
  • Setup user-vars.yml using the example file

    cp vars/user-vars.example.yml vars/user-vars.yml
    
  • Edit the user-vars.yml file:

    # name of the user you want to setup on the target host
    username: ""
    
    # password of the user you want to setup on the target host
    password: ""
    
    # path to the ssh key on your machine, eg: "/home/user/.ssh/id_rsa.pub"
    path_to_ssh_key: ""
    
  • Execute the setup-user.yml Ansible playbook to create a user with passwordless sudo permissions:

    LANG=en_US.utf8 ansible-playbook setup-user.yml -i hosts.ini --extra-vars='{ "target_host": "deployment_host" }'
    

Become a Service Provider

Setup

  • Copy the vars files:

    cd vars
    cp dns-vars.example.yml dns-vars.yml
    cp gpg-vars.example.yml gpg-vars.yml
    cp k8s-vars.example.yml k8s-vars.yml
    cp container-vars.example.yml container-vars.yml
    cp webapp-vars.example.yml webapp-vars.yml
    cd -
    
  • Update the following values in the respective variable files:

    # vars/dns-vars.yml
    full_domain: ""               # eg: laconic.com
    subdomain_prefix: ""          # eg: lcn-cad
    service_provider_ip: ""        # eg: 23.111.78.179
    do_api_token: ""              # Digital Ocean access token that you generated, eg: dop_v1...
    
    # vars/gpg-vars.yml
    gpg_user_name: ""         # Full name of the user for the GPG key
    gpg_user_email: ""        # Email address associated with the GPG key
    gpg_passphrase: ""        # Passphrase for securing the GPG key
    
    # vars/k8s-vars.yml
    target_host: "deployment_host"
    org_id: ""                    # eg: lcn
    location_id: ""               # eg: cad
    base_domain: ""               # eg: laconic
    support_email: ""             # eg: support@laconic.com
    
    # vars/container-vars.yml
    container_registry_username: "" # username to login to the container registry
    container_registry_password: "" # password to login to the container registry
    
    # vars/webapp-vars.yml
    authority_name: ""      # eg: my-org-name
    cpu_reservation: ""     # Minimum number of cpu cores to be used, eg: 2
    memory_reservation: ""  # Minimum amount of memory in GB to be used, eg: 4G
    cpu_limit: ""           # Maximum number of cpu cores to be used, eg: 6
    memory_limit: ""        # Maximum amount of memory in GB to be used, eg: 8G
    deployer_gpg_passphrase: "" # passphrase for creating GPG key used by webapp-deployer, eg: SECRET
    
  • Update the hosts.ini file:

    [root_host]
    <host_name> ansible_host=<target_ip> ansible_user=root ansible_ssh_common_args='-o ForwardAgent=yes'
    
    [deployment_host]
    <host_name> ansible_host=<target_ip> ansible_user=<new_username> ansible_ssh_common_args='-o ForwardAgent=yes'
    
    • Replace <host_name> with the desired hostname of the remote machine
    • Replace <target_ip> with the IP address or hostname of the target machine
    • Under deployment_host, Replace <ansible_user> with the name of the user you have created
  • Verify that you are able to connect to the host using the following command:

    ansible all -m ping -i hosts.ini
    
    # Expected output:
    
    # <host_name> | SUCCESS => {
    #  "ansible_facts": {
    #      "discovered_interpreter_python": "/usr/bin/python3.10"
    #  },
    #  "changed": false,
    #  "ping": "pong"
    # }
    
  • Run the service-provider-setup.yml ansible-playbook to:

    • Create DNS records
    • Deploy k8s
    • Setup laconicd and laconic console
    • Setup container registry
    • Deploy the webapp-deployer API and webapp-deployer UI
    LANG=en_US.utf8 ansible-playbook service-provider-setup.yml -i hosts.ini --extra-vars='{ target_host: "deployment_host" }' --user $USER
    

Result

After the playbook finishes executing, the following services will be deployed (your setup should look similar to the example below):