LoginSignup
0
1

More than 5 years have passed since last update.

ansibleでパッケージインストールする_02(apt サンプル集)

Last updated at Posted at 2016-11-13

今日のお題:ansibleを用いてパッケージをインストールする際にオプションを設定する

実行環境

  • virtual box
  • ubuntu16.04

前提条件

  • サーバ側にansibleのインストールを行っていること。 ※ここでやりました。
  • クライアント側の設定とサーバ間のSSH設定を行う ※ここでやりました。
  • 本手順はサーバ/クライアント側すべて一般ユーザで実施します。この手順ではクライアント側のsudoersの設定で一般ユーザ側でsudoのnopass設定をしています。

目的

パッケージを1つインストールする方法は判ったが、実際使用する際には複数のパッケージをインストールしたり、要らないパッケージを消したり複数目的がある。
ここではそのうち必要になるだろうと思われるやり方を残していきたい。

ToDo

  • 複数パッケージインストール
  • パッケージアンインストール
  • apt-get update

サンプルソース

・複数パッケージインストール

install_multiple_package
- hosts: all
  tasks:
    - name: install multi packages
      apt: name={{item}}
      with_items:
          - cowsay
          - cmatrix

・パッケージアンインストール

remove_package
remove_package.yml
- hosts: all
  tasks:
    - name: remove cowsay package
      apt:
        name: cowsay
        state: absent

・apt-get_update

run_apt-get_update
- hosts: all
  tasks:
    - name: run apt-get update
      apt:
        update_cache: yes

参考リンク

0
1
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
0
1