Linux 变量包含某个单词时可执行的运行任务
我有一个ansible任务,它拥有所有elasticsearch角色Linux 变量包含某个单词时可执行的运行任务,linux,ansible,devops,Linux,Ansible,Devops,我有一个ansible任务,它拥有所有elasticsearch角色 - name: Get all roles shell: curl -u elastic:123456789 "192.168.2.13:9200/_security/role" register: roles 我只想在roles.stdout变量包含word时执行下面的任务 - name: register role (if doesn't exist) shell: curl -u ela
- name: Get all roles
shell: curl -u elastic:123456789 "192.168.2.13:9200/_security/role"
register: roles
我只想在roles.stdout变量包含word时执行下面的任务
- name: register role (if doesn't exist)
shell: curl -u elastic:123456789 "192.168.2.12:9200"
when: roles.stdout =="Uzbekistan"
那么我该怎么做呢?有很多方法可以做到这一点 使用
搜索
-名称:注册角色(如果不存在)
外壳:卷曲-u形弹性:123456789“192.168.2.12:9200”
当:roles.stdout为搜索('乌兹别克斯坦')时
在
-名称:注册角色(如果不存在)
外壳:卷曲-u形弹性:123456789“192.168.2.12:9200”
当:“‘乌兹别克斯坦’在roles.stdout中”
使用find
-名称:注册角色(如果不存在)
外壳:卷曲-u形弹性:123456789“192.168.2.12:9200”
时间:roles.stdout.find('乌兹别克斯坦')
角色是一个重要的角色。不要把它当作变量。Thanq Volodija!非常感谢。我会给你一道菜和一个新鲜的爆米花!