V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
css3
V2EX  ›  程序员

求助 ansible 如何在不同 host 执行不同 task 啊

  •  
  •   css3 · 2019-03-15 14:14:07 +08:00 · 1649 次点击
    这是一个创建于 1867 天前的主题,其中的信息可能已经有所发展或是发生改变。
    [host1]
    192.168.1.1
    [host1]
    192.168.1.2
    [host3]
    192.168.1.3

    想用分别给 host1,host2, host3 执行 task1, task2, task3 怎么怎么设置 playbook?
    6 条回复    2019-03-16 11:39:20 +08:00
    xabc
        1
    xabc  
       2019-03-15 14:19:57 +08:00
    你需要 saltstack
    coolloves
        2
    coolloves  
       2019-03-15 21:52:14 +08:00 via iPhone
    when 判断下?应该满足需求吧
    xcai
        3
    xcai  
       2019-03-16 08:05:40 +08:00 via Android
    target
    css3
        4
    css3  
    OP
       2019-03-16 08:18:11 +08:00 via iPhone
    @coolloves 怎么判断啊,whenwhen 读取不到 hosthost 吧?
    coolloves
        5
    coolloves  
       2019-03-16 08:31:26 +08:00
    @css3 获取的方式很多啊,
    -m setup 就可以看到有个 hostname 的变量啊,
    退一步,就算没有的话,自己加个变量,获取一下也是可以的呀
    css3
        6
    css3  
    OP
       2019-03-16 11:39:20 +08:00
    @coolloves 好的,多谢,我试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5938 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 02:22 · PVG 10:22 · LAX 19:22 · JFK 22:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.