Archivio mensile:Aprile 2024

Quick and dirty : aws tag reserved instances

aws ec2 describe-reserved-instances
{
    "ReservedInstances": [
        {
            "Duration": 57024000,
            "End": "2026-02-12T16:11:46+00:00",
            "FixedPrice": 0.0,
            "InstanceCount": 3,
            "InstanceType": "r5a.xlarge",
            "ProductDescription": "Linux/UNIX",
            "ReservedInstancesId": "c5851026-2b6f-4d5c-99ba-946146221ac0",
            "Start": "2024-04-23T16:11:47.169000+00:00",
            "State": "active",
            "UsagePrice": 0.0,
            "CurrencyCode": "USD",
            "InstanceTenancy": "default",
            "OfferingClass": "standard",
            "OfferingType": "No Upfront",
            "RecurringCharges": [
                {
                    "Amount": 0.099,
                    "Frequency": "Hourly"
                }
            ],
            "Scope": "Region"
        }
    ]
}

aws ec2 create-tags --resources c5851026-2b6f-4d5c-99ba-946146221ac0 --tags Key=project,Value=200029

aws ec2 describe-reserved-instances                                                                 
{
    "ReservedInstances": [
        {
            "Duration": 57024000,
            "End": "2026-02-12T16:11:46+00:00",
            "FixedPrice": 0.0,
            "InstanceCount": 3,
            "InstanceType": "r5a.xlarge",
            "ProductDescription": "Linux/UNIX",
            "ReservedInstancesId": "c5851026-2b6f-4d5c-99ba-946146221ac0",
            "Start": "2024-04-23T16:11:47.169000+00:00",
            "State": "active",
            "UsagePrice": 0.0,
            "CurrencyCode": "USD",
            "InstanceTenancy": "default",
            "OfferingClass": "standard",
            "OfferingType": "No Upfront",
            "RecurringCharges": [
                {
                    "Amount": 0.099,
                    "Frequency": "Hourly"
                }
            ],
            "Scope": "Region",
            "Tags": [
                {
                    "Key": "project",
                    "Value": "200029"
                }
            ]
        }
    ]
}

Magari esisterà anche un altro modo, ma questo ha funzionato subito taggando le risorse

Piwigo e docker

Sto per cambiare radicalmente la configurazione della mia infrastruttura e la cosa che mi interessava era quella di poter ancora depositare su qualche parte le foto del rugby / harpastum che realizzo per i figli e, siccome l’appetito vien mangiando e non volendo installare effettivamente i pacchetti ho pensato di vedere se e come con docker si potesse fare.

Ho seguito le indicazioni in rete ed ho generato il seguente docker-composer.yml


services:
mysql-server-80:
image: mysql/mysql-server:8.0
volumes:
- /home/dockeruser/docker-piwigo/mysql/:/var/lib/mysql/
ports:
- "3306:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: piwigo
MYSQL_USER: utente
MYSQL_PASSWORD: password
piwigo:
image: lscr.io/linuxserver/piwigo:latest
container_name: piwigo
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Rome
volumes:
- /home/dockeruser/docker-piwigo/config:/config
- /home/dockeruser/docker-piwigo/gallery:/gallery
ports:
- 80:80
restart: unless-stopped
depends_on:
- mysql-server-80

La parte complicata è stata l’individuazione del nome della macchina che esponeva il servizio di mysql: all’inzio pensavo che fosse mysql-server-80, ma mi sono ricreduto quyando ho visto i nomi dei conainer presenti sulla rete di pwigo

docker network ls

riporta

274d82b58ef7 docker-piwigo_default bridge local

e poi con

docker network inspect docker-piwigo_default

ho avuto la conferma che il nome non era quello:

[
    {
        "Name": "docker-piwigo_default",
        "Id": "274d82b58ef7a0c0ab416ea16a7a81e58f083748aef29e0b7bfff324c62f05ea",
        "Created": "2024-04-21T09:59:37.303645746Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "4d3af57c45055f7f887de168d8b894a87345bc2584f77e90c5b986baf8fbd12b": {
                "Name": "docker-piwigo_mysql-server-80_1",
                "EndpointID": "fd26e447aa94e9188f9661c13420ef4edfd45c2f0d4c3c6ae2137f63ae68e540",
                "MacAddress": "02:42:ac:15:00:02",
                "IPv4Address": "172.21.0.2/16",
                "IPv6Address": ""
            },
            "8b08f8b67ff6b513627a9432ad6f81c222bff572460a0cd011e39b4b7d79304c": {
                "Name": "piwigo",
                "EndpointID": "9f7a1699f512bf9a784378a5fdd954c80aef488e1162cb2f14f611ed3a6d57ab",
                "MacAddress": "02:42:ac:15:00:03",
                "IPv4Address": "172.21.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "docker-piwigo",
            "com.docker.compose.version": "1.29.2"
        }
    }
]

ed impostando nel nome del server del db docker-piwigo_mysql-server-80_1 della configurazione di piwigo sono riuscito ad andare avanti,

ma mancava nella definizione del db l’utente e password. Mi sono cellagato sul docker del db con

docker exec -it docker-piwigo_mysql-server-80_1 /bin/bash
bash-4.4# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'utente'@'%' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT all PRIVILEGES ON piwigo.* TO 'utente'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

A questo punto la configurazione è andata a buon fine e il docker con piwigo e mysql funziona perfettamente