1

The documentation of a swarm mode setup seems to be missing something important.
It looks like to manage swarm with puppet I need to provide a token.
But to get the token I need to go to the manager node and type docker swarm join-token -q, copy the output and paste it into puppet?

Am I missing something? Or there's some automated way to do that? What I would expect is this:

if(host_has_label("my-swarm-manager")) {
  docker::swarm {'cluster_manager':
    init           => true,
    advertise_addr => current_host_ip(),
    listen_addr    => current_host_ip(),
    swarm_name     => 'my-swarm'
  }
} else if (host_has_label("my-swarm-worker")) {
  docker::swarm {'cluster_worker':
    join           => true,
    advertise_addr => current_host_ip(),
    listen_addr    => current_host_ip(),
    manager_ip     => get_ip_by_swarm_name('my-swarm'),
    token          => get_token_by_swarm_name('my-swarm')
  }
}

Swarm mode token

Arya N
  • 95
  • 1
  • 1
  • 6
  • What module are you using? – Matthew Schuchard Mar 18 '19 at 11:00
  • `puppetlabs-docker --version 3.5.0` [Puppetlabs module](https://forge.puppet.com/puppetlabs/docker) – Arya N Mar 18 '19 at 13:17
  • To clarify the question for anyone else, the question is not how to do something which is absent in functionality from the module (as the question and pseudocode imply), but rather how to pass the token to the module. To that effect, you would need exported resources, the explanation of which is in several answers by John Bollinger. He can probably link to his favorite. – Matthew Schuchard Mar 18 '19 at 13:20
  • Although this problem has several features that seem well suited for [exported resources](https://stackoverflow.com/a/53351848/2402272), there is a wrinkle that the join token is computed when the swarm is created, and is only available from a manager node. If there is any desire to add additional managers to a swarm, then this issue will affect them, too. This isn't something that the module could reasonably work around internally. – John Bollinger Mar 18 '19 at 14:32
  • I see at least a couple of different general approaches that might be viable for conveying that information to the master, but I'm not well enough versed in Docker to be confident about making specific recommendations. – John Bollinger Mar 18 '19 at 14:40
  • As I've seen there is no solution to "get" the join-token in a dynamic way... – Arya N Mar 20 '19 at 12:02
  • No, @AryaN, no one said that. In fact, I said I think the opposite is probably the case. But I do not myself have sufficient expertise on the Docker side of things to write a decent SO answer to the question. You might have more luck over at the [puppet-users](https://groups.google.com/forum/?nomobile=true#!forum/puppet-users) Google group, where you're more likely to find people well versed in the combination of technologies involved, and where the discussion-style format is more amenable to an incremental back and forth leading toward a solution. – John Bollinger Mar 20 '19 at 13:01
  • Did you find a solution? I am having the same problem! @AryaN – Alejandro Jaramillo Jul 23 '20 at 17:05

0 Answers0