Skip to content

Commit

Permalink
ansible: Allow passing tmpfs options
Browse files Browse the repository at this point in the history
Currently, the only option passed to tmpfs is `exec` so tmpfs is mounted
with "exec" option.
We may need to pass extra options on some runners, like setting the size
of tmpfs for instance (docker seems to default to 50% of the host
memory), and only on specific hosts, so we need this to be somwhat
configurable.

Add a new variable `runner_tmpfs_options` which defaults to `['exec']`
and can be overridden at the host/group level.

Test, after setting a host to use:
```
        runner_tmpfs_options:
          - exec
          - size=12G
```

running ansible in dry-run mode:
```
--- before: /etc/systemd/system/[email protected]
+++ after:
/home/chantra/.ansible/tmp/ansible-local-3819115bni8m1fy/tmp65ktafym
@@ -15,7 +15,7 @@
             --health-cmd='(ss -ntp -H dport = :443 | grep -q ESTAB) ||
exit 1' \
 --health-start-period=60s --health-interval=30s \
 --health-timeout=5s --health-retries=3 \
-            --tmpfs /tmp/work:exec \
+            --tmpfs /tmp/work:exec,size=12G \
             --rm \
             --env-file
"/etc/actions-runner/actions-runner-kernel-patches-worker-%i.env" \
             --env-file
"/etc/actions-runner/actions-runner-kernel-patches-worker-%i-ghtoken.env"
\

```

And for a hosts with no override, running ansible does not chasnge
anything.

Signed-off-by: Manu Bretelle <[email protected]>
  • Loading branch information
chantra committed Dec 16, 2023
1 parent bdf8643 commit b17e815
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ansible/roles/runner/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ runner_base_dir: /etc/actions-runner
runner_workers: 1
runner_prefix: ""
runner_workdir: /tmp/work
runner_tmpfs_options:
- exec
runner_gh_token_default: replace with your token
runner_gh_user_default: replace with your GH user
runner_docker_tag: main
Expand All @@ -25,4 +27,4 @@ runner_repo_list:
# ---START PEM SECRET---
# ...
# ...
# ---END PEM SECRET---
# ---END PEM SECRET---
2 changes: 1 addition & 1 deletion ansible/roles/runner/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
{% if runner_docker_mount_volume %}
--volume=actions-runner-{{ item.normalized }}-worker-%i:{{ runner_workdir }} \
{% else %}
{{ '--tmpfs %s:exec' | format(runner_workdir) }} \
{{ '--tmpfs %s:%s' | format(runner_workdir, runner_tmpfs_options | join(',')) }} \
{% endif %}
--rm \
--env-file "{{ runner_base_dir }}/actions-runner-{{ item.normalized }}-worker-%i.env" \
Expand Down

0 comments on commit b17e815

Please sign in to comment.