【问题标题】:Issue with handler restarting service处理程序重新启动服务的问题
【发布时间】:2018-10-30 19:18:54
【问题描述】:

我遇到了一个问题,保加利亚的一个开发团队向我提供了去年秋天编码和构建的游戏服务。我为该平台拥有的唯一文档是一段视频,该视频显示了一位开发人员运行剧本来构建环境。该视频未显示正在使用的 ansible 版本。我正在尝试在 ubuntu 16.04 和 ansible 2.0.0.2 上运行剧本。我正在尝试执行以下操作:

- hosts: nler-example-nxx
  user: ubuntu
  tasks:
  - include: ../../templates/nler-nxx.yml
  - name: change nodes ip in nxx config
    replace:
     path: /www/nler-nxx/conf/nxx.properties
     regexp: '(\s+)nxx.defaultPeers=(.*)$'
     replace: '\1nxt.defaultPeers=52.202.223.114; 35.173.242.207; 34.238.136.137; 54.164.46.62; 54.86.17.225;'
    notify:
    - restart nxx service

  handlers:
  - name: restart nxx service
    become: yes
    systemd: name=nxx state=restarted

并得到这个错误:

错误!任务中未检测到任何操作

错误似乎出现在“/etc/ansible/playbook/niler/example/nxx.yml”中:第 15 行第 7 列,但可能 根据确切的语法问题,位于文件中的其他位置。

违规行似乎是:

handlers:
  - name: restart nxx service
    ^ here

在做一些研究时,我认为这是一个版本冲突问题,但无法确认他们使用的是什么版本。

【问题讨论】:

    标签: ansible yaml


    【解决方案1】:

    缩进错误。应该是:

    tasks:
      - include: ../../templates/nler-nxx.yml
    ...
    

    .

    handlers:
      - name: restart nxx service
    ...
    

    【讨论】:

      猜你喜欢
      • 2019-03-03
      • 1970-01-01
      • 2019-12-14
      • 2016-01-29
      • 1970-01-01
      • 2011-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多