-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from ehh-why-its-so-hard/implement_lb
feat: add jenkins role
- Loading branch information
Showing
6 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Install Required packages | ||
ansible.builtin.apt: | ||
name: | ||
- openjdk-17-jdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
jenkins_master_version: '2.452.4' | ||
|
||
jenkins_master_with_zfs: false | ||
jenkins_master_zfs_device: /dev/sdb |
5 changes: 5 additions & 0 deletions
5
roles/jenkins_master/files/etc/systemd/system/jenkins.service.d/override.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[Service] | ||
Environment="JAVA_OPTS=-Djava.awt.headless=true -Xms6144m -Xmx6144m" | ||
Environment="JENKINS_OPTS=--sessionTimeout=10080 --sessionEviction=259200" | ||
Environment="JENKINS_HOME=/home/jenkins" | ||
TimeoutSec=900 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: "Reload systemd config" | ||
ansible.builtin.systemd: | ||
daemon_reload: "yes" | ||
|
||
- name: "Restart jenkins" | ||
ansible.builtin.systemd: | ||
name: jenkins | ||
enabled: true | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
- name: Setup ZFS | ||
ansible.builtin.import_tasks: zfs.yaml | ||
when: jenkins_master_with_zfs | ||
|
||
- name: Ensure jenkins home exists | ||
ansible.builtin.file: | ||
path: "{{- item -}}" | ||
state: directory | ||
mode: '0755' | ||
owner: jenkins | ||
group: jenkins | ||
with_items: | ||
- /home/jenkins | ||
- /home/jenkins/jobs | ||
|
||
- name: Add an Apt signing key for Jenkins apt repo | ||
ansible.builtin.apt_key: | ||
url: https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | ||
state: present | ||
|
||
- name: Add Jenkins apt repo into sources list | ||
ansible.builtin.apt_repository: | ||
repo: deb https://pkg.jenkins.io/debian-stable binary/ | ||
state: present | ||
update_cache: "yes" | ||
filename: jenkins | ||
|
||
- name: Install Required packages | ||
ansible.builtin.apt: | ||
name: | ||
- openjdk-17-jdk | ||
|
||
- name: Install Jenkins | ||
ansible.builtin.apt: | ||
name: | ||
- "jenkins={{ jenkins_master_version }}" | ||
notify: | ||
- "Reload systemd config" | ||
- "Restart jenkins" | ||
|
||
|
||
- name: Create a directory if it does not exist | ||
ansible.builtin.file: | ||
path: /etc/systemd/system/jenkins.service.d/ | ||
state: directory | ||
mode: '0755' | ||
|
||
|
||
- name: Copy jenkins.service.d config | ||
ansible.builtin.copy: | ||
src: 'etc/systemd/system/jenkins.service.d/override.conf' | ||
dest: '/etc/systemd/system/jenkins.service.d/override.conf' | ||
owner: 'root' | ||
group: 'root' | ||
mode: "0644" | ||
notify: | ||
- "Reload systemd config" | ||
- "Restart jenkins" | ||
|
||
- name: Restart jenkins periodically | ||
become: true | ||
ansible.builtin.cron: | ||
name: "restart jenkins" | ||
minute: "0" | ||
hour: "5" # 5AM UTC | ||
weekday: "1" # monday | ||
user: root | ||
job: "/usr/bin/systemctl restart jenkins.service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
- name: Create pool | ||
ansible.builtin.shell: | | ||
set -o pipefail | ||
zpool create -f -o ashift=12 "jenkins_pool" "{{- jenkins_master_zfs_device -}}"; | ||
zfs set atime=off "jenkins_pool"; | ||
zfs set compression=zstd "jenkins_pool"; | ||
# enable improved extended attributes - keep in inode instead of dir; | ||
zfs set xattr=sa "jenkins_pool"; | ||
# reduce amount of metadata (may improve random writes); | ||
zfs set redundant_metadata=most "jenkins_pool"; | ||
touch "/.zfs_pool" | ||
args: | ||
executable: /bin/bash | ||
creates: "/.zfs_pool" | ||
|
||
- name: Create dataset | ||
ansible.builtin.shell: | | ||
set -o pipefail | ||
mkdir -p "{{- item.mount_point -}}"; | ||
zfs create "{{- item.dataset_name -}}"; | ||
zfs set atime=off "{{- item.dataset_name -}}"; | ||
zfs set compression=zstd "{{- item.dataset_name -}}"; | ||
# enable improved extended attributes - keep in inode instead of dir; | ||
zfs set xattr=sa "{{- item.dataset_name -}}"; | ||
# reduce amount of metadata (may improve random writes); | ||
zfs set redundant_metadata=most "{{- item.dataset_name -}}"; | ||
zfs set mountpoint="{{- item.mount_point -}}" "{{- item.dataset_name -}}"; | ||
touch "{{- item.mount_point -}}/.zfs_pool" | ||
args: | ||
executable: /bin/bash | ||
creates: "{{- item.mount_point -}}/.zfs_pool" | ||
with_items: | ||
- dataset_name: "jenkins_pool/home" | ||
mount_point: "/home/jenkins" | ||
- dataset_name: "jenkins_pool/home/jobs" | ||
mount_point: "jenkins_pool/home/jobs" |