我想在其他variables中存储事实variables的值,也想检查variables是否为空
下面是我的代码,我可以打印ansible_local事实variables的值,但我想这个值存储在另一个variables,如xyz。 还想检查ansible_local.sj.inventory.as_tagvariables值是否为空
- 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"
你可以使用set_fact模块 。
这里是一个例子….
- name: -> Apply common configuration to {{ target }} nodes hosts: "{{ target }}" gather_facts: True user: root pre_tasks: - setup: filter: ansible_local - set_fact: tag: "{{ ansible_local.sj.inventory.as_tag }}" - debug: var: tag