diff --git a/legacy/projects/docker_swarm/ansible/inventory/hosts.yml b/legacy/projects/docker_swarm/ansible/inventory/hosts.yml index 5500f35..6254371 100644 --- a/legacy/projects/docker_swarm/ansible/inventory/hosts.yml +++ b/legacy/projects/docker_swarm/ansible/inventory/hosts.yml @@ -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 diff --git a/legacy/projects/docker_swarm/ansible/playbooks/setup-nixos.yml b/legacy/projects/docker_swarm/ansible/playbooks/setup-nixos.yml index f784c21..fcd02b3 100644 --- a/legacy/projects/docker_swarm/ansible/playbooks/setup-nixos.yml +++ b/legacy/projects/docker_swarm/ansible/playbooks/setup-nixos.yml @@ -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 }}" diff --git a/nixos/machines/default.nix b/nixos/machines/default.nix index 6b85972..00e1851 100644 --- a/nixos/machines/default.nix +++ b/nixos/machines/default.nix @@ -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";