Media Edge Installation
This guide will walk you through the process of installing Media Edge on your servers. Media Edge is a software package that allows you to participate in Media Network as a provider. It enables you to monetize your resources by offering content delivery services to clients who need to distribute their web content efficiently and effectively.
Prerequisites
Being registered as a provider on Media Network is a prerequisite for installing Media Edge. If you haven't registered yet, please visit the registration page to sign up. You also need at least two servers with Debian 10 installed. One server will be used as the origin server, and the other as the edge server. You can have as many origin and edge servers as you want.
Step by Step Guide
Ensure these are installed on your local computer and target server(s):
🖥️ For Windows users: it is recommended to install Debian for the Windows Subsystem for Linux (WSL) from the Microsoft Store. This will allow for greater efficiency in installing Ansible, rsync, and typing commands.
🛠️ Installation
Clone the repository and its submodules:
git clone https://github.com/mediafoundation/media-edge.git
cd media-edge
git submodule init
git submodule updateNavigate to the
ansible
folder:cd ansible
Prepare the hosts file:
Rename
hosts.example
tohosts
.- Windows
- Linux
- macOS
copy hosts.example hosts
cp hosts.example hosts
cp hosts.example hosts
The
hosts
file is used in Ansible for defining groups of hosts and their connection details. Below is an example of how you can structure yourhosts
file to manage multiple servers, categorized asorigin
andedge
.[origin]
origin1 ansible_host=XXX.XXX.XXX.XXX ansible_port=22 ansible_user=root
[edge]
edge1 ansible_host=XXX.XXX.XXX.XXX ansible_port=22 ansible_user=rootReplace X with your server's IP addresses.
Explanation
Groups ([origin], [edge])
- Groups are defined within square brackets ([]). Each group can contain one or more servers with similar roles or configurations.
Host Definitions
- Each host entry starts with a unique name (origin1, edge1) that identifies the server.
- ansible_host: specifies the IP address or hostname of the server.
- ansible_port: specifies the SSH port number used for Ansible connections (default is 22).
- ansible_user: specifies the username used for SSH authentication (often root for administrative tasks).
Usage Tips
- Adding more hosts: you can add additional hosts to either [origin] or [edge] groups by following the same format.
- Dynamic Inventory: for larger setups, consider using dynamic inventory scripts to automatically populate the hosts file based on cloud providers, databases, or other external sources.
Set up your configuration:
Rename
user_config.yml.example
touser_config.yml
and follow the steps below to correctly specify the necessary parameters.- Windows
- Linux
- macOS
copy user_config.yml.example user_config.yml
cp user_config.yml.example user_config.yml
cp user_config.yml.example user_config.yml
Detailed Steps
Wallet Address
- Specify your wallet address within double quotes to avoid it being interpreted as a hex number.
- Example:
wallet_address: "0x0000000000000000000000000000000000000000"
Private Key
- Provide the private key for decrypting resources. Ensure it's 64 characters long.
- Caution: Use a private key from a wallet without funds to prevent hacking and fund loss.
- Example:
private_key: 0000000000000000000000000000000000000000000000000000000000000000
Networks
- Specify the networks where you are providing services, including the network ID and URL. You can find the Network ID in the DAPP in the navigation menu under "More" -> "Contract Addresses" or directly access it at /info.
- If URL is undefined, the default RPC from the media-sdk will be used.
- Example:
networks:
- id: 11155111
URL: undefinedMarketplace ID
- Select the marketplace ID where you are providing services.
- Example:
marketplace_id: 1
Origin IP Address and CNAME
- Specify the IP address and CNAME for your origin.
- Example:
origin_ip: XXX.XXX.XXX.XXX
cname: cname.yourdomain.comDNS Configuration
- Configure DNS for caddy to create TXT records to pass ACME challenges.
- Specify the DNS provider and environment variables for authentication.
- Example:
dns_config:
lego: cloudflare
env_vars:
- CLOUDFLARE_EMAIL=example@yourmail.com
- CLOUDFLARE_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
domains:
- yourdomain.comPostgreSQL Configuration
- Provide the PostgreSQL database connection details including host, port, user, password, and database name.
- Example:
db_host: localhost
db_port: 5432
db_user: origin
db_password: changeme1234
db_name: origin
Deploy Media Edge:
Execute the playbook using the
ansible-playbook
command, specifying yourdeploy.yml
andhosts
file:ansible-playbook deploy.yml -i hosts
This command initiates Ansible to connect to the specified hosts and execute the tasks defined in
deploy.yml
.
By following these steps, you can effectively deploy and manage your media edge infrastructure using Ansible, ensuring consistency and reliability across your distributed network.
Feel free to adjust the instructions based on your specific deployment requirements and infrastructure setup.