mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
generic-worker on macOS: run as unprivileged user, start as a service
This commit is contained in:
parent
889d479935
commit
70f507879f
8 changed files with 115 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
||||||
# macOS
|
# macOS
|
||||||
|
|
||||||
Servo’s macOS workers for Taskcluster are configured with
|
This is the configuration for the `proj-servo/macos` worker type.
|
||||||
SaltStack in [agentless] mode.
|
These macOS workers are configured with SaltStack in [agentless] mode.
|
||||||
|
|
||||||
[agentless]: https://docs.saltstack.com/en/getstarted/ssh/index.html
|
[agentless]: https://docs.saltstack.com/en/getstarted/ssh/index.html
|
||||||
|
|
||||||
|
@ -15,6 +15,25 @@ cd etc/taskcluster/macos
|
||||||
./salt-ssh '*' state.apply test=True
|
./salt-ssh '*' state.apply test=True
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Servers
|
||||||
|
|
||||||
|
Servers are provisioned manually from MacStadium.
|
||||||
|
The `config/roster` file lists them by DNS name.
|
||||||
|
|
||||||
|
|
||||||
|
## Taskcluster secrets
|
||||||
|
|
||||||
|
This SaltStack configuration has a custom module that uses Taskcluster’s
|
||||||
|
[secrets service](https://tools.taskcluster.net/secrets/).
|
||||||
|
These secrets include an [authentication token](
|
||||||
|
You’ll need to authenticate with a Taskcluster client ID
|
||||||
|
that has scope `secrets:get:project/servo/*`.
|
||||||
|
This should be the case if you’re a Servo project administrator (the `project-admin:servo` role).
|
||||||
|
|
||||||
|
|
||||||
## Worker’s client ID
|
## Worker’s client ID
|
||||||
|
|
||||||
`project/servo/worker/macos/1`
|
Workers are configured to authenticate with client ID
|
||||||
|
[`project/servo/worker/macos/1`](
|
||||||
|
https://tools.taskcluster.net/auth/clients/project%2Fservo%2Fworker%macos%2F1).
|
||||||
|
This client has the scopes required to run tasks for this worker type.
|
|
@ -2,3 +2,6 @@ root_dir: .salt
|
||||||
file_roots:
|
file_roots:
|
||||||
base:
|
base:
|
||||||
- states
|
- states
|
||||||
|
extension_modules: ../modules
|
||||||
|
ext_pillar:
|
||||||
|
- taskcluster_secrets:
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
mac1:
|
mac1:
|
||||||
host: servo-tc-mac1.servo.org
|
host: servo-tc-mac1.servo.org
|
||||||
|
|
||||||
|
# https://github.com/saltstack/salt/issues/50477
|
||||||
|
minion_opts:
|
||||||
|
providers:
|
||||||
|
user: mac_user
|
||||||
|
|
16
etc/taskcluster/macos/modules/pillar/taskcluster_secrets.py
Normal file
16
etc/taskcluster/macos/modules/pillar/taskcluster_secrets.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "packet.net"))
|
||||||
|
import tc
|
||||||
|
|
||||||
|
|
||||||
|
def ext_pillar(_minion_id, _pillar, *_args):
|
||||||
|
tc.check()
|
||||||
|
data = {}
|
||||||
|
data.update(tc.secret("project/servo/tc-client/worker/macos/1"))
|
||||||
|
data.update(tc.secret("project/servo/livelog-secret/1"))
|
||||||
|
return data
|
|
@ -1,5 +1,6 @@
|
||||||
{% set bin = "/usr/local/bin" %}
|
{% set bin = "/usr/local/bin" %}
|
||||||
{% set keyfile = "/etc/generic-worker/key" %}
|
{% set user = "worker" %}
|
||||||
|
{% set home = "/Users/" + user %}
|
||||||
|
|
||||||
{{ bin }}/generic-worker:
|
{{ bin }}/generic-worker:
|
||||||
file.managed:
|
file.managed:
|
||||||
|
@ -16,21 +17,76 @@
|
||||||
- mode: 755
|
- mode: 755
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
/etc/generic-worker/config.json:
|
{{ user }}:
|
||||||
|
user.present:
|
||||||
|
- home: {{ home }}
|
||||||
|
|
||||||
|
# `user.present`’s `createhome` is apparently not supported on macOS
|
||||||
|
{{ home }}:
|
||||||
|
file.directory:
|
||||||
|
- user: {{ user }}
|
||||||
|
|
||||||
|
{{ home }}/config.json:
|
||||||
file.serialize:
|
file.serialize:
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
- user: {{ user }}
|
||||||
- mode: 600
|
- mode: 600
|
||||||
- show_changes: False
|
- show_changes: False
|
||||||
- formatter: json
|
- formatter: json
|
||||||
- dataset:
|
- dataset:
|
||||||
provisionerId: proj-servo
|
provisionerId: proj-servo
|
||||||
workerType: macos
|
workerType: macos
|
||||||
workerId: servo-macos-1
|
workerGroup: servo-macos
|
||||||
clientId: project/servo/worker/macos/1
|
workerId: mac1
|
||||||
|
tasksDir: {{ home }}/tasks
|
||||||
publicIP: {{ salt.network.ip_addrs()[0] }}
|
publicIP: {{ salt.network.ip_addrs()[0] }}
|
||||||
signingKeyLocation: {{ keyfile }}
|
signingKeyLocation: {{ home }}/key
|
||||||
|
clientId: {{ pillar["client_id"] }}
|
||||||
|
accessToken: {{ pillar["access_token"] }}
|
||||||
|
livelogSecret: {{ pillar["livelog_secret"] }}
|
||||||
|
|
||||||
generic-worker new-openpgp-keypair --file {{ keyfile }}:
|
{{ bin }}/generic-worker new-openpgp-keypair --file {{ home }}/key:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- creates: {{ keyfile }}
|
- creates: {{ home }}/key
|
||||||
- prepend_path: {{ bin }}
|
- runas: worker
|
||||||
|
|
||||||
|
/Library/LaunchAgents/net.generic.worker.plist:
|
||||||
|
file.managed:
|
||||||
|
- mode: 644
|
||||||
|
- template: jinja
|
||||||
|
- contents: >-
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>net.generic.worker</string>
|
||||||
|
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>{{ bin }}/generic-worker</string>
|
||||||
|
<string>run</string>
|
||||||
|
<string>--config</string>
|
||||||
|
<string>config.json</string>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<true/>
|
||||||
|
|
||||||
|
<key>WorkingDirectory</key>
|
||||||
|
<string>{{ home }}</string>
|
||||||
|
|
||||||
|
<key>UserName</key>
|
||||||
|
<string>{{ user }}</string>
|
||||||
|
|
||||||
|
<key>StandardOutPath</key>
|
||||||
|
<string>stdout.log</string>
|
||||||
|
|
||||||
|
<key>StandardErrorPath</key>
|
||||||
|
<string>stderr.log</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
||||||
|
net.generic.worker:
|
||||||
|
service.running:
|
||||||
|
- enable: True
|
||||||
|
|
|
@ -39,7 +39,7 @@ This should be the case if you’re a Servo project administrator (the `project-
|
||||||
## Worker’s client ID
|
## Worker’s client ID
|
||||||
|
|
||||||
Workers are configured to authenticate with client ID
|
Workers are configured to authenticate with client ID
|
||||||
[project/servo/worker/docker-worker-kvm/1](
|
[`project/servo/worker/docker-worker-kvm/1`](
|
||||||
https://tools.taskcluster.net/auth/clients/project%2Fservo%2Fworker%2Fdocker-worker-kvm%2F1).
|
https://tools.taskcluster.net/auth/clients/project%2Fservo%2Fworker%2Fdocker-worker-kvm%2F1).
|
||||||
This client has the scopes required to run docker-worker
|
This client has the scopes required to run docker-worker
|
||||||
as well as for tasks that we run on this worker type.
|
as well as for tasks that we run on this worker type.
|
Loading…
Add table
Add a link
Reference in a new issue