我是新来的。什么是正确的调用ansible变量?下面是3个剧本,剧本1使用“{ ansible_hostname }}",但是,剧本2和3直接使用"ansible_hostname”。有什么不同吗?谢谢!
剧本1:
tasks:
- name: Jinja2 template
template:
src: template.j2
dest: "/tmp/{{ ansible_hostname }}_template.out"
trim_blocks: true
mode: 0644剧本2:
tasks:
- name: Ansible Jinja2 if
debug:
msg: >
--== Ansible Jinja2 if statement ==--
{# If the hostname is ubuntu-c, include a message -#}
{% if ansible_hostname == "ubuntu-c" -%}
This is ubuntu-c
{% endif %}剧本3:
tasks:
- name: Exploring register
command: hostname -s
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version | int >= 8
register: command_registerhttps://stackoverflow.com/questions/72543870
复制相似问题