cat /sys/devices/virtual/dmi/id/board_asset_tag
#short hostname
hname=$(cat /sys/devices/virtual/dmi/id/board_asset_tag | awk '{print substr($0,5,15)}')
hostnamectl set-hostname $hname
Month: March 2021
Rabbitmq docker-compose
version: '3'
services:
rabbitmq:
image: rabbitmq:3-management
restart: always
container_name: rabbitmq
environment:
TZ: "Asia/Kolkata"
RABBITMQ_DEFAULT_USER: username
RABBITMQ_DEFAULT_PASS: password
volumes:
- /opt/rabbitmq/data:/var/lib/rabbitmq
ports:
- 5671:5671
- 5672:5672
- 15672:15672
Docker command :
dodocker run -d -p 5671:5671 -p 5672:5672 -p 15672:15672 -v /opt/rabbitmq/data:/var/lib/rabbitmq -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password -e TZ="Asia/Kolkata" --restart unless-stopped rabbitmq:3-management
cloudcustodian ec2 start/stop rule
start-policy.yml
policies:
- name: start-policy
resource: aws.ec2
query:
- instance-state-name: stopped
filters:
- "tag:owner": present
actions:
- start
stop-policy.yml
policies:
- name: stop-policy
resource: aws.ec2
filters:
- "tag:owner": present
actions:
- stop
custodian run --cache-period 0 start-policy.yml -s output
custodian run --cache-period 0 stop-policy.yml -s output
https://cloudcustodian.io/docs/aws/gettingstarted.html
Deregister aws ami older than 30 days:
policies:
- name: ebs-delete-old-ebs-snapshots
resource: ami
filters:
- type: image-age
days: 30
op: ge
actions:
- deregister
Delete aws snapshot older than 30 days:
policies:
- name: ebs-delete-old-ebs-snapshots
resource: ebs-snapshot
filters:
- type: age
days: 30
op: ge
actions:
- delete
Docker CloudCustodian
docker run -it -v $(pwd)/output:/opt/custodian/output -v $(pwd):/opt/custodian/ --env-file <(env | grep "^AWS\|^AZURE\|^GOOGLE|^kubeconfig") cloudcustodian/c7n run -v -s /opt/custodian/output /opt/custodian/policy.yml
docker run -it --entrypoint=/bin/bash -v $(pwd)/output:/opt/custodian/output -v $(pwd):/opt/custodian/ --env-file <(env | grep "^AWS\|^AZURE\|^GOOGLE|^kubeconfig") cloudcustodian/c7n