-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook-file03.yml
More file actions
25 lines (22 loc) · 856 Bytes
/
playbook-file03.yml
File metadata and controls
25 lines (22 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
- name: A playbook showing the file module
hosts: planetexpress
gather_facts: yes # very important to gather_facts in this example
connection: ssh # default connection type, ssh.py
tasks:
- name: Create directory where Space Station documents will reside
become_user: root
become: true
file:
# the var "fileuser" is a host variable
path: "/home/{{ fileuser }}/station_docs/"
state: directory
owner: "{{ fileuser }}"
group: "{{ fileuser }}"
mode: "0755"
- name: Copy content into a file with the year-mo-day
copy:
# the var "fileuser" is a host variable
# ansible_date_time.date is defined by gather_facts
dest: "/home/{{ fileuser }}/station_docs/navdata-{{ ansible_date_time.date }}.txt"
content: "Earth\nMars\nSaturn\nEuropa\n"