Skip to content

Commit

Permalink
Made no-same-owner recognize fully qualified modules
Browse files Browse the repository at this point in the history
Related: ansible#1908
  • Loading branch information
ssbarnea committed Feb 18, 2022
1 parent e3e8562 commit 554ab2d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/ansiblelint/rules/NoSameOwnerRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ def handle_playlist(self, lintable: Lintable, playlist: Any) -> List[MatchError]
def handle_task(self, lintable: Lintable, task: Any) -> List[MatchError]:
"""Process a task."""
results = []
if "synchronize" in task:
if self.handle_synchronize(task):
action = [e for e in ("synchronize", "ansible.posix.synchronize") if e in task]
if action:
if self.handle_synchronize(task, action[0]):
print(task)
results.append(
self.create_matcherror(
filename=lintable, linenumber=task[LINE_NUMBER_KEY]
)
)
elif "unarchive" in task:
if self.handle_unarchive(task):
action = [e for e in ("unarchive", "ansible.builtin.unarchive") if e in task]
if action:
if self.handle_unarchive(task, action[0]):
results.append(
self.create_matcherror(
filename=lintable, linenumber=task[LINE_NUMBER_KEY]
Expand All @@ -73,22 +75,22 @@ def handle_task(self, lintable: Lintable, task: Any) -> List[MatchError]:
return results

@staticmethod
def handle_synchronize(task: Any) -> bool:
def handle_synchronize(task: Any, action: str) -> bool:
"""Process a synchronize task."""
if task.get("delegate_to") is not None:
return False

synchronize = task["synchronize"]
synchronize = task[action]
archive = synchronize.get("archive", True)

if synchronize.get("owner", archive) or synchronize.get("group", archive):
return True
return False

@staticmethod
def handle_unarchive(task: Any) -> bool:
def handle_unarchive(task: Any, action: str) -> bool:
"""Process unarchive task."""
unarchive = task["unarchive"]
unarchive = task[action]
delegate_to = task.get("delegate_to")

if (
Expand Down

0 comments on commit 554ab2d

Please sign in to comment.