From 4f95870c3376ca4b213082ce1c6a64ce032299ea Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 22 Aug 2024 19:51:50 +0200 Subject: [PATCH] chore(gitlab): upgrade package-based instance --- knowledge base/cloud computing/aws/ebs.md | 7 +++++++ snippets/ansible/commands.sh | 3 ++- snippets/aws/commands.fish | 7 +++++++ snippets/gitlab/gitlab-runner.sh | 2 ++ snippets/gitlab/package installation.sh | 8 ++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/knowledge base/cloud computing/aws/ebs.md b/knowledge base/cloud computing/aws/ebs.md index a94c1f8..a098d99 100644 --- a/knowledge base/cloud computing/aws/ebs.md +++ b/knowledge base/cloud computing/aws/ebs.md @@ -17,6 +17,13 @@ Persistent [block storage][what is block storage?] for [EC2 Instances][ec2]. aws ec2 describe-volumes --output 'text' --filters 'Name=status,Values=available' \ --query "Volumes[?CreateTime<'2018-03-31'].VolumeId" \ | xargs -pn '1' aws ec2 delete-volume --volume-id + +# Check state of snapshots. +aws ec2 describe-snapshots --snapshot-ids 'snap-0123456789abcdef0' \ + --query 'Snapshots[].{"State": State,"Progress": Progress}' --output 'yaml' + +# Wait for snapshots to finish. +aws ec2 wait snapshot-completed --snapshot-ids 'snap-0123456789abcdef0' ``` diff --git a/snippets/ansible/commands.sh b/snippets/ansible/commands.sh index 6ae4162..71a9994 100644 --- a/snippets/ansible/commands.sh +++ b/snippets/ansible/commands.sh @@ -51,7 +51,8 @@ ansible-playbook 'path/to/playbook.yml' --syntax-check # Ad-hoc commands. ansible -i 'hosts.yml' -m 'ping' 'all' ansible -i 'host-1,host-n,' 'hostRegex' -m 'ansible.builtin.shell' -a 'echo $TERM' -ansible -i 'localhost ansible_python_interpreter=venv/bin/python3,' -c 'local' -m 'ansible.builtin.copy' -a 'src=/tmp/src' -a 'dest=/tmp/dest' 'localhost' +ansible -i 'localhost ansible_python_interpreter=venv/bin/python3,' -c 'local' 'localhost' \ + -m 'ansible.builtin.copy' -a 'src=/tmp/src' -a 'dest=/tmp/dest' ansible-vault encrypt_string --name 'command_output' 'somethingNobodyShouldKnow' ANSIBLE_VAULT_PASSWORD='ohSuchASecurePassword' ansible-vault encrypt --output 'ssh.key' '.ssh/id_rsa' diff --git a/snippets/aws/commands.fish b/snippets/aws/commands.fish index 745221e..acb672e 100644 --- a/snippets/aws/commands.fish +++ b/snippets/aws/commands.fish @@ -116,6 +116,13 @@ aws kms get-key-policy --output 'text' --key-id '01234567-89ab-cdef-0123-456789a aws ec2 describe-images --image-ids 'ami-01234567890abcdef' aws ec2 describe-images --image-ids 'ami-01234567890abcdef' --query 'Images[].Description' +# Check state of snapshots. +aws ec2 describe-snapshots --snapshot-ids 'snap-0123456789abcdef0' \ + --query 'Snapshots[].{"State": State,"Progress": Progress}' --output 'yaml' + +# Wait for snapshots to finish. +aws ec2 wait snapshot-completed --snapshot-ids 'snap-0123456789abcdef0' + aws autoscaling describe-auto-scaling-groups aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names 'ProductionServers' aws autoscaling start-instance-refresh --auto-scaling-group-name 'ProductionServers' diff --git a/snippets/gitlab/gitlab-runner.sh b/snippets/gitlab/gitlab-runner.sh index 2ae757a..9a54f45 100644 --- a/snippets/gitlab/gitlab-runner.sh +++ b/snippets/gitlab/gitlab-runner.sh @@ -33,3 +33,5 @@ gitlab-runner list -c '/etc/gitlab-runner/config.toml' gitlab-runner verify -c '/etc/gitlab-runner/config.toml' # Also delete runners that have been removed from the main instance gitlab-runner verify … --delete + +diff -y <(helm show values 'gitlab/gitlab-runner' --version '0.64.2') <(helm show values 'gitlab/gitlab-runner' --version '0.68.1') diff --git a/snippets/gitlab/package installation.sh b/snippets/gitlab/package installation.sh index ba39eac..0778326 100644 --- a/snippets/gitlab/package installation.sh +++ b/snippets/gitlab/package installation.sh @@ -103,6 +103,14 @@ sudo gitlab-ctl backup-etc \ | head -n '1' \ | xargs -pI '{}' aws s3 cp '/etc/gitlab/config_backup/'{} 's3://backups/gitlab/' +# Put the instance in maintenance mode +sudo gitlab-rails runner ' + ::Gitlab::CurrentSettings.update!(maintenance_mode: true); + ::Gitlab::CurrentSettings.update!(maintenance_mode_message: "New message"); +' +# Take the instance out of maintenance mode +sudo gitlab-rails runner '::Gitlab::CurrentSettings.update!(maintenance_mode: false);' + # Package upgrade sudo yum check-update sudo yum info 'gitlab-ee' # informational