Skip to content

Commit

Permalink
ramdisk buildbot worker draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Akira25 committed Oct 16, 2024
1 parent 6d2bc93 commit 26ffb34
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 24 deletions.
14 changes: 0 additions & 14 deletions inventory/host_vars/buildbot-worker-scherer8/main.yml

This file was deleted.

8 changes: 5 additions & 3 deletions inventory/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ buildbot-worker-01 ansible_host=85.215.202.123
buildbot-worker-02 ansible_host=85.215.248.194
buildbot-worker-03 ansible_host=85.215.225.21
buildbot-worker-04 ansible_host=85.215.162.88
buildbot-worker-akira ansible_host=192.168.16.7 # only from within martins home...
buildbot-worker-scherer8 ansible_host=scherer8-buildbot.olsr # only from within freifunk-net use a jump-host or so...
buildbot.berlin.freifunk.net # the buildbot master runs additionally the master-worker. Thus having the worker-role too.
buildbot-worker-akira ansible_host=192.168.16.7 # only from within martins home...
buildbot-worker-scherer8-1 ansible_host[email protected] # only from within freifunk-net use a jump-host or so...
buildbot-worker-scherer8-2 ansible_host[email protected] # only from within freifunk-net use a jump-host or so...
buildbot.berlin.freifunk.net # the buildbot master runs additionally the master-worker. Thus having the worker-role too.


[tunneldigger]
b.tunnel.berlin.freifunk.net # freifunk-gw01
Expand Down
1 change: 1 addition & 0 deletions roles/buildbot_worker/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ bbworker_info: Worker administered by ffb-ansible-repo
machine_user: bbworker

# gets overridden on hosts, that use a ramdisk
bbworker_ramdisk: no
bbworker_path: /home/{{ machine_user }}/{{ bbworker_dir }}
7 changes: 7 additions & 0 deletions roles/buildbot_worker/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
- name: Initialise buildbot-worker
command: "{{ bbworker_path }}/env/bin/buildbot-worker create-worker --umask=0o22 {{ bbworker_path }} {{ bbmaster_fqdn }}:{{ bbmaster_port }} {{ bbworker_name }} {{ bbworker_pwd }}"
become_user: "{{ machine_user }}"

- name: Restart podman
systemd:
daemon_reload: true
name: podman
enabled: true
state: restarted
78 changes: 71 additions & 7 deletions roles/buildbot_worker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- rsync
- time
- podman
- dbus-x11
state: present
update_cache: true
cache_valid_time: 3600
Expand All @@ -16,6 +17,66 @@
user:
name: "{{ machine_user }}"

- name: Create mountpoint for ramdisk
ansible.builtin.file:
path: /ramdisk/
state: directory
mode: '0755'
owner: "{{ machine_user }}"
group: "{{ machine_user }}"
when: bbworker_ramdisk

- name: Create ramdisk mount and persist
ansible.posix.mount:
path: /ramdisk/
src: tmpfs
fstype: tmpfs
opts: "size={{ bbworker_ramdisk_size }}"
state: present
boot: yes
when: bbworker_ramdisk
become: true

- name: Create bbworker_path
ansible.builtin.file:
path: "{{ bbworker_path }}"
state: directory
mode: '0755'
owner: "{{ machine_user }}"
group: "{{ machine_user }}"

- name: Create path for custom podman storage config
ansible.builtin.file:
path: "/home/{{ machine_user }}/.config/containers/"
state: directory
mode: '0755'
owner: "{{ machine_user }}"
group: "{{ machine_user }}"
when: bbworker_ramdisk

- name: Custom podman storage config
ansible.builtin.copy:
dest: "/home/{{ machine_user }}/.config/containers/storage.conf"
mode: '0644'
content: |
[storage]
driver = "overlay"
runroot = "{{ bbworker_path }}/run/user/$UID/run"
graphroot = "{{ bbworker_path }}/.local/share/containers/storage/"
owner: "{{ machine_user }}"
group: "{{ machine_user }}"
when: bbworker_ramdisk
notify: Restart podman

- name: Add buildbot-worker systemd-service-module
ansible.builtin.template:
dest: /etc/systemd/system/buildbot-worker.service
src: systemd-unit.j2
mode: "0644"
owner: root
group: root
notify: Restart buildbot-worker

- name: Install buildbot-worker
pip:
name: buildbot-worker
Expand Down Expand Up @@ -57,12 +118,15 @@
group: "{{ machine_user }}"
recurse: true
notify: Restart buildbot-worker
when: not bbworker_ramdisk

- name: Add buildbot-worker systemd-service-module
template:
dest: /etc/systemd/system/buildbot-worker.service
src: systemd-unit.j2
mode: "0644"
owner: root
group: root
- name: Adjust permissions on buildbot-worker description
ansible.builtin.file:
path: "{{ bbworker_path }}"
state: directory
# needs to be this high. Otherwise service will not start.
mode: "0755"
owner: "{{ machine_user }}"
group: "{{ machine_user }}"
notify: Restart buildbot-worker
when: bbworker_ramdisk
8 changes: 8 additions & 0 deletions roles/buildbot_worker/templates/systemd-unit.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ After=network.target
User=bbworker
Group=bbworker
WorkingDirectory={{ bbworker_path }}
{% if bbworker_ramdisk %}
# recreates the worker after a reboot
ExecStartPre=mkdir -p "{{ bbworker_path }}"
virtualenv "{{ bbworker_path }}env"
pip install buildbot-worker=={{ buildbot_version }}
source "{{ bbworker_path }}env/bin/activate"
{{ bbworker_path }}/env/bin/buildbot-worker create-worker --umask=0o22 {{ bbworker_path }} {{ bbmaster_fqdn }}:{{ bbmaster_port }} {{ bbworker_name }} {{ bbworker_pwd }}
{% endif %}
ExecStart={{ bbworker_path }}/env/bin/buildbot-worker start --nodaemon

[Install]
Expand Down

0 comments on commit 26ffb34

Please sign in to comment.