ファイルサイズ(容量)の合計

ls -l /var/log/maillog* | awk '{ total += $5 }; END { print total/1024/1024 "M" }'

http://blogcdn.rutake.com/techmemo/2017/04/19/linux-lsで特定ファイルサイズの合計値を出す/

find /usr/local/pgsql/archive/ -type f \
 -newermt '2019/3/27 11:00:00' -and ! -newermt '2019/3/27 13:00:00' \
 | xargs ls -l | awk '{ total += $5 }; END { print total/1024/1024 "M" }'

11:00〜13:00に更新されたファイルの合計

awk で変数の末尾1文字を削除
awk の変数の文字列の末尾1文字を削除する。

sub(/.$/,"",$1);

$1の中が「85%」の場合、85となる。
awk で変数の末尾1文字を削除 : コンピュータ操作覚え書き

aws cloudfront 証明書

It seems there's substantial delay, but it does eventually propagate. After almost 24h I'm now seeing the cert being served from both CDNs I was updating. It may be the case that doing invalidations on the / path helps as the other one that I did that came through already yesterday, whilst for the CDN I had to give over night.

https://forums.aws.amazon.com/message.jspa?messageID=825995

反映に時間かかる

https://aws.amazon.com/jp/about-aws/whats-new/2017/11/aws-certificate-manager-easier-certificate-validation-using-dns/

DNS検証

AWS Certificate Manager(ACM)による証明書の自動更新について勘違いしていたのでまとめ - Qiita
https://qiita.com/VTRyo/items/9534c73ff300ff721056

Ansible Galaxy role 登録

role登録

(github.com)
プロジェクト作成
https://github.com/kurita0/ansible-role-nagios_check_mfi

cd ansible-role-nagios_check_mfi

README.md
meta/main.yml
を追加

git init
git add .
git commit -m "first commit"
git remote add origin git@github.com:kurita0/ansible-role-nagios_check_mfi.git
git push -u origin master

(galaxy.ansible.com)
My Content
https://galaxy.ansible.com/my-content/namespaces
Add Content
Import Role from GitHub

roleを使う
ansible-galaxy install kurita0.nagios_check_mfi
roleを更新

github にコミットして

ansible-galaxy install -f  kurita0.nagios_check_mfi

Playbookを一旦開発し終わった後でも、ロールに対して修正することがよくあります
そんなときに、再度インストールし直すには、fオプションつけないと更新できません。
Ansible Galaxyでロールの管理 - コマンド編 - kikukawa's diary

参考

Ansible の Role を Ansible Galaxy に登録し再利用
https://qiita.com/kouji-kojima/items/2525ea87952d4039bad7

roleを作成してAnsible Galaxyに登録するワークフロー
https://qiita.com/hnakamur/items/4c5abbbbbb5623ce46ad

が参考になった

role用のgithubレポジトリ名

role用のgithubレポジトリ名はrole名と同じにしない
role名とレポジトリ名を同じにしてしまうと、Ansible roleが扱うupstreamのソフトウェアのレポジトリをforkするときに名前が衝突してしまいます。例えばnginxのroleをnginxという名前でgithubレポジトリを作ってしまうと、nginx自体のレポジトリをforkするときに困ってしまいます。そこで、role用のgithubレポジトリにはansible-role-という接頭辞をつけることにしました。

https://qiita.com/hnakamur/items/4c5abbbbbb5623ce46ad

Use galaxy_info.role_name, if set in meta/main.yml

https://github.com/ansible/galaxy/issues/498

githubレポジトリはansible-role-xxx に
meta/main.yml の galaxy_info.role_name: xxx にする

On pushing the change that sets this metadata tag, every one of our roles with a hyphenated name was silently converted to using underscores instead.

https://www.stackhpc.com/galaxy-broken.html

role_nameのハイフンはアンダースコアに変わる

参考

ansible で role を新規作成して ansible galaxy で公開して更新した
https://blog.n-z.jp/blog/2017-06-03-ansible-galaxy-new-role.html

https://galaxy.ansible.com/geerlingguy
https://github.com/geerlingguy

Add 'update' option to ansible-galaxy #6466
https://github.com/ansible/ansible/issues/6466

ansible コーディング規約

ansibleのコーディング規約
https://gist.github.com/kkkw/ea55caf2fdaa38a965d7de6954f1fdda

block ディレクティブ

Ansible v2.0 からの "block" ディレクティブを使ってみる
https://qiita.com/tksarah/items/5ec07acf9e7ee7814a04

WSL bash

echo "set bell-style none" >> ~/.inputrc
echo "set visualbell t_vb=" >> ~/.vimrc

Bash on Windowsでビープ音を消す方法 | Linux Fan

https://github.com/mintty/wsltty/releases

WSLのコンソールを便利で高機能な「wsltty」に置き換える:Tech TIPS - @IT

AWS CLI

構成設定はどこに保存されていますか。
...
~/.aws/credentials

[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

~/.aws/config

[default]
region=us-west-2
output=json

設定ファイルと認証情報ファイルの設定 - AWS Command Line Interface

AWS|AWS CLI(インストール, profileの設定, 使い方) - わくわくBank

AWS CLIでCloudWatchのアラームを制御する - t-sanoブログ

AWS CLIから設定していきます。(マネージメントコンソールから設定できそうかなと思い探したのですが無効化するような機能は見つけられませんでした。)
設定は簡単で下記コマンドで完了です。

アラームの無効化
$ aws cloudwatch disable-alarm-actions --alarm-name <アラームの名前>

運用作業を行うのでCloudWatchのアラーム設定を無効化させたい | DevelopersIO

よく使う aws-cli 「私的」コマンドチートシートとか jq の使い方とか - ようへいの日々精進XP

aws CloudFront S3 hosting

公式
静的ウェブサイトホスティング用に S3 バケットを設定する方法 - Amazon Simple Storage Service

AWS S3で静的Webページをホスティングする - Qiita

「アップロード」「アクセス許可を設定する」は
「このオブジェクトにパブリック読み取りアクセス権限を付与しない」
バケットポリシーで公開

CloudFrontとS3でHTTPS独自ドメイン
https://qiita.com/yoneapp/items/ed355be381723cd37b54

CloudFront で S3 静的ウェブサイトホスティングSSL/TLS に対応させる
https://dev.classmethod.jp/cloud/aws/tls-for-s3-web-hosting-with-cloudfront/

エラーページ

AWSのCloudFront+S3でSPAするときにErrorPagesを使いたくない
https://area-b.com/blog/2017/12/02/2205/

下記に your-bucket-name という名前のS3バケットへのアクセスを許可するポリシー例を記載しています。
念のため、バケットの削除や作成もできないように制限しています。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::your-bucket-name",
                "arn:aws:s3:::your-bucket-name/*"
            ]
        },
        {
            "Effect": "Deny",
            "Action": [
                "s3:DeleteBucket",
                "s3:CreateBucket"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

特定S3バケットに対してのみアクセスを許可したい – サーバーワークスエンジニアブログ