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
| provider "google" { | |
| credentials = "${file("${var.credentials}")}" | |
| project = "${var.project}" | |
| region = "${var.region}" | |
| } | |
| resource "google_compute_firewall" "nexus" { | |
| name = "nexus-firewall" | |
| network = "${google_compute_network.nexus.name}" |
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
| resource "google_compute_firewall" "nexus" { | |
| name = "nexus-firewall" | |
| network = "${google_compute_network.nexus.name}" | |
| allow { | |
| protocol = "tcp" | |
| ports = ["22", "8081", "5000"] | |
| } | |
| source_ranges = ["0.0.0.0/0"] |
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
| resource "google_compute_firewall" "swarm" { | |
| name = "swarm-firewall" | |
| network = "${google_compute_network.swarm.name}" | |
| allow { | |
| protocol = "icmp" | |
| } | |
| allow { | |
| protocol = "tcp" |
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
| docker service create --name=visualizer --publish=8080:8080/tcp \ | |
| --constraint=node.role==manager --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ | |
| dockersamples/visualizer |
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
| --- | |
| - name: Install Python | |
| hosts: managers:workers | |
| gather_facts: False | |
| roles: | |
| - python | |
| - name: Init Swarm cluster | |
| hosts: managers | |
| gather_facts: False |
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
| [managers] | |
| ${managers} | |
| [workers] | |
| ${workers} |
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
| data "template_file" "inventory" { | |
| template = "${file("templates/inventory.tpl")}" | |
| depends_on = [ | |
| "google_compute_instance.managers", | |
| "google_compute_instance.workers", | |
| ] | |
| vars { | |
| managers = "${join("\n", google_compute_instance.managers.*.network_interface.0.access_config.0.nat_ip)}" |
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
| resource "google_compute_firewall" "swarm" { | |
| name = "swarm-firewall" | |
| network = "${google_compute_network.swarm.name}" | |
| allow { | |
| protocol = "icmp" | |
| } | |
| allow { | |
| protocol = "tcp" |
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
| resource "google_compute_instance" "workers" { | |
| count = "${var.swarm_workers}" | |
| name = "worker${count.index + 1}" | |
| machine_type = "${var.swarm_workers_instance_type}" | |
| zone = "${var.zone}" | |
| depends_on = ["google_compute_instance.managers"] | |
| boot_disk { | |
| initialize_params { |
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
| resource "google_compute_instance" "managers" { | |
| count = "${var.swarm_managers}" | |
| name = "manager" | |
| machine_type = "${var.swarm_managers_instance_type}" | |
| zone = "${var.zone}" | |
| boot_disk { | |
| initialize_params { | |
| image = "${var.image_name}" | |
| size = 100 |