--- - name: 检查 topic_name fail: msg: 需要在host定义 topic_name when: topic_name is undefined - name: 检查 consumer_id fail: msg: 需要在host定义 consumer_id when: consumer_id is undefined - name: 创建代码目录 file: path: /data/code state: directory - name: 创建日志目录 file: path: /data/log/xlegudata_consumer state: directory - name: 拷贝代码 unarchive: src: xlegudata_consumer.tar.gz dest: /data/code/ register: xlegudata_consumer_changed_result - name: 安装环境 shell: chdir: /data/code/xlegudata_consumer cmd: pipenv install Pipfile when: xlegudata_consumer_changed_result.changed - name: 消费进程 template: src: "xdata_consumer{{item}}.ini.j2" dest: "/etc/supervisord.d/xdata_consumer{{item}}.ini" loop: - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - name: 更新配置 shell: chdir: ~ cmd: supervisorctl update - name: 代码改变重启动 shell: chdir: ~ cmd: supervisorctl restart xdata_consumer when: xlegudata_consumer_changed_result.changed