状況
dockerコンテナ削除するたびに less
などが使えなくなるのが面倒
対策
ansibleでミドルウェア管理するようにする
手順
1. ローカルへのansibleインストール
基本方針:公式通りに進める
1-1. pythonコマンド事前準備
-
python --version
するとzsh: command not found: python
となる -
brew install python
するとWarning: python@3.13 3.13.2 is already installed and up-to-date.
となるのでパス通っていない -
brew reinstall python@3.13
するとインストール成功 -
brew info python@3.13
するととなっているのでここにパスを通すUnversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, are installed into /opt/homebrew/opt/python@3.13/libexec/bin
-
vi ~/.zshrc
でexport PATH="/opt/homebrew/opt/python@3.13/libexec/bin:$PATH"
追記 source ~/.zshrc
-
python --version
でPython 3.13.2
表示されるようになった
1-2. pipコマンド確認
-
pip --version
とやるとpip 25.0 from /opt/homebrew/lib/python3.13/site-packages/pip (python 3.13)
になる
1-3. ansibleインストール
- 公式通り
pip install --user ansible
とやるとerror: externally-managed-environment
になって仮想環境用意しろと言われるので諦める brew install ansible
-
ansible --version
が使えるようになったので入った
2. playbook作成
ansible_connection=docker
にすることでsshを使わずに接続する