Skip to content

Commit

Permalink
update nac_dc_validate to check if iac-validate is installed (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtarking authored Nov 8, 2024
1 parent 01e1575 commit 4bbffdb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions plugins/action/common/nac_dc_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@

from ansible.utils.display import Display
from ansible.plugins.action import ActionBase
from ansible.errors import AnsibleError

try:
import iac_validate.validator
from iac_validate.yaml import load_yaml_files
from iac_validate.cli.options import DEFAULT_SCHEMA
except ImportError as imp_exc:
IAC_VALIDATE_IMPORT_ERROR = imp_exc
else:
IAC_VALIDATE_IMPORT_ERROR = None

import iac_validate.validator
from iac_validate.yaml import load_yaml_files
from iac_validate.cli.options import DEFAULT_SCHEMA
import os

display = Display()
Expand All @@ -43,6 +50,9 @@ def run(self, tmp=None, task_vars=None):
results['msg'] = None
results['data'] = {}

if IAC_VALIDATE_IMPORT_ERROR:
raise AnsibleError('iac-validate not found and must be installed. Please pip install iac-validate.') from IAC_VALIDATE_IMPORT_ERROR

schema = self._task.args.get('schema')
rules = self._task.args.get('rules')
mdata = self._task.args.get('mdata')
Expand Down

0 comments on commit 4bbffdb

Please sign in to comment.