Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HOST_IP=192.168.0.1
26 changes: 26 additions & 0 deletions docker-compose/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Rabbitmq and ETC needs to be started first to make sure that todd server starts properly
start:
docker-compose up -d rabbitmq etcd
docker-compose up -d

stop:
docker-compose down

init:
@echo "Create Groups agent-dc and agent-hq in Todd"
@docker exec -it dockercompose_toddserver_1 todd create /root/group-dc.yaml
@docker exec -it dockercompose_toddserver_1 todd create /root/group-hq.yaml
@echo "Create Tests in Todd"
@docker exec -it dockercompose_toddserver_1 todd create /root/test-ping-dns.yaml
@docker exec -it dockercompose_toddserver_1 todd create /root/test-ping.yaml
@docker exec -it dockercompose_toddserver_1 todd create /root/test-http.yaml

show-agents:
docker exec -it dockercompose_toddserver_1 todd agents

show-groups:
docker exec -it dockercompose_toddserver_1 todd groups

cli:
docker exec -it dockercompose_toddserver_1 bash
35 changes: 35 additions & 0 deletions docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# Start all components
By default it will start: The todd server, Rabbitmq, etcd and 2 todd agents
```
make start
```

Both agents should register automatically, you can check using:
```
✗ make agents
docker exec -it dockercompose_toddserver_1 todd agents
UUID EXPIRES ADDR FACT SUMMARY COLLECTOR SUMMARY
9c5992d8622e 23s 172.25.2.3 Addresses, Hostname get_addresses, get_hostname
7d9d0f0ec4b7 23s 172.25.1.3 Hostname, Addresses get_addresses, get_hostname
```

You can increase the number of agents with docker-compose using `docker-compose scale`
```
docker-compose scale agent-hq=2 agent-dc=3
```
> New agents will register automatically, you can check using `make show-agents`

# Create groups and tests in todd
Once all components are up, you need to create some `groups` and `tests`.
you can create the predefined groups and tests with:
```
make init
```
it will create 2 groups `agent-hq` and `agent-dc` and create 3 tests.

# access the Todd Cli

```
make cli
```
20 changes: 20 additions & 0 deletions docker-compose/configs/toddagent.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Describes parameters for the "comms" system, which manages communications between
# the server and the agents
[Comms]
User = guest # Username for comms
Password = guest # Password for comms
Host = rabbitmq # Hostname or IP address for comms
Port = 5672 # Port for comms
Plugin = rabbitmq # Comms plugin to use (i.e. "rabbitmq")

# Describes parameters for local resources, such as network or filesystem resources
[LocalResources]
DefaultInterface = eth0 # Dictates what network interface is used for testing
# purposes (i.e. informs the todd-server which IP
# address can be used

# IPAddrOverride = 192.168.99.100 # Overrides DefaultInterface by providing a specific IP
# address rather

OptDir = /opt/todd/agent # Operational directory for the agent. Houses things like
# cache files, user-defined testlets, etc.
51 changes: 51 additions & 0 deletions docker-compose/configs/toddserver.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ToDD's API
[API]
Host = 0.0.0.0
Port = 8080

# Serves assets like collectors, testlets, etc.
[Assets]
IP = 0.0.0.0
Port = 8090

# Describes parameters for the "comms" system, which manages communications between
# the server and the agents
[Comms]
User = guest # Username for comms
Password = guest # Password for comms
Host = rabbitmq # Hostname or IP address for comms
Port = 5672 # Port for comms
Plugin = rabbitmq # Comms plugin to use (i.e. "rabbitmq")

# Parameters for database connectivity
[DB]
Host = etcd # Hostname or IP address for database
Port = 4001 # Port for database
Plugin = etcd # Database plugin to use (i.e. "etcd")

# Parameters for time-series database connectivity
[TSDB]
Host = influxdb # Hostname or IP address for tsdb
Port = 8086 # Port for tsdb
Plugin = influxdb # TSDB plugin to use (i.e. "influxdb")
DatabaseName = todd # Todd

[Grouping]
Interval = 10 # Interval (in seconds) for the grouping calculation
# to run on the server

[Testing]
Timeout = 30 # This is the timer (in seconds) that a test will be
# allowed to live

