Ansible
https://miro.medium.com/max/1400/0*_LHhOC_-FEJ1ILRd.jpg
Ansible is Simple IT Automation
Automation for everyone
No matter your role, or what your automation goals are, Ansible can help you demonstrate value, connect teams, and deliver efficiencies for your organization. Built on open source, Red Hat® Ansible® Automation Platform is a hardened, tested subscription product that offers full life cycle support for organizations. Explore how Ansible can help you automate today—and scale for the future.
オーケストレーションツールの一つであり、自動化や DevOps、IaC を実現する構成管理システムである。
Puppet, Chef などと比較されるがAnsibleが一番主流だと思われる。
Python で開発され、Ansible-Playbook と言う yml 形式の設定ファイルを記載する。
ansible-inventory コマンドで inventory 一覧を表示できる
ベストプラクティスを書くうえで参考になる記事
【Ansible】メンテナンスしやすいPlaybookの書き方 | 電算星組
ベストプラクティス — Ansible Documentation
高度な機能
使えばきっと一目置かれるAnsibleのちょっと高度な機能
Ansible-Console でインタラクティブに実行できる。
Config
ansible-config コマンドが便利
設定(config)は以下の優先順位で読み込まれる。(ファイルが存在すれば以降は読み込まれない。)
ANSIBLE_CONFIG: 環境変数(特定の作業にはこれを利用)
ANSIBLE_LOG_PATH="/path/to/log" ansible-playbook ...
ansible.cfg: リポジトリ設定(基本は置いてありそう)
~/.ansible.cfg: ユーザー設定(使わなそう)
/etc/ansible/ansible.cfg: システム設定
Inventory
ansible-inventory コマンドでホストに設定されている vars を確認できる
Memo
commands
code: (bash)
# 対象サーバーのヒストリーを削除AWS IAM Access Analyzer
ansible all -m shell -a "sudo rm {/root,~}/.bash_history"
Reference
Ansible の使い方
使えばきっと一目置かれるAnsibleのちょっと高度な機能
【Ansible】メンテナンスしやすいPlaybookの書き方 | 電算星組
以前に知っていたらよかった5つのAnsibleテクニック– zwischenzugs
Ansible | よく見る公式ドキュメントのページ5選 - てくなべ (tekunabe)
高速化
Ansible Playbookを高速化する方法– VITUX
Ansible実行を1/3に高速化した話 - RAKUS Developers Blog | ラクス エンジニアブログ