Skip to content

Commit dc5cbd3

Browse files
committed
ansible v2
1 parent 61e259f commit dc5cbd3

2 files changed

Lines changed: 65 additions & 1 deletion

File tree

ansible/vars/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
github_username: "x-access-token"
3-
github_pat: "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"
3+
github_pat: "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"
44
git_repo_url: "https://github.com/Healthcare-Monitoring-System/d2-data-intelligence.git"
55
repo_dest: "/opt/d2-data-intelligence"

ansible_use.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# D2 Ansible Deployment Guide
2+
3+
This guide explains how to use the Ansible playbook to fully automate the deployment of the D2 Data Intelligence stack to a fresh EC2 instance.
4+
5+
## Prerequisites
6+
7+
1. **Local SSH Setup**: Ensure your `~/.ssh/config` is set up with an alias for your EC2 instance (e.g., `king`), or know the IP and path to your private key (e.g., `Nadeesha.pem`).
8+
2. **GitHub PAT**: The repository (`d2-data-intelligence`) is private. We use a GitHub Personal Access Token (PAT) so Ansible and ArgoCD can automatically fetch the repository.
9+
10+
### Generating a GitHub PAT
11+
1. Go to your GitHub account **Settings** -> **Developer Settings** -> **Personal Access Tokens** -> **Tokens (classic)**.
12+
2. Click **Generate new token (classic)**.
13+
3. Name it (e.g., `d2-deployment`), set the expiration, and check the **`repo`** scope box.
14+
4. Generate the token and copy it (it starts with `ghp_` or `github_pat_`).
15+
16+
## Configuration
17+
18+
1. **Inventory (`inventory.ini`)**:
19+
Ensure `inventory.ini` points to your instance. If using your SSH config alias `king`, simply use:
20+
```ini
21+
[d2_servers]
22+
king ansible_host=<IP> ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/Nadeesha.pem
23+
```
24+
25+
2. **Variables (`vars/main.yml`)**:
26+
Paste your GitHub PAT into `vars/main.yml`:
27+
```yaml
28+
github_username: "x-access-token"
29+
github_pat: "github_pat_YOUR_TOKEN_HERE"
30+
```
31+
*(Note: The username can safely be `x-access-token`. GitHub only cares about the valid token).*
32+
33+
## Running the Playbook
34+
35+
To provision a fresh server, run the following from your laptop:
36+
37+
```bash
38+
cd ansible
39+
ansible-playbook site.yml
40+
```
41+
42+
### What the Playbook Does:
43+
- Upgrades system packages and configures the `ufw` firewall (opening ports 80, 443, 6443, 5432, 8086, etc.).
44+
- Installs K3s (Kubernetes) automatically.
45+
- Installs ArgoCD natively using Kubernetes Server-Side Apply to bypass manifest size limits.
46+
- Clones the private repository to the server using your PAT.
47+
- Injects your PAT into ArgoCD as a Kubernetes Secret so it can sync manifests from GitHub continuously.
48+
- Deploys all ArgoCD applications into the cluster.
49+
50+
## Post-Deployment & Troubleshooting
51+
52+
**Checking the cluster:**
53+
SSH into the server:
54+
```bash
55+
ssh king
56+
```
57+
Check the pods:
58+
```bash
59+
kubectl get pods -n d2 -o wide
60+
```
61+
*Note: Do **NOT** use `sudo kubectl`. The `ubuntu` user has been explicitly configured to communicate with K3s. Using `sudo` will cause it to fail looking for root credentials.*
62+
63+
**Checking ArgoCD:**
64+
The playbook automatically prints the initial ArgoCD admin password at the end of the run. You can use it to log into the UI (once exposed) or via the CLI.

0 commit comments

Comments
 (0)