Skip to content

Commit becc5ba

Browse files
author
Jonathan Owens
committed
Add env var lambda example in README
1 parent 492d7ee commit becc5ba

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,24 @@ specified more than once and will append to the configuration. However, there
142142
can only be one `command`; the last one will take priority.
143143

144144
You can also assign lambdas to environment variables. The lambda function will
145-
be invoked by Centurion with `server_hostname` as its only argument. This is
146-
useful to assign a sticky identity for each of the containers in the deploy.
145+
be invoked by Centurion during deploy time with `server_hostname` as its only
146+
argument. The `server_hostname` yielded will be the same string as was
147+
specified in the `host` argument for the server currently being deployed to.
148+
149+
This is useful to assign a sticky identity for each of the containers
150+
in the deploy. For example, a hash mapping hostname to another string which is
151+
different on each host.
152+
```ruby
153+
desc 'Host-specific env vars'
154+
task :production => :common do
155+
env_vars MEMBER_ID: lambda do |hostname|
156+
{
157+
'web-server-1.company.net' => 'machine1'
158+
'web-server-2.company.net' => 'machine2'
159+
}[hostname]
160+
end
161+
end
162+
```
147163

148164
You can cause your container to be started with a specific DNS server
149165
IP address (the equivalent of `docker run --dns 172.17.42.1 ...`) like this:

0 commit comments

Comments
 (0)