Skip to content

Commit

Permalink
hosts/jenkins-controller: give jenkins state
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Klink <[email protected]>
  • Loading branch information
flokli committed Dec 7, 2023
1 parent 49ff513 commit dec4d7a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hosts/jenkins-controller/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
self.nixosModules.service-openssh
];

services.jenkins = {
enable = true;
listenAddress = "localhost";
port = 8080;
withCLI = true;
};

# set StateDirectory=jenkins, so state volume has the right permissions
# https://github.com/NixOS/nixpkgs/pull/272679
systemd.services.jenkins.serviceConfig.StateDirectory = "jenkins";

# TODO: deploy reverse proxy, sort out authentication (SSO?)

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

system.stateVersion = "23.05";
Expand Down
36 changes: 36 additions & 0 deletions terraform/jenkins/jenkins_controller.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ module "jenkins_controller_vm" {
ssh_authorized_keys = local.ssh_keys[user]
}
]
# mount /dev/disk/by-lun/10 to /var/lib/jenkins
disk_setup = {
"/dev/disk/by-lun/10" = {
layout = false # don't partition
timeout = 60 # wait for device to appear
}
}
fs_setup = [
{
filesystem = "ext4"
partition = "auto"
device = "/dev/disk/by-lun/10"
label = "jenkins"
}
]
mounts = [
["/dev/disk/by-label/jenkins", "/var/lib/jenkins"]
]
})])

subnet_id = azurerm_subnet.jenkins.id
Expand Down Expand Up @@ -64,3 +82,21 @@ resource "azurerm_network_security_group" "jenkins_controller_vm" {
destination_address_prefix = "*"
}
}

# Create a data disk
resource "azurerm_managed_disk" "jenkins_controller_jenkins_state" {
name = "jenkins-controller-vm-jenkins-state"
resource_group_name = azurerm_resource_group.default.name
location = azurerm_resource_group.default.location
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = 10
}

# Attach to the VM
resource "azurerm_virtual_machine_data_disk_attachment" "jenkins_controller_vm_jenkins_state" {
managed_disk_id = azurerm_managed_disk.jenkins_controller_jenkins_state.id
virtual_machine_id = module.jenkins_controller_vm.virtual_machine_id
lun = "10"
caching = "None"
}

0 comments on commit dec4d7a

Please sign in to comment.