diff --git a/docker-compose/.env b/docker-compose/.env new file mode 100644 index 0000000..357822c --- /dev/null +++ b/docker-compose/.env @@ -0,0 +1 @@ +HOST_IP=192.168.0.1 diff --git a/docker-compose/Makefile b/docker-compose/Makefile new file mode 100644 index 0000000..54b63b0 --- /dev/null +++ b/docker-compose/Makefile @@ -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 diff --git a/docker-compose/README.md b/docker-compose/README.md new file mode 100644 index 0000000..89569cb --- /dev/null +++ b/docker-compose/README.md @@ -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 +``` diff --git a/docker-compose/configs/toddagent.toml b/docker-compose/configs/toddagent.toml new file mode 100644 index 0000000..9bbad9a --- /dev/null +++ b/docker-compose/configs/toddagent.toml @@ -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. diff --git a/docker-compose/configs/toddserver.toml b/docker-compose/configs/toddserver.toml new file mode 100644 index 0000000..c385b3b --- /dev/null +++ b/docker-compose/configs/toddserver.toml @@ -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. diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml new file mode 100644 index 0000000..5b0651f --- /dev/null +++ b/docker-compose/docker-compose.yml @@ -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 diff --git a/docker-compose/objects/group-dc.yaml b/docker-compose/objects/group-dc.yaml new file mode 100644 index 0000000..0867686 --- /dev/null +++ b/docker-compose/objects/group-dc.yaml @@ -0,0 +1,7 @@ +--- +type: group +label: agent-dc +spec: + group: dc + matches: + - within_subnet: "172.25.1.0/24" diff --git a/docker-compose/objects/group-hq.yaml b/docker-compose/objects/group-hq.yaml new file mode 100644 index 0000000..8d99388 --- /dev/null +++ b/docker-compose/objects/group-hq.yaml @@ -0,0 +1,7 @@ +--- +type: group +label: agent-hq +spec: + group: hq + matches: + - within_subnet: "172.25.2.0/24" diff --git a/docker-compose/objects/test-http.yaml b/docker-compose/objects/test-http.yaml new file mode 100644 index 0000000..b19c174 --- /dev/null +++ b/docker-compose/objects/test-http.yaml @@ -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 diff --git a/docker-compose/objects/test-ping-dns.yaml b/docker-compose/objects/test-ping-dns.yaml new file mode 100644 index 0000000..7eb9b12 --- /dev/null +++ b/docker-compose/objects/test-ping-dns.yaml @@ -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 diff --git a/docker-compose/objects/test-ping.yaml b/docker-compose/objects/test-ping.yaml new file mode 100644 index 0000000..c273bea --- /dev/null +++ b/docker-compose/objects/test-ping.yaml @@ -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"