create shadow docker swarm
This commit is contained in:
parent
701cc85327
commit
ab8ae06040
3 changed files with 50 additions and 13 deletions
|
@ -1,9 +1,11 @@
|
|||
all:
|
||||
hosts:
|
||||
manager:
|
||||
primary:
|
||||
ansible_host: 192.168.30.42
|
||||
children:
|
||||
workers:
|
||||
secondaries:
|
||||
hosts:
|
||||
bancomart:
|
||||
ansible_host: bancomart2.dmz
|
||||
vpay:
|
||||
ansible_host: vpay2.dmz
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
---
|
||||
|
||||
- name: Setup Docker Swarm manager
|
||||
hosts: manager
|
||||
- name: Setup Docker Swarm primary
|
||||
hosts: primary
|
||||
tasks:
|
||||
- name: Create Docker Swarm
|
||||
docker_swarm:
|
||||
|
||||
- name: Get Docker Swarm manager info
|
||||
- name: Get Docker Swarm primary info
|
||||
docker_swarm_info:
|
||||
nodes: yes
|
||||
nodes_filters:
|
||||
name: manager
|
||||
name: primary
|
||||
register: swarm_info
|
||||
|
||||
- hosts: workers
|
||||
- hosts: secondaries
|
||||
tasks:
|
||||
- name: Join Docker Swarm
|
||||
docker_swarm:
|
||||
state: join
|
||||
join_token: "{{ hostvars.manager.swarm_info.swarm_facts.JoinTokens.Worker }}"
|
||||
join_token: "{{ hostvars.primary.swarm_info.swarm_facts.JoinTokens.Manager }}"
|
||||
remote_addrs:
|
||||
- "{{ hostvars.manager.ansible_default_ipv4.address }}"
|
||||
- "{{ hostvars.primary.ansible_default_ipv4.address }}"
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
# TODO: make leases persistent!
|
||||
hermes = {
|
||||
type = "virtual";
|
||||
hypervisorName = "lewis";
|
||||
|
@ -79,7 +80,7 @@
|
|||
|
||||
maestro2 = {
|
||||
type = "virtual";
|
||||
hypervisorName = "lewis";
|
||||
hypervisorName = "atlas";
|
||||
|
||||
nixosModule = { pkgs, lib, config, ... }: {
|
||||
lab.vm = {
|
||||
|
@ -90,7 +91,7 @@
|
|||
};
|
||||
|
||||
microvm.shares = [{
|
||||
source = "/var/lib/microvms/${config.networking.hostName}/shares/docker_swarm";
|
||||
source = "/data/vm_shares/${config.networking.hostName}/docker_swarm";
|
||||
mountPoint = "/var/lib/docker/swarm";
|
||||
tag = "docker_swarm";
|
||||
proto = "virtiofs";
|
||||
|
@ -118,13 +119,47 @@
|
|||
|
||||
bancomart2 = {
|
||||
type = "virtual";
|
||||
hypervisorName = "lewis";
|
||||
hypervisorName = "jefke";
|
||||
|
||||
nixosModule = { pkgs, lib, config, ... }: {
|
||||
lab.vm.id = 2;
|
||||
|
||||
microvm.shares = [{
|
||||
source = "/var/lib/microvms/${config.networking.hostName}/shares/docker_swarm";
|
||||
source = "/data/vm_shares/${config.networking.hostName}/docker_swarm";
|
||||
mountPoint = "/var/lib/docker/swarm";
|
||||
tag = "docker_swarm";
|
||||
proto = "virtiofs";
|
||||
socket = "docker_swarm.sock";
|
||||
}];
|
||||
|
||||
networking = {
|
||||
nftables.enable = lib.mkForce false;
|
||||
firewall.enable = lib.mkForce false;
|
||||
};
|
||||
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
liveRestore = false;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
(python311.withPackages (python-pkgs: [
|
||||
python-pkgs.docker
|
||||
python-pkgs.requests
|
||||
]))
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
vpay2 = {
|
||||
type = "virtual";
|
||||
hypervisorName = "lewis";
|
||||
|
||||
nixosModule = { pkgs, lib, config, ... }: {
|
||||
lab.vm.id = 3;
|
||||
|
||||
microvm.shares = [{
|
||||
source = "/data/vm_shares/${config.networking.hostName}/docker_swarm";
|
||||
mountPoint = "/var/lib/docker/swarm";
|
||||
tag = "docker_swarm";
|
||||
proto = "virtiofs";
|
||||
|
|
Loading…
Reference in a new issue