add two nixos-managed VMs for docker swarm
change docker swarm ansible to target these vms
This commit is contained in:
parent
c461ab5e49
commit
17f110b183
4 changed files with 84 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
||||||
[defaults]
|
[defaults]
|
||||||
roles_path=../../../ansible_roles:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles
|
roles_path=../../../ansible_roles:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles
|
||||||
inventory=inventory
|
inventory=inventory
|
||||||
interpreter_python=/usr/bin/python3
|
interpreter_python=/run/current-system/sw/bin/python3.11
|
||||||
remote_user = root
|
remote_user = root
|
||||||
vault_password_file=$HOME/.config/home/ansible-vault-secret
|
vault_password_file=$HOME/.config/home/ansible-vault-secret
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
all:
|
all:
|
||||||
hosts:
|
hosts:
|
||||||
manager:
|
manager:
|
||||||
ansible_host: maestro.dmz
|
ansible_host: 192.168.30.42
|
||||||
children:
|
children:
|
||||||
workers:
|
workers:
|
||||||
hosts:
|
hosts:
|
||||||
bancomart:
|
bancomart:
|
||||||
ansible_host: bancomart.dmz
|
ansible_host: bancomart2.dmz
|
||||||
# vpay:
|
|
||||||
# ansible_host: vpay.dmz
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Setup Docker Swarm manager
|
||||||
|
hosts: manager
|
||||||
|
tasks:
|
||||||
|
- name: Create Docker Swarm
|
||||||
|
docker_swarm:
|
||||||
|
|
||||||
|
- name: Get Docker Swarm manager info
|
||||||
|
docker_swarm_info:
|
||||||
|
nodes: yes
|
||||||
|
nodes_filters:
|
||||||
|
name: manager
|
||||||
|
register: swarm_info
|
||||||
|
|
||||||
|
- hosts: workers
|
||||||
|
tasks:
|
||||||
|
- name: Join Docker Swarm
|
||||||
|
docker_swarm:
|
||||||
|
state: join
|
||||||
|
join_token: "{{ hostvars.manager.swarm_info.swarm_facts.JoinTokens.Worker }}"
|
||||||
|
remote_addrs:
|
||||||
|
- "{{ hostvars.manager.ansible_default_ipv4.address }}"
|
|
@ -58,20 +58,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
my-microvm = {
|
|
||||||
type = "virtual";
|
|
||||||
hypervisorName = "lewis";
|
|
||||||
|
|
||||||
nixosModule = { pkgs, ... }: {
|
|
||||||
# TODO: would be cool to create a check that a mac address is only ever assigned to one VM.
|
|
||||||
lab.vm.id = 0;
|
|
||||||
|
|
||||||
programs.bash.interactiveShellInit = ''
|
|
||||||
echo "Hello world from inside a virtual machine!!" | ${pkgs.lolcat}/bin/lolcat
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
hermes = {
|
hermes = {
|
||||||
type = "virtual";
|
type = "virtual";
|
||||||
hypervisorName = "lewis";
|
hypervisorName = "lewis";
|
||||||
|
@ -81,6 +67,7 @@
|
||||||
networking.dmz.services.enable = true;
|
networking.dmz.services.enable = true;
|
||||||
|
|
||||||
vm = {
|
vm = {
|
||||||
|
# TODO: would be cool to create a check that a mac address is only ever assigned to one VM.
|
||||||
id = 7;
|
id = 7;
|
||||||
staticNetworking = true;
|
staticNetworking = true;
|
||||||
staticIPv4 = config.lab.networking.dmz.ipv4.services;
|
staticIPv4 = config.lab.networking.dmz.ipv4.services;
|
||||||
|
@ -89,4 +76,61 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
maestro2 = {
|
||||||
|
type = "virtual";
|
||||||
|
hypervisorName = "lewis";
|
||||||
|
|
||||||
|
nixosModule = { pkgs, lib, ... }: {
|
||||||
|
lab.vm = {
|
||||||
|
id = 1;
|
||||||
|
staticNetworking = true;
|
||||||
|
staticIPv4 = "192.168.30.42";
|
||||||
|
staticIPv6 = "2a0d:6e00:1a77:30::42";
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
]))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
bancomart2 = {
|
||||||
|
type = "virtual";
|
||||||
|
hypervisorName = "lewis";
|
||||||
|
|
||||||
|
nixosModule = { pkgs, lib, ... }: {
|
||||||
|
lab.vm.id = 2;
|
||||||
|
|
||||||
|
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
|
||||||
|
]))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue