ansible wget then exec scripts => get_url equivalent

前端 未结 6 930
慢半拍i
慢半拍i 2020-12-09 09:00

I always wonder what is the good way to replace the following shell tasks using the \"ansible way\" (with get_url, etc.):

- name: I         


        
6条回答
  •  星月不相逢
    2020-12-09 09:14

    Note the: "force=yes", which will always download the script, overriding the old one. Also note the "changed_when", which you can refine per your case.

      - name: 'Download {{ helm.install_script_url }}'
        environment:
          http_proxy:  '{{proxy_env.http_proxy | default ("") }}'
          https_proxy: '{{proxy_env.https_proxy | default ("") }}'
          no_proxy:    '{{proxy_env.no_proxy | default ("") }}'
        get_url: url={{ helm.install_script_url | default ("") }} dest=/tmp/helm_install_script force=yes mode="0755"
        when: helm.install_script_url is defined
        tags:
        - helm_x
    
      - name: Run {{ helm.install_script_url }}
        environment:
          http_proxy:  '{{proxy_env.http_proxy | default ("") }}'
          https_proxy: '{{proxy_env.https_proxy | default ("") }}'
          no_proxy:    '{{proxy_env.no_proxy | default ("") }}'
        command: "/tmp/helm_install_script"
        register: command_result
        changed_when: "'is up-to-date' not in command_result.stdout"
        when: helm.install_script_url is defined
        args:
          chdir: /tmp/
        tags:
        - helm_x
    

提交回复
热议问题