Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
4a467f71
Commit
4a467f71
authored
Sep 22, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change touched -> touch for new file state, and cleaning up docs
parent
4d417401
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
library/files/file
+9
-8
No files found.
library/files/file
View file @
4a467f71
...
@@ -50,12 +50,13 @@ options:
...
@@ -50,12 +50,13 @@ options:
exist, see the M(copy) or M(template) module if you want that behavior.
exist, see the M(copy) or M(template) module if you want that behavior.
If C(link), the symbolic link will be created or changed. Use C(hard)
If C(link), the symbolic link will be created or changed. Use C(hard)
for hardlinks. If C(absent), directories will be recursively deleted,
for hardlinks. If C(absent), directories will be recursively deleted,
and files or symlinks will be unlinked. If C(touched), existing file and
and files or symlinks will be unlinked. If C(touch), an empty file will
directory will change file access and modification times, not existing
be created if the c(dest) does not exist, while an existing file or
file will be created.
directory will receive updated file access and modification times (similar
to the way `touch` works from the command line).
required: false
required: false
default: file
default: file
choices: [ file, link, directory, hard, touch
ed
, absent ]
choices: [ file, link, directory, hard, touch, absent ]
mode:
mode:
required: false
required: false
default: null
default: null
...
@@ -141,7 +142,7 @@ def main():
...
@@ -141,7 +142,7 @@ def main():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
argument_spec
=
dict
(
argument_spec
=
dict
(
state
=
dict
(
choices
=
[
'file'
,
'directory'
,
'link'
,
'hard'
,
'touch
ed
'
,
'absent'
],
default
=
'file'
),
state
=
dict
(
choices
=
[
'file'
,
'directory'
,
'link'
,
'hard'
,
'touch'
,
'absent'
],
default
=
'file'
),
path
=
dict
(
aliases
=
[
'dest'
,
'name'
],
required
=
True
),
path
=
dict
(
aliases
=
[
'dest'
,
'name'
],
required
=
True
),
recurse
=
dict
(
default
=
'no'
,
type
=
'bool'
),
recurse
=
dict
(
default
=
'no'
,
type
=
'bool'
),
force
=
dict
(
required
=
False
,
default
=
False
,
type
=
'bool'
),
force
=
dict
(
required
=
False
,
default
=
False
,
type
=
'bool'
),
...
@@ -225,7 +226,7 @@ def main():
...
@@ -225,7 +226,7 @@ def main():
module
.
exit_json
(
path
=
path
,
changed
=
True
)
module
.
exit_json
(
path
=
path
,
changed
=
True
)
if
prev_state
!=
'absent'
and
prev_state
!=
state
:
if
prev_state
!=
'absent'
and
prev_state
!=
state
:
if
not
(
force
and
prev_state
==
'file'
and
state
==
'link'
)
and
state
!=
'touch
ed
'
:
if
not
(
force
and
prev_state
==
'file'
and
state
==
'link'
)
and
state
!=
'touch'
:
module
.
fail_json
(
path
=
path
,
msg
=
'refusing to convert between
%
s and
%
s for
%
s'
%
(
prev_state
,
state
,
src
))
module
.
fail_json
(
path
=
path
,
msg
=
'refusing to convert between
%
s and
%
s for
%
s'
%
(
prev_state
,
state
,
src
))
if
prev_state
==
'absent'
and
state
==
'absent'
:
if
prev_state
==
'absent'
and
state
==
'absent'
:
...
@@ -309,7 +310,7 @@ def main():
...
@@ -309,7 +310,7 @@ def main():
changed
=
module
.
set_file_attributes_if_different
(
file_args
,
changed
)
changed
=
module
.
set_file_attributes_if_different
(
file_args
,
changed
)
module
.
exit_json
(
dest
=
path
,
src
=
src
,
changed
=
changed
)
module
.
exit_json
(
dest
=
path
,
src
=
src
,
changed
=
changed
)
elif
state
==
'touch
ed
'
:
elif
state
==
'touch'
:
if
module
.
check_mode
:
if
module
.
check_mode
:
module
.
exit_json
(
path
=
path
,
skipped
=
True
)
module
.
exit_json
(
path
=
path
,
skipped
=
True
)
...
@@ -324,7 +325,7 @@ def main():
...
@@ -324,7 +325,7 @@ def main():
try
:
try
:
open
(
path
,
'w'
)
.
close
()
open
(
path
,
'w'
)
.
close
()
except
OSError
,
e
:
except
OSError
,
e
:
module
.
fail_json
(
path
=
path
,
msg
=
'Error
while touching non-existing
target:
%
s'
%
str
(
e
))
module
.
fail_json
(
path
=
path
,
msg
=
'Error
, could not touch
target:
%
s'
%
str
(
e
))
module
.
set_file_attributes_if_different
(
file_args
,
True
)
module
.
set_file_attributes_if_different
(
file_args
,
True
)
module
.
exit_json
(
dest
=
path
,
changed
=
True
)
module
.
exit_json
(
dest
=
path
,
changed
=
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment