diff --git a/notes/stv/20240228-new-user.txt b/notes/stv/20240228-new-user.txt new file mode 100644 index 00000000..e47cb28f --- /dev/null +++ b/notes/stv/20240228-new-user.txt @@ -0,0 +1,454 @@ +# +# +# +# Copyright (c) 2023, ROE (http://www.roe.ac.uk/) +# +# This information is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This information is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# +# + + + + Target: + + Add new user to GaiaDMP + + Result: + + Work in progress .. + + +# ----------------------------------------------------- + + - name: "JDodd" + type: "live" + linuxuid: 10033 + + +# ----------------------------------------------------- +# Backup the user notebooks. +#[user@desktop] + + source "${HOME:?}/aglais.env" + + gedit "${AGLAIS_CODE}/notes/zrq/20230517-01-backup-notebooks.txt" & + +# ----------------------------------------------------- +# Check the backups. +#[user@desktop] + + ssh fedora@data.gaia-dmp.uk + + .... + + pushd /var/local/backups/notebooks/latest + + du -h -d 2 notebook + + popd + + > + + 4.0K notebook/User/NHambly + 8.0K notebook/User + 3.7M notebook/Users/SBertocco + 4.3M notebook/Users/AKyrieleis + 3.7M notebook/Users/JSwinbank + 3.4M notebook/Users/MVioque + 4.0K notebook/Users/dmorris + 3.4M notebook/Users/MNizovkina + 3.4M notebook/Users/NMiller + 3.4M notebook/Users/GGuil + 3.4M notebook/Users/MLucey + 3.4M notebook/Users/MFouesneau + 3.4M notebook/Users/MBayer + 54M notebook/Users/DCrake + 2.7M notebook/Users/chee2ooW5rieSohv + 3.4M notebook/Users/CWorley + 3.1M notebook/Users/AZijlstra + 3.4M notebook/Users/PKuzma + 3.4M notebook/Users/aeYohngie7iel1ae + 16M notebook/Users/NHambly + 3.6M notebook/Users/SGoughKelly + 3.4M notebook/Users/DHDarrington + 4.2M notebook/Users/SVoutsinas + 3.4M notebook/Users/SHodgkin + 3.4M notebook/Users/SSagear + 3.4M notebook/Users/GBusso + 3.0M notebook/Users/MSemczuk + 3.5M notebook/Users/Reyesfan + 3.4M notebook/Users/WCooper + 3.7M notebook/Users/GHughes + 3.5M notebook/Users/HHeinl + 3.5M notebook/Users/NWalton + 3.5M notebook/Users/Oor7cheitoiz8Fie + 3.4M notebook/Users/BRoulston + 3.4M notebook/Users/ZWay + 3.7M notebook/Users/FLykou + 3.4M notebook/Users/AKrause + 4.3M notebook/Users/DMorris + 182M notebook/Users + 13M notebook/.git/objects + 16K notebook/.git/refs + 4.0K notebook/.git/branches + 36K notebook/.git/logs + 4.0K notebook/.git/hooks + 13M notebook/.git + 3.0M notebook/tmp + 197M notebook + + +# ----------------------------------------------------- +# Merge upstream changes. +#[user@desktop] + + source "${HOME:?}/aglais.env" + pushd "${AGLAIS_CODE}" + + git checkout master + + git pull + + git fetch upstream + + git merge upstream/master + + git status + + git push + + popd + + +# ----------------------------------------------------- +# Start a new branch. +#[user@desktop] + + branchname=new-users + + source "${HOME:?}/aglais.env" + pushd "${AGLAIS_CODE}" + + newbranch=$(date '+%Y%m%d')-zrq-${branchname:?} + + git checkout master + + git checkout -b "${newbranch:?}" + + git push --set-upstream 'origin' "$(git branch --show-current)" + + popd + + +# ----------------------------------------------------- +# Add the new users to the live users list. +#[user@desktop] + + source "${HOME:?}/aglais.env" + pushd "${AGLAIS_CODE}" + + pushd deployments/common/users + + gedit live-users.yml & + + + - name: "JDodd" + + type: "live" + + linuxuid: 10033 + + + + popd + popd + +# ----------------------------------------------------- +# Check which cloud is currently live. +#[user@desktop] + + ssh fedora@live.gaia-dmp.uk \ + ' + date + hostname + ' + + > Wed 28 Feb 16:58:40 UTC 2024 + > iris-gaia-green-20231027-zeppelin + + + +# ----------------------------------------------------- +# Create a container to work with. +#[user@desktop] + + # + # Create a client for the live system. + # + + source "${HOME:?}/aglais.env" + + clientname=ansibler-live + + podman run \ + --rm \ + --tty \ + --interactive \ + --name "${clientname:?}" \ + --hostname "${clientname:?}" \ + --env "SSH_AUTH_SOCK=/mnt/ssh_auth_sock" \ + --volume "${SSH_AUTH_SOCK:?}:/mnt/ssh_auth_sock:rw,z" \ + --volume "${HOME:?}/clouds.yaml:/etc/openstack/clouds.yaml:ro,z" \ + --volume "${AGLAIS_CODE:?}/deployments:/deployments:ro,z" \ + ghcr.io/wfau/atolmis/ansible-client:2023.06.15 \ + bash + + + +# ----------------------------------------------------- +# Fetch the live system config. +#[root@ansibler] + + hostname=live.gaia-dmp.uk + + mkdir -p "${HOME}/.ssh" + ssh-keyscan "${hostname:?}" 2>/dev/null >> "${HOME}/.ssh/known_hosts" + + mkdir -p /opt/aglais + scp "${hostname:?}:/opt/aglais/aglais-status.yml" \ + "/opt/aglais/aglais-status.yml" + + cat "/opt/aglais/aglais-status.yml" + + + > + aglais: + status: + deployment: + type: hadoop-yarn + conf: zeppelin-54.86-spark-6.26.43 + name: iris-gaia-green-20231027 + date: 20231027T160525 + hostname: zeppelin.gaia-dmp.uk + spec: + openstack: + cloud: + base: arcus + name: iris-gaia-green + + + +# ----------------------------------------------------- +# Extract the cloud and configuration name. +#[root@ansibler] + + configname=$( + yq '.aglais.status.deployment.conf' "/opt/aglais/aglais-status.yml" + ) + + cloudname=$( + yq '.aglais.spec.openstack.cloud.name' "/opt/aglais/aglais-status.yml" + ) + +# ----------------------------------------------------- +# Configure our Ansible client. +#[root@ansibler] + + inventory="/deployments/hadoop-yarn/ansible/config/${configname:?}.yml" + + pushd "/deployments/hadoop-yarn/ansible" + + ansible-playbook \ + --inventory "${inventory:?}" \ + '05-config-ssh.yml' + + popd + +# ----------------------------------------------------- +# Check we can login using ssh. +#[root@ansibler] + + ssh zeppelin \ + ' + date + hostname + ' + + > Wed 28 Feb 2024 04:59:48 PM UTC + > iris-gaia-green-20231027-zeppelin + + + +# ----------------------------------------------------- +# Check the user accounts before we run the script. +#[root@ansibler] + + ssh zeppelin \ + ' + date + hostname + echo + tail -n 8 /etc/passwd + ' + + > Tue 04 Jul 2023 03:31:24 PM UTC + > iris-gaia-green-20230308-zeppelin + + > .... + > .... + MBayer:x:10025:10025::/home/MBayer:/bin/bash + DHDarrington:x:10026:10026::/home/DHDarrington:/bin/bash + GGuil:x:10027:10027::/home/GGuil:/bin/bash + WCooper:x:10028:10028::/home/WCooper:/bin/bash + NMiller:x:10029:10029::/home/NMiller:/bin/bash + AKyrieleis:x:10030:10030::/home/AKyrieleis:/bin/bash + PKuzma:x:10031:10031::/home/PKuzma:/bin/bash + aeYohngie7iel1ae:x:20001:20001::/home/aeYohngie7iel1ae:/bin/bash + + + +# ----------------------------------------------------- +# Add the ssh key for our data server. +#[root@ansibler] + + ssh-keyscan 'data.gaia-dmp.uk' 2>/dev/null >> "${HOME}/.ssh/known_hosts" + + +# ----------------------------------------------------- +# Re-install the live users, adding the new accounts. +# TODO Fast mode that skips existing users. +# https://github.com/wfau/gaia-dmp/issues/1157 +#[root@ansibler] + + source /deployments/admin/bin/create-user-tools.sh + import-live-users + + > .... + > .... + + list-shiro-full \ + /tmp/live-users.json + + + > { + > "username": "JDodd", + > "password": "#### ####", + > "passhash": "#### ####", + > "hashhash": "#### ####" + > }, + > ] + + +# ----------------------------------------------------- +# Update the passhash entries on our data server. +#[root@ansibler] + + ssh fedora@data.gaia-dmp.uk + + vi passhashes + + > users: + > passhash: + > .... + > .... + > "JDodd": "$######=" + + +# ----------------------------------------------------- +# Check the user accounts after we run the script. +#[root@ansibler] + + ssh zeppelin \ + ' + date + hostname + echo + tail -n 8 /etc/passwd + ' + + > Tue 04 Jul 2023 04:01:23 PM UTC + > iris-gaia-green-20230308-zeppelin + + > .... + > .... + > JDodd:x:10033:10033::/home/JDodd:/bin/bash + + +# ----------------------------------------------------- +# Check the CephFS mounts. +#[root@ansibler] + + ssh zeppelin + + ls -al /home + + .... + drwxr-x---. 3 JDodd JDodd 1 Feb 28 17:25 JDodd + .... + + + ls -al /user + + .... + drwxrwxrwx. 2 root root 0 Feb 28 17:25 JDodd + .... + + + +# ----------------------------------------------------- +# Check the new user's examples are registered correctly. +#[root@ansibler] + + ssh zeppelin + + newusers=( + JDodd + ) + + for newuser in "${newusers[@]}" + do + echo "User [${newuser}]" + + # + # Get the filename of their first notebook. + filename=$( + ls -1 "/home/fedora/zeppelin/notebook/Users/${newuser}/examples/" | grep '^1.' + ) + + echo "File [${filename}]" + + # + # Check the note ID and version + jq '{name, id, version}' \ + "/home/fedora/zeppelin/notebook/Users/${newuser}/examples/${filename}" + + noteid=$( + jq -r '.id' \ + "/home/fedora/zeppelin/notebook/Users/${newuser}/examples/${filename}" + ) + + # + # Check how that is registered in the notebook authorization file. + jq \ + --arg 'noteid' "${noteid:?}" \ + ' + .authInfo | + with_entries( + select( + .key | match($noteid) + ) + ) + ' \ + /home/fedora/zeppelin/conf/notebook-authorization.json + + echo + + done