Ansible使用find在其他剧本中搜索寄存器变量中的特定字符串

时间:2018-07-26 07:51:59

标签: ansible

我有2个剧本,我想从1个剧本访问其他的寄存器变量,然后使用find搜索特定的字符串。我目前正在使用Ansible 2.5.3。

- name: Status Checks in Samurai
  hosts: foo
  tasks:

    - name: telegraf Service Status
      shell: systemctl status telegraf
      register: teleg

- name: Status Checks in Samurai
  hosts: bar
  tasks:

- debug: msg="INSTALLED SYSTEM"
      when:
       - "{{ hostvars['samurai']['foundstat']['stdout']['find("active")] }} != -1"

我尝试了许多可能的方法来检查是否可以将.find与上次播放的寄存器变量一起使用。但找不到任何可行的方法。 有人可以帮忙吗? 我也尝试过:

"{{ hostvars.foo.teleg.stdout.find(\"active\") }}" != -1

0 个答案:

没有答案