Ansible Module copy: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * http://docs.ansible.com/ansible/latest/copy_module.html =Internal= * Ansible Concepts")
 
Line 6: Line 6:


* [[Ansible_Concepts#copy|Ansible Concepts]]
* [[Ansible_Concepts#copy|Ansible Concepts]]
=Example=
<syntaxhighlight lang='yaml'>
- name: Copy .envrc script
  template:
    src: envrc
    dest: "{{ ansible_env.SOME_DIR }}/.envrc"
    mode: "u=rw,g=r,o=r"
</syntaxhighlight>
<syntaxhighlight lang='yaml'>
- name: Copy bashrc scripts
  template:
    src: "{{ item }}"
    dest: "{{rc_d}}"
    mode: "u=rwx,g=rx,o=rx"
  with_fileglob:
    - "*.sh"
</syntaxhighlight>
The files can be placed in:
* <role>/templates

Revision as of 18:10, 19 January 2021

External

Internal

Example

- name: Copy .envrc script
  template:
    src: envrc
    dest: "{{ ansible_env.SOME_DIR }}/.envrc"
    mode: "u=rw,g=r,o=r"
- name: Copy bashrc scripts
  template:
    src: "{{ item }}"
    dest: "{{rc_d}}"
    mode: "u=rwx,g=rx,o=rx"
  with_fileglob:
    - "*.sh"

The files can be placed in:

  • <role>/templates