Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
$ ansible-playbook gather_facts.yml

PLAY [gather facts] ************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Print all available facts] ***********************************************
ok: [localhost] => {
    "ansible_facts": {
        "all_ipv4_addresses": [
            p192.168.187.200"
        ],
        "all_ipv6_addresses": [
            "fe80::b76f:65c7:7205:dcc2"
        ],
        "ansible_local": {},
        "apparmor": {
            "status": "disabled"
        },

setup 모듈

ansible 은 playbook 실행시 자동으로 fact 를 수집하고 저장합니다.

만약 playbook 을 작성하지 않고 간단하게 fact 만 출력하려면 builtin 모듈인 setup 을 사용하면 됩니다.

Code Block
languagebash
$ ansible -m setup localhost


특정 fact 만 알고 싶을 경우 pipe 로 연결해서 grep 을 실행하면 됩니다.

Code Block
languagebash
$ ansible -m setup localhost |  grep distribution

 "ansible_distribution": "CentOS",
        "ansible_distribution_file_parsed": true,
        "ansible_distribution_file_path": "/etc/redhat-release",
        "ansible_distribution_file_variety": "RedHat",
        "ansible_distribution_major_version": "8",
        "ansible_distribution_release": "Core",
        "ansible_distribution_version": "8.0",


같이 보기

Ref