スマートフォン・ジン | Smartphone-Zine

引っ越し先→ https://smartphone-zine.com/

memo

ansibleでLinuxコマンドの「patch」をインストールするスクリプトを書いてください。redhad系、Debian系両方対応するようにお願いします。

  • name: Install patch command hosts: all become: true tasks:
      - name: Install patch on Red Hat based systems
          yum:
              name: patch
              state: present
          when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS'
    
      - name: Install patch on Debian based systems
          apt:
              name: patch
              state: present
          when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
    
# ログイン
az acr login --name <acr-name>

# レポジトリの一覧を取得
repositories=$(az acr repository list --name <acr-name> --output tsv)

# 各レポジトリのイメージのダイジェストを取得
for repo in $repositories
do
  echo "Repository: $repo"
  az acr repository show-manifests --name <acr-name> --repository $repo --query "[].digest" --output tsv
done
# Azureにログイン
az login

# ACR_NAMEにはあなたのACRの名前を設定してください
ACR_NAME="your_acr_name"

# リポジトリ一覧を取得
REPOSITORIES=$(az acr repository list --name $ACR_NAME --output tsv)

# 各リポジトリについて、イメージのタグとダイジェストを取得
for REPO in $REPOSITORIES
do
  echo "Repository: $REPO"
  TAGS=$(az acr repository show-tags --name $ACR_NAME --repository $REPO --output tsv)
  for TAG in $TAGS
  do
    DIGEST=$(az acr repository show-manifests --name $ACR_NAME --repository $REPO --query "[?tags[? @ == '$TAG']].digest" --output tsv)
    echo "Tag: $TAG, Digest: $DIGEST"
  done
done
#!/bin/bash

# Azure ACR name
ACR_NAME="<your-acr-name>"

# Output file path
OUTPUT_FILE="acr_images.csv"

# Get all repository names
REPO_NAMES=$(az acr repository list --name $ACR_NAME --output tsv)

# Create the output file with headers
echo "Repository Name,Image Digest,Tag" > $OUTPUT_FILE

# Loop through each repository
for REPO_NAME in $REPO_NAMES; do
    # Get all image manifests for the repository
    MANIFESTS=$(az acr repository show-manifests --name $ACR_NAME --repository $REPO_NAME --output tsv)

    # Loop through each image manifest
    while IFS=$'\t' read -r DIGEST TAG; do
        # Append the repository name, image digest, and tag to the output file
        echo "$REPO_NAME,$DIGEST,$TAG" >> $OUTPUT_FILE
    done <<< "$MANIFESTS"
done

echo "CSV file with repository names, image digests, and tags has been created: $OUTPUT_FILE"

#!/bin/bash

# Check if ACR name is provided as an argument
if [ $# -eq 0 ]; then
  echo "ACR name is required."
  exit 1
fi

# Set ACR name from the argument
ACR_NAME=$1

# Get the list of repositories in the ACR
REPOSITORIES=$(az acr repository list --name $ACR_NAME --output tsv)

# Create a CSV file to store the output
OUTPUT_FILE="acr_images.csv"
echo "Repository,Image Digest,Tags" > $OUTPUT_FILE

# Iterate over each repository
for REPO in $REPOSITORIES; do
  # Get the list of images and their digests
  IMAGES=$(az acr repository show-manifests --name $ACR_NAME --repository $REPO --orderby time_desc --output tsv --query "[].{Digest: digest, Tags: tags[0]}")

  # Iterate over each image
  while IFS=$'\t' read -r DIGEST TAG; do
    # Append the repository, image digest, and tags to the CSV file
    echo "$REPO,$DIGEST,$TAG" >> $OUTPUT_FILE
  done <<< "$IMAGES"
done

echo "Output saved to $OUTPUT_FILE"