ansible-facts

How to get the first element of a list from the output of setup module in Ansible?

天大地大妈咪最大 提交于 2019-11-27 05:23:50
I received the following data from the setup module: "ansible_nodename": "3d734bc2a391", "ansible_os_family": "RedHat", "ansible_pkg_mgr": "yum", "ansible_processor": [ "AuthenticAMD", "AMD PRO A10-8700B R6, 10 Compute Cores 4C+6G" ], "ansible_processor_cores": 1, "ansible_processor_count": 1, "ansible_processor_threads_per_core": 1, I want to retrieve the 1st value of ansible_processor and use it in a Jinja2 template. If I use {{ ansible_processor }} , it's giving me both values: "AuthenticAMD", "AMD PRO A10-8700B R6, 10 Compute Cores 4C+6G" But I want only the first one. To get first item of

Where can I get a list of Ansible pre-defined variables?

烈酒焚心 提交于 2019-11-26 22:28:25
问题 I see that Ansible provide some pre-defined variables that we can use in playbooks and template files. For example, the host ip address is ansible_eth0.ipv4.address. Googleing and searching the docs I cound't find a list of all available variables. Would someone list them for me? 回答1: Argh! From the FAQ: How do I see a list of all of the ansible_ variables? Ansible by default gathers “facts” about the machines under management, and these facts can be accessed in Playbooks and in templates. To