首页 文章

ansible \ include of other yml不起作用

提问于
浏览
0

playbooks> all.yml tagger.yml configservice.yml

all.yml在其脚本中包含其他ymls,但它失败了 .

所有

---
  - name: build all dockers
    hosts: all  
    vars:      
        version1: "1.0"

    tasks:            

      - name: build all docker
        include: ./{{ item }}.yml
        with_items:
          - tagger

恶搞

---
  - name: build tagger docker 
    hosts: all 
    tasks:
    - name: some step !!!!!!
      command: echo 1

标记器的示例:

错误

任务[建造所有码头工具] ***************************************** *************致命:[localhost]:失败了! => {“failed”:true,“reason”:“在任务中未检测到任何操作 . 这通常表示拼写错误的模块名称或模块路径不正确 . \ n \ n错误似乎出现在'./Build/plays/ tagger.yml':第2行,第5列,但可能在文件的其他位置,具体取决于确切的语法问题 . \ n \ n违规行似乎是:\ n \ n --- \ n - name:build tagger docker \ n ^ here \ n \ n \ n错误似乎出现在'./Build/plays/tagger.yml'中:第2行第5列,但可能在文件的其他位置,具体取决于确切的语法问题 . \ n \ n违规行似乎是:\ n \ n --- \ n - name:build tagger docker \ n ^ here \ n“}}

似乎如果我从孩子那里解雇“任务:”,它就有效,但我不能这样做 - 我希望孩子独立 .

1 回答

  • 0

    实际上你的结构有点尴尬,你能做的就是把它作为一个角色

    roles / playbook_name / all.yml,tagger.yml configservice.yml

    现在在all.yml

    ---
      - name: build all dockers
        hosts: all  
        vars:      
            version1: "1.0"
      - name: call tagger
        host: all
        include: tagger.yml   #u can loop also with_items
    

    在标记中

    ---
      - name: some step !!!!!!
        command: echo 1
    

    你可以通过外面的包装来调用整个角色 .

相关问题