-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplaybook-copy.yml
45 lines (37 loc) · 1.3 KB
/
playbook-copy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
- hosts: all
become: true
become_user: root
become_method: sudo
vars:
file1_single_line: "abcdefghij1234567890"
file2_multi_lines: |
-----CUSTOM-KEY-----
5f9=UgdL(MiRx'1_$+P3
tBK.L{xHcxd{NtCy!Z&>
j42!n4gHF{M5OJNR#nA-
SAveX%C5XqLXPgVwu|+Y
W))rx3[>ekmUU^T`YsY2
{x&16)L]3TPfF]w;:vuU
>uOm|P_?`lq%-KXK(-CY
/R/#{xg`VM[BI)xDUWOm
*2Uy'nOhs(aRR?(cTA_p
J)o5qL0omq=hb`7Msj!2
---------EOF--------
tasks:
- name: example #1 one line to file
copy: content="{{ file1_single_line }}" dest=/root/file1_single_line.txt
- name: example #2 many lines to file
copy: content="{{ file2_multi_lines }}" dest=/root/file2_multi_lines.txt
- name: example #3 inside one server within plays
copy: remote_src=true src=/root/.profile dest=/tmp/.profile
- name: example #4 inside one server at separate play
copy: remote_src=true src=/root/profile dest=/home/admin/.profile
delegate_to: {{ server }}
- name: example #5 inside one server folder to folder and list
synchronize: src={{ item.src }} dest={{ item.dest }}
delegate_to: "{{ ansible_host }}"
with_items:
- { src: '/foler/from/1/', dest: '/folder/to/1/' }
- { src: '/foler/from/2/', dest: '/folder/to/2/' }
#TODO: example #6 - find + copy results