Skip to content

Commit

Permalink
Remove deprecated first_available_file
Browse files Browse the repository at this point in the history
The first_available_file option on tasks has been deprecated in
Ansible 2, and will be removed in 2.2. Remove its use in the
config_template plugin similarly to its removal from the upstream
template plugin [0].

[0] ansible/ansible#17643

Change-Id: Icd4f70706979a3f59dd93f116d1c5ef96d66edbe
  • Loading branch information
jimmymccrory committed Oct 19, 2016
1 parent aa0cc3b commit 2f6cac2
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions action/_v2_config_template.py
Expand Up @@ -419,36 +419,25 @@ def _load_options_and_status(self, task_vars):
# Access to protected method is unavoidable in Ansible
searchpath = [self._loader._basedir]

faf = self._task.first_available_file
if faf:
task_file = task_vars.get('_original_file', None, 'templates')
source = self._get_first_available_file(faf, task_file)
if not source:
return False, dict(
failed=True,
msg="could not find src in first_available_file list"
)
if self._task._role:
file_path = self._task._role._role_path
searchpath.insert(1, C.DEFAULT_ROLES_PATH)
searchpath.insert(1, self._task._role._role_path)
else:
# Access to protected method is unavoidable in Ansible
if self._task._role:
file_path = self._task._role._role_path
searchpath.insert(1, C.DEFAULT_ROLES_PATH)
searchpath.insert(1, self._task._role._role_path)
else:
file_path = self._loader.get_basedir()
file_path = self._loader.get_basedir()

user_source = self._task.args.get('src')
if not user_source:
return False, dict(
failed=True,
msg="No user provided [ src ] was provided"
)
source = self._loader.path_dwim_relative(
file_path,
'templates',
user_source
user_source = self._task.args.get('src')
if not user_source:
return False, dict(
failed=True,
msg="No user provided [ src ] was provided"
)
searchpath.insert(1, os.path.dirname(source))
source = self._loader.path_dwim_relative(
file_path,
'templates',
user_source
)
searchpath.insert(1, os.path.dirname(source))

_dest = self._task.args.get('dest')
list_extend = self._task.args.get('list_extend')
Expand Down

0 comments on commit 2f6cac2

Please sign in to comment.