Skip to content

Commit e97643a

Browse files
committed
[Path] Support "force" argument on path link
1 parent 0505854 commit e97643a

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

path/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Support "force" argument on path link, to create link even if the source does not exist
13+
1014
## [2.3.0] - 2026-01-02
1115

1216
### Added

path/plugins/action/path.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def run(self, tmp=None, task_vars=None):
2222
'content': {'type': 'str'},
2323
'file': {'type': 'path'},
2424
'template': {'type': 'path'},
25+
'force': {'type': 'bool'},
2526
'vars': {'type': 'dict', 'default': {}},
2627
'src': {'type': 'path'},
2728
'user': {'type': 'str'},
@@ -184,6 +185,7 @@ def run_link(self, args, task_vars):
184185
'path': args['path'],
185186
'src': args['src'],
186187
'state': 'link',
188+
'force': args['force'] if (args.get('force') is not None) else False,
187189
'owner': args['user'],
188190
'group': args['group'],
189191
},

path/tests/integration/targets/path/tasks/link.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
- { path: file, state: touch }
1414
paths:
1515
- { path: explicit_file, state: link, src: file }
16+
- { path: explicit_missing_file, state: link, src: missing_file }
1617
expected:
17-
- { path: explicit_file, exists: true, islnk: true, lnk_target: file }
18+
- { path: explicit_file, exists: true, islnk: true, lnk_target: file, readable: true }
19+
- { path: explicit_missing_file, exists: true, islnk: true, lnk_target: missing_file, readable: false }
1820
block:
1921

2022
- name: link | Prepare root
@@ -51,6 +53,7 @@
5153
- stats.results[index].stat.exists == expected[index].exists
5254
- stats.results[index].stat.islnk == expected[index].islnk
5355
- stats.results[index].stat.lnk_target == expected[index].lnk_target
56+
- stats.results[index].stat.readable == expected[index].readable
5457
loop: "{{ expected }}"
5558
loop_control:
5659
index_var: index

0 commit comments

Comments
 (0)