【问题标题】:ansible: pull data from remote repository and run another task if data changedansible:从远程存储库中提取数据并在数据更改时运行另一个任务
【发布时间】:2018-10-25 14:29:11
【问题描述】:

对于作业自动化,我需要从远程存储库中提取数据并在之后执行一些任务。但是只有在数据更改时才应该运行任务。

换句话说:只有在更改源时才从 repo 中提取源并重建应用程序

【问题讨论】:

    标签: git ansible


    【解决方案1】:
    - name: Get data from repo
      git:
        repo: "{{ repo }}"
        dest: ""{{ local_path }}""
        clone: yes
        force: yes
        version: "{{ branch }}"
      register: data_changed
    
    - name: build changes if changed
      shell: |
         bash -c "any shell script here"
      when: data_changed.before != data_changed.after
    

    when: data_changed.before != data_changed.after 仅当数据在第一个任务期间发生变化时为真

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多