對於ansible來講,下載文件是一個很重要的課題,這是build或者deploy的第一步,一般來說因爲不一樣項目的差別,可能咱們的代碼包或者資源文件保存在於http,github,nexus,ftp,nas等等。git
- name: Copy file with owner and permissions copy: src: /srv/myfiles/foo.conf dest: /etc/foo.conf owner: foo group: foo mode: '0644'
- name: download war file get_url: url: "{{ https_url }}/start.war" dest: /tmp mode: 0644 force: yes validate_certs: no
- name: donwload docker rpm get_url: validate_certs: no url: https://github.com/raw/org_name/project/master/docker.rpm dest: /tmp/docker.rpm mode: 0755 force: yes headers: Authorization: token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
delegate_to: localhost
github
- name: donwload docker rpm get_url: validate_certs: no url: https://github.com/raw/org_name/project/master/docker.rpm dest: /tmp/docker.rpm mode: 0755 force: yes headers: Authorization: token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx delegate_to: localhost