Skip to content

Commit 3006cc7

Browse files
authored
Merge pull request #79 from oli-obk/dev-desktop
Add ansible config for dev desktops
2 parents a6c12ae + 0cc3e3c commit 3006cc7

29 files changed

+918
-1
lines changed

ansible/envs/prod/hosts

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ ci-arm-1.infra.rust-lang.org
1313

1414
[playground]
1515
play-1.infra.rust-lang.org
16+
17+
[dev-desktop]
18+
dev-desktop.infra.rust-lang.org

ansible/playbooks/dev-desktop.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
- hosts: dev-desktop
4+
become: yes
5+
become_user: root
6+
7+
roles:
8+
9+
- role: common
10+
papertrail_url: "{{ vars_papertrail_url }}"
11+
collect_metrics_from: "{{ global_collect_metrics_from }}"
12+
sudo_users:
13+
- aidanhs
14+
- simulacrum
15+
- pietro
16+
- oli-obk
17+
18+
- role: dev-desktop

ansible/roles/common/defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ sudo_users: []
66
collect_metrics_from: []
77
avoid_removing_docker_users: []
88
papertrail_url: null
9+
allow_ssh_extra_groups: ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDIU/eDOjiDgwwXrsKTqUW3/N8DWCgYedNOXF1ZhI5wybi13kX7TMehEDN/tVYVe5f4BP3v7dNNVhvrENe/5ubCKBAVVj/1UkosYo57uRq30zl/pRkthoG8eMVkHCMjfBzAAC0zEPEFrSk1rOsf8BZnnEnG7o+RsGg5rYBOdI+/EM6v7KEF0xKQ2nP5haPcu0D4o+PySa+HW9RyCPHq7aOY3L53XbvvEjaioeSSyrGAD3vFCQyX+N216kr2Riono7pXS1AiBtN45VLBojAvjnsf7xlU/P1kl5RkBz31EjppKjRaKnWtwbedhbXRnetTrlzkfsFc04JkMB1kwuqRz2qccb1EigZ3D3GX1d150ZmUrrSwBo5UdcntdWCw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+e8/4O5lBG88y0lVtLi7HvVMK9QjzAlr7mU6o0iEjpeS1VFcTKjI8nxBpJQ1+URr31V52VzZ1yx2Rd2DxLoL2/+smFb3JwGJaAviPgL2BLjz444obX5rWNViFIp7OICLRWWXBxNdPrq7Ayiwubl3WA59PenjytKldaRY8eGLmDjAJvUM/xWcq0Fnep/+g5y7tou3MXO9a9+8EmcApB8OY7+dYNH8LSU26Erd6kx/qZgPD7omqTq3eNHavbW5HaWXhCwbJ38dqWgkocKWWVUjBHwdd5V5/tYIFuqam49QOyGKoJ2hDVt6xwDGYcUPIG3qAi6VfMGTF1C71BKq6aCRuthxs8owy4/LMea+O6XyLBJXUSk0DX7orPzamgVzbzfpEVGqdHb/gGqk2BmG86aWrmkV9vuIvDAJMpsI5ajdTaSYiCOXE=

ansible/roles/common/templates/ssh/sshd_config

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ AcceptEnv LANG LC_*
3434

3535
Subsystem sftp /usr/lib/openssh/sftp-server
3636

37-
AllowGroups allow-ssh
37+
AllowGroups allow-ssh {{ allow_ssh_extra_groups }}
3838

