LoginSignup
4
9

More than 5 years have passed since last update.

[Ansible][apt] Ansibleでのapt設定方法

Last updated at Posted at 2017-06-01

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=yesapt-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

4
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
9