2642779b31b6ee78f35995cae52d78106e16096c
configuration/crontab
| ... | ... | @@ -1,3 +0,0 @@ |
| 1 | -* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_authorized_keys_for_landscape_managers_if_changed $( cat /root/ssh-key-reader.token ) https://security-service.sapsailing.com /root 2>&1 >>/var/log/sailing.err |
|
| 2 | -# NOTICE: Please try to reference the customised crontabs at $GIT_HOME/configuration/crontabs or use |
|
| 3 | -# the build_crontab_and_setup_files command in imageupgrade_functions.sh. This file has been maintained for continuity, but is deprecated. |
|
| ... | ... | \ No newline at end of file |
configuration/environments_scripts/build-crontab-and-cp-files
| ... | ... | @@ -33,17 +33,13 @@ do |
| 33 | 33 | done |
| 34 | 34 | shift $((OPTIND-1)) # shift the arguments along so there are no options in the arguments anymore. |
| 35 | 35 | if [[ "$#" -ne 3 ]]; then |
| 36 | - echo "$0 [ -f ] [ -n ] [ -c ] <ENVIRONMENT_TYPE> <USER_WITH_COPY_OF_REPO> <RELATIVE_PATH_OF_GIT_DIR_WITHIN_USER>" |
|
| 36 | + echo "$0 [ -f ] [ -n ] [ -c ] <ENVIRONMENT_TYPE>" |
|
| 37 | 37 | echo "" |
| 38 | - echo "Where USER_WITH_COPY_OF_REPO is a user that contains a checked out copy of the main git." |
|
| 39 | - echo "And where RELATIVE_PATH_OF_GIT_DIR_WITHIN_USER is the path to the git repo from the USER_WITH_COPY_OF_REPO's home directory." |
|
| 40 | 38 | echo "Use the f(iles) flag to disable file copying. Use the c(rontab) flag to disable the creation of users and the creation of crontab files for those users." |
| 41 | 39 | echo "If the c flag is not used then the n(o install) flag can be used to setup the crontabs but not install them." |
| 42 | 40 | exit 2 |
| 43 | 41 | fi |
| 44 | 42 | ENV_TYPE="$1" |
| 45 | -GIT_USER="$2" |
|
| 46 | -RELATIVE_GIT_DIR_NAME="$3" |
|
| 47 | 43 | cd "$(dirname "$0")/${ENV_TYPE}" |
| 48 | 44 | if [[ -d "groups" ]]; then |
| 49 | 45 | cd "groups" |
| ... | ... | @@ -60,7 +56,6 @@ if [[ -d "groups" ]]; then |
| 60 | 56 | fi |
| 61 | 57 | if [[ -d "users" ]]; then |
| 62 | 58 | cd "users" |
| 63 | - GIT_PATH="$(eval echo $(printf "~%q" "$GIT_USER"))/${RELATIVE_GIT_DIR_NAME}" # The absolute path to a git repo in the environment type. |
|
| 64 | 59 | for dir in *; do |
| 65 | 60 | [[ -d "$dir" ]] || continue |
| 66 | 61 | USERNAME="$dir" |
| ... | ... | @@ -95,7 +90,7 @@ if [[ -d "users" ]]; then |
| 95 | 90 | # Clear the crontab file before assembling it from the snippets: |
| 96 | 91 | > $HOME_DIR/crontab |
| 97 | 92 | echo "# Note that this file should not be edited manually. Please instead make use of the build_crontab_and_setup_files command in imageupgrade_functions.sh">>"$HOME_DIR"/crontab |
| 98 | - echo "# which concatenates the crontabs found at GIT_HOME/configuration/crontabs into this file. Please edit these crontab stubs in the git repo to make permanent changes.">>"$HOME_DIR"/crontab |
|
| 93 | + echo "# which concatenates the crontabs found at users/*/* into this file. Please edit these crontab stubs in the git repo to make permanent changes.">>"$HOME_DIR"/crontab |
|
| 99 | 94 | echo "">>"$HOME_DIR"/crontab |
| 100 | 95 | for crontab in ${USERNAME}/crontab*; do |
| 101 | 96 | [[ -e $crontab ]] || continue |
configuration/environments_scripts/build_server/setup-hudson-server.sh
| ... | ... | @@ -23,7 +23,7 @@ else |
| 23 | 23 | sudo chown root:root /root/secrets |
| 24 | 24 | sudo chmod 600 /root/secrets |
| 25 | 25 | . imageupgrade_functions.sh |
| 26 | - if ! build_crontab_and_setup_files build_server sailing code; then |
|
| 26 | + if ! build_crontab_and_setup_files build_server; then |
|
| 27 | 27 | exit 1 |
| 28 | 28 | fi |
| 29 | 29 | # Make eu-west-1 the default region for any aws CLI interaction: |
configuration/environments_scripts/central_mongo_setup/files/usr/local/bin/imageupgrade
| ... | ... | @@ -18,7 +18,7 @@ clean_mongo_pid() { |
| 18 | 18 | LOGON_USER_HOME=/home/ec2-user |
| 19 | 19 | |
| 20 | 20 | run_yum_update |
| 21 | -build_crontab_and_setup_files central_mongo_setup root code |
|
| 21 | +build_crontab_and_setup_files central_mongo_setup |
|
| 22 | 22 | clean_startup_logs |
| 23 | 23 | clean_mongo_pid |
| 24 | 24 | finalize |
configuration/environments_scripts/central_reverse_proxy/setup-central-reverse-proxy-part-2.sh
| ... | ... | @@ -17,8 +17,6 @@ if [[ "$#" -ne 2 ]]; then |
| 17 | 17 | fi |
| 18 | 18 | IP=$1 |
| 19 | 19 | IMAGE_TYPE="$2" |
| 20 | -GIT_COPY_USER="wiki" |
|
| 21 | -RELATIVE_PATH_TO_GIT="gitwiki" # the relative path to the repo within the git_copy_user |
|
| 22 | 20 | TEMPORARY_HOME_COPY_LOCATION="/root/temporary_home_copy" # home nested within this. |
| 23 | 21 | ssh -A "root@${IP}" "bash -s" << EOF |
| 24 | 22 | sudo systemctl start crond.service |
| ... | ... | @@ -27,7 +25,7 @@ sudo systemctl start tmux-management-panel.service |
| 27 | 25 | cp -r "$TEMPORARY_HOME_COPY_LOCATION"/home / |
| 28 | 26 | rm -rf "$TEMPORARY_HOME_COPY_LOCATION" |
| 29 | 27 | # Localhost works here as we are logged on as root and are using ssh agent forwarding. |
| 30 | -if ! build_crontab_and_setup_files -h localhost -f "${IMAGE_TYPE}" "${GIT_COPY_USER}" "${RELATIVE_PATH_TO_GIT}"; then # files have already been copied so -f is used. |
|
| 28 | +if ! build_crontab_and_setup_files -h localhost -f "${IMAGE_TYPE}"; then # files have already been copied so -f is used. |
|
| 31 | 29 | exit 1 |
| 32 | 30 | fi |
| 33 | 31 | setup_keys -p "${IMAGE_TYPE}" |
configuration/environments_scripts/central_reverse_proxy/setup-central-reverse-proxy.sh
| ... | ... | @@ -44,8 +44,6 @@ IMAGEUPGRADE_FUNCTIONS_IP="$3" # can be a domain name, such as sapsailing.com |
| 44 | 44 | IMAGEUPGRADE_FUNCTIONS_PATH_ON_INSTANCE_TO_GIT="$4" |
| 45 | 45 | IMAGE_TYPE="central_reverse_proxy" |
| 46 | 46 | HTTP_LOGROTATE_ABSOLUTE=/etc/logrotate.d/httpd |
| 47 | -GIT_COPY_USER="wiki" |
|
| 48 | -RELATIVE_PATH_TO_GIT="gitwiki" # the relative path to the repo within the git_copy_user |
|
| 49 | 47 | # This authorized keys copying is essential as we rely on the ability to log into the root user. |
| 50 | 48 | ssh -A "ec2-user@${IP}" "bash -s" << FIRSTEOF |
| 51 | 49 | # Correct authorized keys. May not be necessary if update_authorized_keys is running. |
| ... | ... | @@ -128,7 +126,7 @@ scp -o StrictHostKeyChecking=no -p root@"$IMAGEUPGRADE_FUNCTIONS_IP":"$IMAGEUPGR |
| 128 | 126 | . imageupgrade_functions.sh |
| 129 | 127 | setup_cloud_cfg_and_root_login |
| 130 | 128 | # setup files |
| 131 | -if ! build_crontab_and_setup_files -c -n "${IMAGE_TYPE}" "${GIT_COPY_USER}" "${RELATIVE_PATH_TO_GIT}"; then # -c & -n mean only files are copied over. |
|
| 129 | +if ! build_crontab_and_setup_files -c -n "${IMAGE_TYPE}"; then # -c & -n mean only files are copied over. |
|
| 132 | 130 | exit 1 |
| 133 | 131 | fi |
| 134 | 132 | setup_swap 5000 |
configuration/environments_scripts/mongo_instance_setup/files/usr/local/bin/imageupgrade
| ... | ... | @@ -18,7 +18,7 @@ clean_mongo_pid() { |
| 18 | 18 | LOGON_USER_HOME=/home/ec2-user |
| 19 | 19 | |
| 20 | 20 | run_yum_update |
| 21 | -build_crontab_and_setup_files mongo_instance_setup root code |
|
| 21 | +build_crontab_and_setup_files mongo_instance_setup |
|
| 22 | 22 | clean_startup_logs |
| 23 | 23 | clean_mongo_pid |
| 24 | 24 | finalize |
configuration/environments_scripts/mysql_instance_setup/setup-mysql-server.sh
| ... | ... | @@ -47,7 +47,7 @@ else |
| 47 | 47 | sudo systemctl enable crond.service |
| 48 | 48 | sudo systemctl start crond.service |
| 49 | 49 | . imageupgrade_functions.sh |
| 50 | - if ! build_crontab_and_setup_files mysql_instance_setup ec2-user no_local_copy; then |
|
| 50 | + if ! build_crontab_and_setup_files mysql_instance_setup; then |
|
| 51 | 51 | exit 1 |
| 52 | 52 | fi |
| 53 | 53 | setup_sshd_resilience |
configuration/environments_scripts/rabbitmq_instance_setup/setup-rabbitmq-server.sh
| ... | ... | @@ -23,7 +23,7 @@ else |
| 23 | 23 | scp -o StrictHostKeyChecking=false -r root@sapsailing.com:/home/wiki/gitwiki/configuration/environments_scripts/repo/usr/local/bin/imageupgrade_functions.sh /home/admin |
| 24 | 24 | sudo mv imageupgrade_functions.sh /usr/local/bin |
| 25 | 25 | . imageupgrade_functions.sh |
| 26 | - if ! build_crontab_and_setup_files 'rabbitmq_instance_setup' admin environments_scripts; then |
|
| 26 | + if ! build_crontab_and_setup_files 'rabbitmq_instance_setup'; then |
|
| 27 | 27 | exit 1 |
| 28 | 28 | fi |
| 29 | 29 | setup_sshd_resilience |
configuration/environments_scripts/repo/usr/local/bin/imageupgrade_functions.sh
| ... | ... | @@ -89,8 +89,6 @@ build_crontab_and_setup_files() { |
| 89 | 89 | echo " -f means no files are copied over, which is useful if you have already copied files accross or don't want to override existing files" |
| 90 | 90 | echo "Then there are the arguments, where the order matters:" |
| 91 | 91 | echo " ENVIRONMENT_TYPE - the directory name in environments_scripts which will be used." |
| 92 | - echo " USER_WITH_COPY_OF_REPO - a user which will exist on the environment type, which has a checked out copy of the git workspace." |
|
| 93 | - echo " RELATIVE_PATH_OF_GIT_DIR_WITHIN_USER - the relative path within the USER_WITH_COPY_OF_REPO to get to the git workspace." |
|
| 94 | 92 | else |
| 95 | 93 | TEMP=$(getopt -o fnch: -n 'options checker' -- "$@") |
| 96 | 94 | [[ "$?" -eq 0 ]] || return 2 |
configuration/environments_scripts/reverse_proxy/files/usr/local/bin/imageupgrade
| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -# Script to deploy on an instance that has an ephemeral volume as /dev/nvme0n1 (adjust env var PARTITION if different) |
|
| 4 | -# Ensures the partition is xfs-formatted, any existing partition contents will be overwritten if formatted otherwise. |
|
| 5 | -# An existing xfs partition will be left alone. |
|
| 6 | 3 | . imageupgrade_functions.sh |
| 7 | 4 | |
| 8 | 5 | get_ec2_user_data() { |
| ... | ... | @@ -13,12 +10,10 @@ METADATA=$( get_ec2_user_data ) |
| 13 | 10 | echo "Metadata: ${METADATA}" |
| 14 | 11 | if echo "${METADATA}" | grep -q "^image-upgrade$"; then |
| 15 | 12 | echo "Image upgrade..." |
| 16 | - GIT_COPY_USER="trac" |
|
| 17 | - RELATIVE_PATH_TO_GIT="gitcopy" |
|
| 18 | 13 | LOGON_USER_HOME="ec2-user" |
| 19 | 14 | ENVIRONMENT_TYPE="reverse_proxy" |
| 20 | 15 | run_yum_update |
| 21 | - build_crontab_and_setup_files "${ENVIRONMENT_TYPE}" "${GIT_COPY_USER}" "${RELATIVE_PATH_TO_GIT}" |
|
| 16 | + build_crontab_and_setup_files "${ENVIRONMENT_TYPE}" |
|
| 22 | 17 | finalize |
| 23 | 18 | fi |
| 24 | 19 |
configuration/environments_scripts/reverse_proxy/setup-disposable-reverse-proxy.sh
| ... | ... | @@ -11,8 +11,6 @@ IP=$1 |
| 11 | 11 | BEARER_TOKEN=$2 |
| 12 | 12 | IMAGE_TYPE="reverse_proxy" |
| 13 | 13 | HTTP_LOGROTATE_ABSOLUTE=/etc/logrotate.d/httpd |
| 14 | -GIT_COPY_USER="trac" |
|
| 15 | -RELATIVE_PATH_TO_GIT="gitcopy" # the relative path to the repo within the git_copy_user |
|
| 16 | 14 | ssh -A "ec2-user@${IP}" "bash -s" << FIRSTEOF |
| 17 | 15 | # Correct authorized keys. May not be necessary if update_authorized_keys is running. |
| 18 | 16 | sudo su - -c "cat ~ec2-user/.ssh/authorized_keys > /root/.ssh/authorized_keys" |
| ... | ... | @@ -35,7 +33,7 @@ scp -o StrictHostKeyChecking=no -p "root@sapsailing.com:/home/wiki/gitwiki/confi |
| 35 | 33 | setup_keys "${IMAGE_TYPE}" |
| 36 | 34 | setup_cloud_cfg_and_root_login |
| 37 | 35 | # setup files and crontab for the required users, both dependent on the environment type. |
| 38 | -build_crontab_and_setup_files "${IMAGE_TYPE}" "${GIT_COPY_USER}" "${RELATIVE_PATH_TO_GIT}" |
|
| 36 | +build_crontab_and_setup_files "${IMAGE_TYPE}" |
|
| 39 | 37 | # setup mail |
| 40 | 38 | setup_mail_sending |
| 41 | 39 | # setup sshd config |
configuration/environments_scripts/sailing_server/files/usr/local/bin/imageupgrade
| ... | ... | @@ -11,5 +11,5 @@ clean_logrotate_target |
| 11 | 11 | clean_httpd_logs |
| 12 | 12 | clean_servers_dir |
| 13 | 13 | clean_startup_logs |
| 14 | -build_crontab_and_setup_files sailing_server sailing no-checked-out-workspace |
|
| 14 | +build_crontab_and_setup_files sailing_server |
|
| 15 | 15 | finalize |
configuration/environments_scripts/sailing_server/setup-sailing-server.sh
| ... | ... | @@ -35,7 +35,7 @@ else |
| 35 | 35 | # The 2nd argument references a user home to navigate to and the 3rd argument is the path to navigate to within that user to find a checked |
| 36 | 36 | # out git workspace. This dependency will be removed in the future, when we no longer have any dependency on a checked out |
| 37 | 37 | # workspace on a sailing server. |
| 38 | - build_crontab_and_setup_files sailing_server sailing code |
|
| 38 | + build_crontab_and_setup_files sailing_server |
|
| 39 | 39 | # Create an SSH key pair with empty passphrase for ec2-user, deploy it to trac@sapsailing.com |
| 40 | 40 | # and then move it to the sailing user's .ssh directory |
| 41 | 41 | setup_keys "sailing_server" |
configuration/mysql_instance_setup/crontab-ec2-user
| ... | ... | @@ -1,3 +0,0 @@ |
| 1 | -* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_authorized_keys_for_landscape_managers_if_changed $( cat /home/ec2-user/ssh-key-reader.token ) https://security-service.sapsailing.com /home/ec2-user |
|
| 2 | -# NOTICE: Please try to reference the customised crontabs at $GIT_HOME/configuration/crontabs or use |
|
| 3 | -# the build_crontab_and_setup_files command in imageupgrade_functions.sh. This file has been maintained for continuity, but is deprecated. |
configuration/sailing_server_setup/crontab-root
| ... | ... | @@ -1,3 +0,0 @@ |
| 1 | -* * * * * export PATH=/bin:/usr/bin:/usr/local/bin; sleep $(( $RANDOM * 60 / 32768 )); update_authorized_keys_for_landscape_managers_if_changed $( cat /root/ssh-key-reader.token ) https://security-service.sapsailing.com /root 2>&1 >>/var/log/sailing.err |
|
| 2 | -# NOTICE: Please try to reference the customised crontabs at $GIT_HOME/configuration/crontabs or use |
|
| 3 | -# the build_crontab_and_setup_files command in imageupgrade_functions.sh. This file has been maintained for continuity, but is deprecated. |
configuration/sailing_server_setup/mountnvmeswap
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -../environments_scripts/repo/usr/local/bin/mountnvmeswap |
|
| ... | ... | \ No newline at end of file |
configuration/sailing_server_setup/mountnvmeswap.initd
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -../archive_instance_setup/mountnvmeswap.initd |
|
| ... | ... | \ No newline at end of file |
configuration/sailing_server_setup/mountnvmeswap.service
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -../environments_scripts/repo/etc/systemd/system/mountnvmeswap.service |
|
| ... | ... | \ No newline at end of file |
configuration/sailing_server_setup/sailing.service
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -../environments_scripts/sailing_server/files/etc/systemd/system/sailing.service |
|
| ... | ... | \ No newline at end of file |
wiki/info/landscape/amazon-ec2.md
| ... | ... | @@ -489,13 +489,11 @@ Any scripts common to multiple environment scripts, may be found in the "repo", |
| 489 | 489 | The build-crontab-and-cp-files uses this structure to help setup an environment |
| 490 | 490 | type. It builds the crontab file, by combining all the referenced crontab |
| 491 | 491 | one-liners, storing a copy in the user's home directory and installing it to the specified user. It also copies across the contents of "files" to the corresponding location, de-refencing any symbolic links. |
| 492 | -The script should ideally be triggered using a function in `imageupgrade_functions.sh`, titled `build_crontab_and_setup_files`, that takes an environment type (see other arguments below), and temporarily copies (via scp) the environments_scripts folder. It then calls the build-crontab-and-cp-files script. |
|
| 492 | +The script should ideally be triggered using a function in `imageupgrade_functions.sh`, titled `build_crontab_and_setup_files`, that takes an environment type (see other arguments below), and temporarily copies (via scp) the environments_scripts folder. It then calls the `build-crontab-and-cp-files` script. |
|
| 493 | 493 | |
| 494 | 494 | This script has a couple of arguments and options. The most important are the arguments. |
| 495 | 495 | 1. Environment type. |
| 496 | -2. User with a checked out Git copy. |
|
| 497 | -3. The relative path within $2 to the Git copy. |
|
| 498 | -Ideally, we would have only a single checked out Git copy across all instances: one on the wiki user of the central. However, some crontabs require references to specific users' files, so we have the string PATH_OF_HOME_DIR_TO_REPLACE, in the crontabs, as placeholders for the paths the string itself describes, which the build-crontab-and-cp-files script replaces with the right path. |
|
| 496 | +Some crontabs require references to specific users' files, so we have the string PATH_OF_HOME_DIR_TO_REPLACE, in the crontabs, as placeholders for the paths the string itself describes, which the `build-crontab-and-cp-files` script replaces with the right path. |
|
| 499 | 497 | Have a look at the script itself for more details on the options and arguments. |
| 500 | 498 | |
| 501 | 499 | ## Reverse proxy automation |
| ... | ... | @@ -578,9 +576,9 @@ write and quit, to install the cronjob. |
| 578 | 576 | * * * * * /home/wiki/gitwiki/configuration/switchoverArchive.sh "/etc/httpd/conf.d/000-macros.conf" 2 9 |
| 579 | 577 | ``` |
| 580 | 578 | |
| 581 | -If you want to quickly run this script, consider installing it in /usr/local/bin, via `ln -s TARGET_PATH LINK_NAME`. |
|
| 579 | +If you want to quickly run this script, consider installing it in ``/usr/local/bin``, via `ln -s TARGET_PATH LINK_NAME`. |
|
| 582 | 580 | |
| 583 | -You can use the build_crontab_and_setup_files (see below) to get these changes. |
|
| 581 | +You can use the `build_crontab_and_setup_files` (see below) to get these changes. |
|
| 584 | 582 | |
| 585 | 583 | ## Automated SSH Key Management |
| 586 | 584 |
wiki/info/landscape/creating-ec2-image-for-webserver-from-scratch.md
| ... | ... | @@ -181,4 +181,4 @@ The script sets up nfs/nvme mounts, installs/updates httpd + software for script |
| 181 | 181 | |
| 182 | 182 | ## Read Also |
| 183 | 183 | |
| 184 | -Check out the details in [amazon-ec2](https://wiki.sapsailing.com/wiki/info/landscape/amazon-ec2#amazon-ec2-for-sap-sailing-analytics_landscape-overview_apache-httpd-the-central-reverse-proxy-webserver-and-disposable-reverse-proxies) on the disposables and central: namely the target group healthcheck and shared httpd configuration Git repo. Also, look over the key_vault and the build_crontab_and_setup_files detailed there. |
|
| ... | ... | \ No newline at end of file |
| 0 | +Check out the details in [amazon-ec2](https://wiki.sapsailing.com/wiki/info/landscape/amazon-ec2#amazon-ec2-for-sap-sailing-analytics_landscape-overview_apache-httpd-the-central-reverse-proxy-webserver-and-disposable-reverse-proxies) on the disposables and central: namely the target group healthcheck and shared httpd configuration Git repo. Also, look over the key_vault and the ``build_crontab_and_setup_files`` detailed there. |
|
| ... | ... | \ No newline at end of file |