LoginSignup
37
36

More than 5 years have passed since last update.

Ansible で RPM を扱う

Last updated at Posted at 2013-08-27

[2013-08-28 追記]

なんと,yum module で,RPM パッケージを指定してインストールすることができるそうです。
なので,下記の hack は必要ありません。
yamazaki-masahide さん,ご指摘ありがとうございました。

具体的な使用方法は,yamazaki-masahide さんのコメントを見ていただくか
本家ドキュメントの yum module の examples をご覧ください。


RPM を扱う module がなさそうだったので,書きました (書き捨てだけど)。

プロジェクトディレクトリの library/ ディレクトリ以下に rpm という名前でおいておけば,自動的に読み込んでくれます(Bundling Ansible Modules With Playbooks | Best Practices | AnsibleWorks)。

使い方は,以下のような感じです。

---
- tasks:
    - rpm: state=installed file=foo.rpm
    - rpm: state=removed file=foo.rpm
    - rpm: state=removed name=foo
    - rpm: state=installed name=failed_if_not_installed

RPM パッケージは,事前にリモート (target host) においてある必要があります。
(たぶん third-party Ansible module だと,ほぼこうせざるをえないと思う)

name ベースで存在チェック (やアンインストール) をする場合は,RPM パッケージをおいておく必要はありません。(例示の後者2つ)

実はすでにいい module あるよ,とか,
こうするほうが定石だよ,とか,
こう書くのはおかしい,とか,
情報があれば,お待ちしています。

37
36
6

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
37
36