3939
{# The `Include` directive is not supported on older Ubuntu versions #}
4040
{% if ansible_distribution_release not in ["xenial", "bionic"] %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
vars_team_login_path: "/root/team_login"
4+
allow_ssh_extra_groups: "dev-desktop-allow-ssh"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import requests
2+
import os
3+
4+
from github import Github
5+
from pprint import pprint
6+
7+
from sys import argv
8+
9+
from datetime import datetime, timedelta, timezone
10+
11+
from github import GithubIntegration
12+
13+
real_path = os.path.realpath(__file__)
14+
dir_path = os.path.dirname(real_path)
15+
16+
17+
def token(user, repo):
18+
with open(os.path.join(dir_path, 'app_id.txt'), 'r') as fh:
19+
app_id = int(fh.read())
20+
21+
with open(os.path.join(dir_path, 'dev-desktop.private-key.pem'), 'rb') as fh:
22+
private_key = fh.read()
23+
24+
integration = GithubIntegration(app_id, private_key)
25+
26+
installation = integration.get_installation(user, repo)
27+
28+
auth = integration.get_access_token(installation.id)
29+
30+
return auth.token
31+
32+
33+
if __name__ == '__main__':
34+
# executed as script, fetch args and dump result on command line
35+
36+
if len(argv) < 2:
37+
print("usage: <github_username> <github_repo_name>")
38+
39+
print(token(argv[1], argv[2]))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/python
2+
3+
from sys import argv, stdin
4+
import os
5+
6+
if argv[1] != "get":
7+
exit(0)
8+
9+
config = [x.strip() for x in stdin]
10+
11+
if config[1] != "host=github.com":
12+
exit(0)
13+
14+
path = config[2].split('=')
15+
path = path[1].split('/')
16+
17+
# Get the username of the caller, not the owner of
18+
# this script (which is setuid)
19+
user = os.getlogin()
20+
if user.starts_with("gh-"):
21+
user = user[3:]
22+
23+
# we don't support usernames differing from repo owner names for now
24+
if user != path[0]:
25+
exit(0)
26+
repo = path[1].rsplit('.', 1)[0]
27+
28+
real_path = os.path.realpath(__file__)
29+
dir_path = os.path.dirname(real_path)
30+
31+
from dump import token
32+
33+
for config in config:
34+
print(config)
35+
36+
print(f"username={user}")
37+
38+
print(f"password={token(user, repo)}")
39+
print()
40+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
rm -rf rust*/build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
for d in rust*
4+
do
5+
cd $d
6+
echo $d
7+
# if the fast forward is successful, this branch is merged, so we can kill it
8+
git pull upstream master --ff-only && git checkout --detach && git submodule update --init --recursive
9+
cd ..
10+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
echo "# Available scripts for managing your Rust checkouts"
4+
echo "init.sh | first time setup, you should only have to execute this once on a new machine"
5+
echo "status.sh | list the branches and git status of all copies of the Rust repo"
6+
echo "new_worktree.sh | creates a worktree (shallow copy of the main git checkout of Rust, sharing the .git folder)"
7+
echo "detach_merged_prs.sh | invokes \"git pull --fast-forward-only\" on all worktrees and detaches those that are equal to the \"master\" branch"
8+
echo ""
9+
echo "# Rarer commands:"
10+
echo "set_defaults.sh | connects the global config.toml with all worktrees. Use this when your setup is broken"
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
username=`id -u -n`
4+
gh_name=${username#"gh-"}
5+
6+
# Using https instead of git urls because vscode only handles login on push/pull
7+
git clone https://github.com/$gh_name/rust.git
8+
pushd rust
9+
git remote add upstream https://github.com/rust-lang/rust.git
10+
git fetch upstream
11+
git checkout upstream/master
12+
popd
13+
14+
./setup_rustup.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
N=$(ls | grep -E -e "rust[0-9]+" | wc -l)
6+
echo $N
7+
pushd rust
8+
git worktree add --detach ../rust$N
9+
popd
10+
pushd rust$N
11+
git fetch upstream
12+
git checkout upstream/master
13+
ln -s ../config.toml
14+
popd
15+
16+
./setup_rustup.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
for D in rust*; do
4+
if [ -d "${D}" ]; then
5+
pushd $D
6+
ln -s ../config.toml
7+
popd
8+
fi
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
rustup --version || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6+
7+
for D in rust*; do
8+
if [ -d "${D}" ]; then
9+
rustup toolchain link "$D"_stage1 "$D/build/x86_64-unknown-linux-gnu/stage1"
10+
rustup toolchain link "$D"_stage2 "$D/build/x86_64-unknown-linux-gnu/stage2"
11+
fi
12+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
for d in rust*
4+
do
5+
cd $d
6+
echo $d
7+
git status --short --branch --untracked-files=no --ignore-submodules --no-ahead-behind --no-renames
8+
cd ..
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
changelog-seen = 2
2+
3+
# Change this to the profile of your choice
4+
profile = "compiler"
5+
6+
[rust]
7+
# Build with debug assertions so we get useful RUSTC_LOG
8+
# and notice debug assertions failing.
9+
debug = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

0 commit comments

Comments
 (0)