# Describes parameters for local resources, such as network or filesystem resources
[LocalResources]
DefaultInterface = eth2 # Dictates what network interface is used for testing
# purposes (i.e. informs the todd-server which IP
# address can be used

IPAddrOverride = toddserver # Overrides DefaultInterface by providing a specific IP
# address rather

OptDir = /opt/todd/agent # Operational directory for the agent. Houses things like
# cache files, user-defined testlets, etc.
105 changes: 105 additions & 0 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
version: '2'

services:
# -------------------------------------------------------------------------
# Todd Server
# -------------------------------------------------------------------------
toddserver:
image: toddproject/todd
command:
- 'todd-server'
volumes:
- /etc/localtime:/etc/localtime
- ./objects:/root
- ./configs/toddserver.toml:/etc/todd/server.cfg
# ports:
# - "8080:8080"
depends_on:
- etcd
- rabbitmq
- influxdb
networks:
- default
- agent-hq
- agent-dc

# -------------------------------------------------------------------------
# Todd Agent - Group DC
# -------------------------------------------------------------------------
agent-dc:
image: toddproject/todd
command:
- 'todd-agent'
volumes:
- /etc/localtime:/etc/localtime
- ./configs/toddagent.toml:/etc/todd/agent.cfg
networks:
- agent-dc

# -------------------------------------------------------------------------
# Todd Agent - Group HQ
# -------------------------------------------------------------------------
agent-hq:
image: toddproject/todd
volumes:
- /etc/localtime:/etc/localtime
- ./configs/toddagent.toml:/etc/todd/agent.cfg
command:
- 'todd-agent'
networks:
- agent-hq

# -------------------------------------------------------------------------
# Etcd
# -------------------------------------------------------------------------
etcd:
image: quay.io/coreos/etcd:v3.1.3
# ports:
# - '2379:2379'
# - '2380:2380'
# - '4001:4001'
command: /usr/local/bin/etcd -name etcd0 -advertise-client-urls http://${HOST_IP}:2379,http://${HOST_IP}:4001 -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 -initial-advertise-peer-urls http://${HOST_IP}:2380 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster-1 -initial-cluster etcd0=http://${HOST_IP}:2380 -initial-cluster-state new
volumes:
- /etc/localtime:/etc/localtime

# -------------------------------------------------------------------------
# Rabbitmq
# -------------------------------------------------------------------------
rabbitmq:
image: rabbitmq:3
volumes:
- /etc/localtime:/etc/localtime
# ports:
# - "5672:5672"
networks:
- default
- agent-hq
- agent-dc

# -------------------------------------------------------------------------
# Influxdb
# -------------------------------------------------------------------------
influxdb:
image: influxdb:1.1.1-alpine
volumes:
- /etc/localtime:/etc/localtime
environment:
- "INFLUXDB_ADMIN_ENABLED=true"
# ports:
# - "8083:8083"
# - "8086:8086"
networks:
- default

# -------------------------------------------------------------------------
# Network Configuration
# -------------------------------------------------------------------------
networks:
agent-dc:
ipam:
config:
- subnet: 172.25.1.0/24
agent-hq:
ipam:
config:
- subnet: 172.25.2.0/24
7 changes: 7 additions & 0 deletions docker-compose/objects/group-dc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: group
label: agent-dc
spec:
group: dc
matches:
- within_subnet: "172.25.1.0/24"
7 changes: 7 additions & 0 deletions docker-compose/objects/group-hq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: group
label: agent-hq
spec:
group: hq
matches:
- within_subnet: "172.25.2.0/24"
13 changes: 13 additions & 0 deletions docker-compose/objects/test-http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Example test file
type: testrun
label: test-http
spec:
targettype: uncontrolled
source:
name: agent-dc
app: http
args: ""
target:
- salesforce.com
- portal.office.com
13 changes: 13 additions & 0 deletions docker-compose/objects/test-ping-dns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Example test file
type: testrun
label: test-ping-dns-dc
spec:
targettype: uncontrolled
source:
name: agent-dc
app: ping
args: "-c 10"
target:
- 4.2.2.2
- 8.8.8.8
14 changes: 14 additions & 0 deletions docker-compose/objects/test-ping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# Example test file
type: testrun
label: test-ping
spec:
targettype: group
source:
name: agent-dc
app: ping
args: "-c 10"
target:
name: agent-hq
app: ping
args: "-c 10"