LoginSignup
17
18

More than 5 years have passed since last update.

自作Ansibleモジュールをライブラリ化するときのディレクトリ構成

Last updated at Posted at 2014-07-18

Best Practices — Ansible Documentationによると、Ansibleモジュールを自作した場合、./library/以下に置けば自動でロードされる様です。しかし、自動でロードされるのは一階層下までとなります。

./library/
├── my_module # ロードされる
└── hoge/
    ├── my_module # ロードされる
    └── fuga/
        └── my_module # ロードされない

つまり、自作モジュールをライブラリ化するときは、以下のようなディレクトリ構成にするとよさそうです。

my_ansible_modules/
├── README.md
├── LICENSE
├── module1
├── module2
└── test/
    ├── units/
    └── integration/
        ├── inventory.ini
        ├── library -> ../../ # プロジェクトルートへのシンボリックリンク
        ├── roles/
        │   ├── test_module1/
        │   │   └── tasks/
        │   │       └── main.yml
        │   └── test_module2/
        │       └── tasks/
        │           └── main.yml
        └── site.yml

こうしておけば、使用する側は外部ライブラリを./library/以下に置くだけで利用できます。

./
├── library/
│   └── my_ansible_modules/
├── inventory.ini
└── site.yml
site.yml
---
- hosts: all
  tasks:
    - module1: option1=value1 option2=value2
    - module2: option3=value3 option4=value4
17
18
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
17
18