Guest User

Untitled

a guest
Nov 12th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. plan examples::swarm(TargetSpec $managers, TargetSpec $workers) {
  2. $hosts = [$managers, $workers]
  3. $hosts.apply_prep
  4. apply($hosts) {
  5. include 'docker'
  6. }
  7.  
  8. # Initialize the swarm on a single manager.
  9. $targets = get_targets($managers)
  10. $master = $targets[0]
  11. $init_result = run_command('docker swarm init', $master, _catch_errors => true)
  12. # Allow init to fail in case we're running it again. Log the result.
  13. notice($init_result)
  14.  
  15. $manager_token = run_command('docker swarm join-token manager --quiet', $master).first['stdout'].chomp
  16. $mgr_result = run_command("docker swarm join --token ${manager_token} ${$master.host}:2377", $targets[1,-1], _catch_errors => true)
  17. notice($mgr_result)
  18.  
  19. $worker_token = run_command('docker swarm join-token worker --quiet', $master).first['stdout'].chomp
  20. return run_command("docker swarm join --token ${worker_token} ${$master.host}:2377", $workers)
  21. }
Add Comment
Please, Sign In to add comment