我想将 ansible fact 变量的值存储在其他变量中,并且还想检查 fact 变量是否为空
下面是我的代码,我可以在其中打印 ansible_local 事实变量的值,但我希望将该值存储在另一个变量中,比如 xyz。并且还想检查 ansible_local.sj.inventory.as_tag 变量值是否为空
- name: -> Apply common configuration to {{ target }} nodes
hosts: "{{ target }}"
gather_facts: True
user: root
pre_tasks:
- setup:
filter: ansible_local
tasks:
- action: debug msg="{{ ansible_local.sj.inventory.as_tag }}"
样品 O/P:
TASK: [debug msg="{{ansible_local.sj.inventory.as_tag}}"]
***********
Monday 09 May 2016 09:48:49 -0700 (0:00:01.375) 0:00:02.785
************
ok: [abcserver] => {
"msg": "abcd-123"