Ansibleでaptの設定をする場合の指定方法メモ
設定例
単体指定する場合例
tasks:
- name: install language-pack-ja
apt: name=language-pack-ja update_cache=yes cache_valid_time=3600
複数指定する場合例
tasks:
- name: install zabbix and dependencies
apt: name={{ item }} update_cache=yes cache_valid_time=3600
with_items:
- zabbix-server-pgsql
- zabbix-frontend-php
- php7.0-bcmath
- php7.0-xml
- php7.0-mbstring
-
update_cache=yes
でapt-get update
を事前に行うようにする - cacheの更新を毎回行うのは遅いため、
cache_valid_time
でcacheの有効時間を指定するようにする
リポジトリを追加する
リポジトリを追加したい場合は apt_repository
を使用します。
apt_repository - Add and remove APT repositories — Ansible Documentation
関連
[Ansible] Ansible使用方法まとめ - Qiita
参考
apt - Manages apt-packages — Ansible Documentation
Ansibleでapt-getのパッケージリストを更新してからインストールする - Qiita
Ansibleでのaptキャッシュの更新 - Qiita