Skip to content

ansible dynamic inventory #14

@wtnb75

Description

@wtnb75

実行するとこんな感じのjsonが返ってくるコマンドがあると、便利である可能性がある。

{
  "grp1": {
    "hosts": [],
    "children": [
      "subgrp1"
    ]
  },
  "subgrp1": [
    "host01",
    "host02"
  ],
  "_meta": {
    "hostvars": {
      "host01": {
        "ansible_ssh_host": "1.2.3.4"
      },
      "host02": {
        "ansible_ssh_host": "1.2.3.5"
      }
    }
  }
}
# ansible.cfg
[defaults]
inventory = (コマンドへのパス)
  • ステータスでフィルタ
  • 出てくるIPアドレス(ansible_ssh_host)の選択方法
    • ネットワークを指定
    • v4 or v6
  • ホスト名は?
    • ラベル
    • サービスコード
  • グループ化の方法は?

インベントリファイルを生成してもいいが…

[grp1:children]
subgrp1

[subgrp1]
host01 ansible_ssh_host=1.2.3.4
host02 ansible_ssh_host=1.2.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions