summaryrefslogtreecommitdiff
path: root/files/file.py
diff options
context:
space:
mode:
Diffstat (limited to 'files/file.py')
-rw-r--r--files/file.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/files/file.py b/files/file.py
index f19a9635..b7044ca2 100644
--- a/files/file.py
+++ b/files/file.py
@@ -88,21 +88,42 @@ options:
EXAMPLES = '''
# change file ownership, group and mode. When specifying mode using octal numbers, first digit should always be 0.
-- file: path=/etc/foo.conf owner=foo group=foo mode=0644
-- file: src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
-- file: src=/tmp/{{ item.src }} dest={{ item.dest }} state=link
+- file:
+ path: /etc/foo.conf
+ owner: foo
+ group: foo
+ mode: 0644
+- file:
+ src: /file/to/link/to
+ dest: /path/to/symlink
+ owner: foo
+ group: foo
+ state: link
+- file:
+ src: /tmp/{{ item.src }}
+ dest: "{{ item.dest }}"
+ state: link
with_items:
- { src: 'x', dest: 'y' }
- { src: 'z', dest: 'k' }
# touch a file, using symbolic modes to set the permissions (equivalent to 0644)
-- file: path=/etc/foo.conf state=touch mode="u=rw,g=r,o=r"
+- file:
+ path: /etc/foo.conf
+ state: touch
+ mode: "u=rw,g=r,o=r"
# touch the same file, but add/remove some permissions
-- file: path=/etc/foo.conf state=touch mode="u+rw,g-wx,o-rwx"
+- file:
+ path: /etc/foo.conf
+ state: touch
+ mode: "u+rw,g-wx,o-rwx"
# create a directory if it doesn't exist
-- file: path=/etc/some_directory state=directory mode=0755
+- file:
+ path: /etc/some_directory
+ state: directory
+ mode: 0755
'''
@@ -217,6 +238,7 @@ def main():
if follow and state == 'link':
# use the current target of the link as the source
src = to_native(os.path.realpath(b_path), errors='strict')
+ b_src = to_bytes(os.path.realpath(b_path), errors='strict')
else:
module.fail_json(msg='src and dest are required for creating links')