Last active
November 12, 2018 18:57
-
-
Save MikaelSmith/11e9d96d33d40103bbee63933c0f2caf to your computer and use it in GitHub Desktop.
Install and bootstrap Docker Swarm using Bolt + the Puppet Docker module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plan examples::swarm(TargetSpec $managers, TargetSpec $workers) { | |
$hosts = [$managers, $workers] | |
$hosts.apply_prep | |
apply($hosts) { | |
include 'docker' | |
} | |
# Initialize the swarm on a single manager. | |
$targets = get_targets($managers) | |
$master = $targets[0] | |
$init_result = run_command('docker swarm init', $master, _catch_errors => true) | |
# Allow init to fail in case we're running it again. Log the result. | |
notice($init_result) | |
$manager_token = run_command('docker swarm join-token manager --quiet', $master).first['stdout'].chomp | |
$mgr_result = run_command("docker swarm join --token ${manager_token} ${$master.host}:2377", $targets[1,-1], _catch_errors => true) | |
notice($mgr_result) | |
$worker_token = run_command('docker swarm join-token worker --quiet', $master).first['stdout'].chomp | |
return run_command("docker swarm join --token ${worker_token} ${$master.host}:2377", $workers) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment