Skip to content

Instantly share code, notes, and snippets.

import ansible_runner
def run():
config = {
"project_dir": "./assets/project", # source directory
"playbook":"self_test.yml", # roles are relative to playbooks: use roles_path for other locations
"private_data_dir": "./data", # run-time directory
"inventory": ["inventory/localhost.yml"],
"suppress_env_files": True,
@stuartellis
stuartellis / s3purger.py
Created July 28, 2023 10:09
Purge S3 objects that have versions
#!/usr/bin/env python3
import logging
import time
import boto3
import botocore
AWS_REGION="eu-west-2"
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
hooks:
- args:
- --config-file
- .yamllint.yaml
id: yamllint
variables:
PROJECT_NAME: labs
CI_DEFAULT_IMAGE: alpine:3.18.2
CI_TF_IMAGE: $CI_DEFAULT_IMAGE
RELEASE_VERSION: $CI_COMMIT_SHORT_SHA
.action_tag_release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo "Tag release $ENVIRONMENT-$COMPONENT_NAME-$STACK_VARIANT-$RELEASE_VERSION"
## Ubuntu
aws ec2 describe-images \
--owners 099720109477 \
--filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-????????" "Name=state,Values=available" \
--query "reverse(sort_by(Images, &CreationDate))[:1].ImageId" \
--output text
## Amazon Linux 2
aws iam create-user --user-name aaa --tags Key=sje:resource:email,Value=aws@stuartellis.name Key=sje:resource:phase,Value=poc
aws iam attach-user-policy --user-name aaa --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
aws iam create-access-key --user-name aaa
@stuartellis
stuartellis / teams-error-extended.json
Created August 16, 2021 13:24
Teams Interactive Error
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "integration-fictional-api Failed Smoke Tests on UAT",
"sections": [{
"activityTitle": "integration-fictional-api Failed Smoke Tests on UAT",
"activitySubtitle": "Commit: fd17b15",
"activityImage": "https://img.icons8.com/flat-round/64/000000/error--v1.png",
"facts": [{
@stuartellis
stuartellis / teams-error1.json
Created August 16, 2021 13:06
MS Teams Error 1
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "integration-fictional-api Failed Smoke Tests on UAT",
"sections": [{
"activityTitle": "integration-fictional-api Failed Smoke Tests on UAT",
"activitySubtitle": "Commit: fd17b15",
"activityImage": "https://img.icons8.com/flat-round/64/000000/error--v1.png",
"facts": [{
@stuartellis
stuartellis / teams-info2.json
Created August 16, 2021 13:01
Teams Large Info
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "integration-fictional-api Deployed to UAT",
"sections": [{
"activityTitle": "integration-fictional-api Deployed to UAT",
"activitySubtitle": "Commit: fd17b15",
"activityImage": "https://img.icons8.com/flat-round/64/000000/info.png",
"facts": [{
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "integration-fictional-api Deployed to UAT",
"sections": [{
"activityTitle": "integration-fictional-api Deployed to UAT",
"activitySubtitle": "Commit: fd17b15",
"activityImage": "https://img.icons8.com/flat-round/48/000000/info.png"
}]