Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Remove TARGET_MACHINES in favour of the built-in HOSTFILTER.
Browse files Browse the repository at this point in the history
We stopped using TARGET_MACHINES in alphagov/govuk-puppet#10146.
  • Loading branch information
sengi committed Feb 14, 2020
1 parent 26f6fac commit 162e74c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -48,6 +48,6 @@ deploy scripts:
* `DEPLOY_TO` - the environment being deployed to
* `DEPLOY_TASK` - the deploy task selected in the Jenkins interface ("deploy", "deploy:setup", etc)
* `TAG` - the tag/branch entered in the Jenkins interface ("release", "release_1234", "build-1234", etc)
* `TARGET_MACHINES` - optional, comma-separated list of hosts to deploy to. This is intended for deploying apps onto new machine instances. If a machine doesn't match one of the app's `server_class` then it is ignored.
* `HOSTFILTER` - optional, comma-separated list of hosts to deploy to. We use this when deploying apps onto new machine instances. If a machine doesn't match one of the app's `server_class` then it is ignored. This is a Capistrano 2 feature.
* `ORGANISATION` - The vCloud organisation being deployed to
* `CI_DEPLOY_JENKINS_API_KEY` - API key used to fetch build artefacts from ci.dev.publishing.service.gov.uk.
15 changes: 2 additions & 13 deletions recipes/set_servers.rb
Expand Up @@ -41,25 +41,14 @@
# Get list of machines in the node class from Puppetmaster, using the
# govuk_node_list command.
begin
all_nodes_in_class = %x{govuk_node_list -c "#{c}"}.split
if all_nodes_in_class.empty?
nodes = %x{govuk_node_list -c "#{c}"}.split
if nodes.empty?
raise CommandError.new("set_servers: no servers with class '#{c}' in this environment!")
end
rescue Errno::ENOENT
raise CommandError.new("set_servers: govuk_node_list is not available!")
end

target_machines = ENV.fetch('TARGET_MACHINES', '')
if target_machines == 'all' || target_machines == ''
nodes = all_nodes_in_class
else
specified_nodes = target_machines.split(/\s*,\s*/)
# Exclude any machines which aren't in the current node class. This
# avoids deploying whitehall-admin to a whitehall_frontend machine, for
# example.
nodes = (specified_nodes.to_set & all_nodes_in_class.to_set).to_a
end

nodes.each_with_index do |node, index|
is_draft_server = !!(c =~ /^draft/)
parent.server node, *extra[:roles], :server_class => c, :primary => index.zero?, :draft => is_draft_server
Expand Down

0 comments on commit 162e74c

Please sign in to comment.