Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(multipass): docker swarm cluster #8

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cluster-multipass/ansible/anisble.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
stdout_callback=yaml
host_key_checking=false
python_interpreter=/usr/bin/python3
inventory=hosts.ini
13 changes: 13 additions & 0 deletions cluster-multipass/ansible/hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[primary]
primary.multipass.mrugesh.net

[manager]
swarm-ldr.multipass.mrugesh.net

[workers]
swarm-wkr01.multipass.mrugesh.net
swarm-wkr02.multipass.mrugesh.net
swarm-wkr03.multipass.mrugesh.net

[all:vars]
ansible_user=ubuntu
Empty file.
23 changes: 23 additions & 0 deletions cluster-multipass/ansible/playbooks/install-traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Deploy Traefik
hosts: manager
gather_facts: false

tasks:
- name: Create network
ansible.builtin.command: docker network create --driver=overlay traefik-public
register: network_created
changed_when: network_created.rc == 0

- name: Get Swarm node ID
ansible.builtin.shell: |
set -e -o pipefail
docker info | grep NodeID | awk '{print $2}'
register: node_id
args:
executable: /bin/bash
changed_when: node_id.rc == 0

- name: Get Swarm node IP
ansible.builtin.debug:
msg: "Swarm node IP: {{ ansible_default_ipv4.address }}, ID: {{ node_id.stdout }}"