To effectively route commands to Relay, we need to inform Cog of each Relay and configure each Relay to communicate with Cog via the message bus.
Cog needs at least one Relay in order to deploy command bundles and execute commands. Configuring Cog to know about a new Relay instance is a simple three step process.
- Pick a secret word or phrase shared between Cog and the new Relay instance. Cog’s API refers to this secret as a token.
- Use
cogctl
to tell Cog about the Relay and its secret.
Configuring a new relay.
$ cogctl relays create my_new_relay --token="my fancy sekrit"
ID f8e3ead2-57e0-4fb2-81e9-24bf6c104202
Name my_new_relay
$
- Use the ID and token from step #2 to start the Relay instance.
Relay starting up.
$ RELAY_ID=bd03d7f0-b670-4721-9121-c23e62583e49 RELAY_COG_TOKEN="my fancy sekrit" relay
INFO[2016-04-18T14:42:57-04:00] Loaded configuration file ./cog_relay.conf.
INFO[2016-04-18T14:42:57-04:00] Relay f8e3ead2-57e0-4fb2-81e9-24bf6c104202 is initializing.
INFO[2016-04-18T14:42:57-04:00] Docker execution engine enabled.
INFO[2016-04-18T14:42:57-04:00] Native execution engine enabled.
INFO[2016-04-18T14:42:57-04:00] Verifying Docker registry credentials.
INFO[2016-04-18T14:42:58-04:00] Docker configuration verified.
INFO[2016-04-18T14:42:58-04:00] Started 8 workers.
INFO[2016-04-18T14:43:00-04:00] Connected to Cog host 10.10.2.12.
INFO[2016-04-18T14:43:00-04:00] Refreshing bundles and related assets every 30s.
INFO[2016-04-18T14:43:00-04:00] Cleaning up expired Docker assets every 5m0s.
INFO[2016-04-18T14:43:00-04:00] Refreshing command bundles.
INFO[2016-04-18T14:43:00-04:00] Bundle refresh complete.
INFO[2016-04-18T14:43:00-04:00] Relay f8e3ead2-57e0-4fb2-81e9-24bf6c104202 ready.
A fully commented example relay.conf
file can be found here.
Once a Relay has been created it can be assigned to one or more relay groups. Relay groups are merely named groups of Relays used to organize many Relays into logical groupings.
Note
You can read about how Cog uses relay groups to simplify command bundle deployment in managing_bundles
.
No relay groups are defined when Cog is first installed so you’ll need to use cogctl
to create at least one.
Creating a relay group.
$ cogctl relay-groups create my_relay_group
ID c3d29691-dc5b-4adf-a88b-53aff0e2bfa4
Name my_relay_group
$
You can also create a relay group and assign Relays to it in a single command, too.
Creating a relay group with members.
$ cogctl relay-groups create my_newer_group --members=my_new_relay
ID 0916ff66-07f9-46bc-bd94-46a540333cb1
Name my_newer_group
Adding 'my_new_relay' to relay group 'my_newer_group': Ok.
$
Members can be added or removed from a relay group at any time with cogctl
's relay-groups add
and relay-groups remove
actions.
Adding and removing group members.
$ cogctl relay-groups add my_relay_group --relay my_new_relay
Relay `my_new_relay` added to relay group `my_relay_group`
$ cogctl relay-groups remove my_relay_group --relay my_other_relay
Relay `my_other_relay` removed from relay group `my_relay_group`
$
Finally, you can view a detailed description of a relay group with cogctl
's relay-groups info
action.
Viewing a relay group.
$ cogctl relay-groups info my_relay_group
Name my_relay_group
ID c3d29691-dc5b-4adf-a88b-53aff0e2bfa4
Creation Time 2016-04-19T18:55:52Z
Relays
NAME ID
my_new_relay f8e3ead2-57e0-4fb2-81e9-24bf6c104202
$
Now you are ready to add managing_bundles
to your relays in order to execute your installed commands.