salt icon indicating copy to clipboard operation
salt copied to clipboard

Passing arguments to sls file from orchastration.

Open ronak2303 opened this issue 5 years ago • 1 comments

Description of Issue

i am trying to pass arguments from orchestration to sls file. but when i try to do so i am getting

failed: Jinja variable 'salt.utils.context.NamespacedDictWrapper object' has no attribute 'login' i am trying to pass my sls file with pillar and running well when i run i with state.apply. but when i try to run it with via orchestration i run in to an error.

Setup

init file. `{% set target_minion = salt'pillar.get' %} {% set login = salt'pillar.get' %} {% set pass = salt'pillar.get' %} {% set sapass = salt'pillar.get' %} {% set inputfile = salt'pillar.get' %}

install python dependencies: salt.state: - tgt: {{ target_minion }} - sls: - {{ slspath }}.SQLProvision - pillar: login: {{ login }} pass: {{ pass }} sapass: {{ sapass }} inputfile: {{ inputfile }}`

SQLProvision.sls `run SQL setup: cmd.run:

  • name: python /home/SQLInstall/sqlsetup/main.py {{ pillar['login'] }} {{ pillar['pass'] }} {{ pillar['sapass'] }} {{ pillar['inputfile'] }}
  • hide_output: false `

Steps to Reproduce Issue

salt-run -l debug state.orchestrate sqlprovision pillar='{"target":"wh-1c385b6305", "login": "cccc", "pass": "9WJVpFpp", "sapass": "9WJVpFpp", "inputfile": "/home/SQLInstall/linux_gss_inputfile.txt"}' [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/salt-api.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/salt-api.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: wh-140a786872.svr.us.jpmchase.net [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] Configuration file path: /etc/salt/master [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [DEBUG ] LazyLoaded state.orchestrate [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf' [DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: wh-140a786872.svr.us.jpmchase.net [DEBUG ] Grains refresh requested. Refreshing grains. [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/salt-api.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/salt-api.conf [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Sending event: tag = salt/run/20201230195643073922/new; data = {'fun': 'runner.state.orchestrate', 'jid': '20201230195643073922', 'user': 'root', 'fun_args': ['sqlprovision', {'pillar': {'target': 'wh-1c385b6305', 'login': 'cccc', 'pass': '9WJVpFpp', 'sapass': '9WJVpFpp', 'inputfile': '/home/SQLInstall/linux_gss_inputfile.txt'}, 'orchestration_jid': '20201230195643073922'}], '_stamp': '2020-12-30T19:56:45.594781'} [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf' [DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: wh-140a786872.svr.us.jpmchase.net [DEBUG ] Grains refresh requested. Refreshing grains. [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/salt-api.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/salt-api.conf [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] LazyLoaded state.sls [DEBUG ] LazyLoaded saltutil.is_running [DEBUG ] LazyLoaded grains.get [DEBUG ] LazyLoaded config.get [DEBUG ] key: test, ret: _|- [DEBUG ] LazyLoaded roots.envs [DEBUG ] Could not LazyLoad roots.init: 'roots.init' is not available. [DEBUG ] Updating roots fileserver cache [DEBUG ] Gathering pillar data for state run [DEBUG ] Determining pillar cache [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] compile template: /srv/pillar/top.sls [DEBUG ] Jinja search path: ['/srv/pillar', '/srv/spm/pillar'] [PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'jinja' renderer: 0.012694120407104492 [DEBUG ] Rendered data from file: /srv/pillar/top.sls: base: '*': - InputFilePath

[DEBUG ] Results of YAML rendering: OrderedDict([('base', OrderedDict([('', ['InputFilePath'])]))]) [PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'yaml' renderer: 0.00034999847412109375 [DEBUG ] LazyLoaded confirm_top.confirm_top [DEBUG ] LazyLoaded compound_match.match [DEBUG ] compound_match: wh-140a786872.svr.us.jpmchase.net_master ? * [DEBUG ] LazyLoaded glob_match.match [DEBUG ] compound_match wh-140a786872.svr.us.jpmchase.net_master ? "" => "True" [DEBUG ] compile template: /srv/pillar/InputFilePath.sls [DEBUG ] Jinja search path: ['/srv/pillar', '/srv/spm/pillar'] [PROFILE ] Time (in seconds) to render '/srv/pillar/InputFilePath.sls' using 'jinja' renderer: 0.0006568431854248047 [DEBUG ] Rendered data from file: /srv/pillar/InputFilePath.sls:

Set path to input file to be stored on Pillar

inputfile: "/home/SQLInstall/linux_gss_inputfile.txt"

[DEBUG ] Results of YAML rendering: OrderedDict([('inputfile', '/home/SQLInstall/linux_gss_inputfile.txt')]) [PROFILE ] Time (in seconds) to render '/srv/pillar/InputFilePath.sls' using 'yaml' renderer: 0.00020074844360351562 [DEBUG ] Finished gathering pillar data for state run [INFO ] Loading fresh modules for state activity [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] Could not find file 'salt://sqlprovision.sls' in saltenv 'base' [DEBUG ] In saltenv 'base', looking at rel_path 'sqlprovision/init.sls' to resolve 'salt://sqlprovision/init.sls' [DEBUG ] In saltenv 'base', ** considering ** path '/var/cache/salt/master/files/base/sqlprovision/init.sls' to resolve 'salt://sqlprovision/init.sls' [DEBUG ] Fetching file from saltenv 'base', ** attempting ** 'salt://sqlprovision/init.sls' [DEBUG ] No dest file found [INFO ] Fetching file from saltenv 'base', ** done ** 'sqlprovision/init.sls' [DEBUG ] compile template: /var/cache/salt/master/files/base/sqlprovision/init.sls [DEBUG ] Jinja search path: ['/var/cache/salt/master/files/base'] [DEBUG ] LazyLoaded roots.envs [DEBUG ] Could not LazyLoad roots.init: 'roots.init' is not available. [DEBUG ] LazyLoaded pillar.get [PROFILE ] Time (in seconds) to render '/var/cache/salt/master/files/base/sqlprovision/init.sls' using 'jinja' renderer: 0.026216506958007812 [DEBUG ] Rendered data from file: /var/cache/salt/master/files/base/sqlprovision/init.sls:

install python dependencies: salt.state: - tgt: wh-1c385b6305 - sls: - sqlprovision.SQLProvision - pillar: login: cccccc pass: 9WJVpFpp sapass: 9WJVpFpp inputfile: /home/SQLInstall/linux_gss_inputfile.txt

run minion restart 1: salt.state: - tgt: wh-1c385b6305 - sls: - sqlprovision.minion_restart

wait for minion to restart 1: salt.wait_for_event: - name: salt/minion/*/start - id_list: - wh-1c385b6305 - require: - salt: run minion restart 1

[DEBUG ] Results of YAML rendering: OrderedDict([('install python dependencies', OrderedDict([('salt.state', [OrderedDict([('tgt', 'wh-1c385b6305')]), OrderedDict([('sls', ['sqlprovision.SQLProvision'])]), OrderedDict([('pillar', None), ('login', 'ccccc'), ('pass', '9WJVpFpp'), ('sapass', '9WJVpFpp'), ('inputfile', '/home/SQLInstall/linux_gss_inputfile.txt')])])])), ('run minion restart 1', OrderedDict([('salt.state', [OrderedDict([('tgt', 'wh-1c385b6305')]), OrderedDict([('sls', ['sqlprovision.minion_restart'])])])])), ('wait for minion to restart 1', OrderedDict([('salt.wait_for_event', [OrderedDict([('name', 'salt/minion//start')]), OrderedDict([('id_list', ['wh-1c385b6305'])]), OrderedDict([('require', [OrderedDict([('salt', 'run minion restart 1')])])])])]))]) [PROFILE ] Time (in seconds) to render '/var/cache/salt/master/files/base/sqlprovision/init.sls' using 'yaml' renderer: 0.0006175041198730469 [DEBUG ] LazyLoaded config.option [DEBUG ] LazyLoaded salt.state [INFO ] Running state [install python dependencies] at time 19:56:46.254261 [INFO ] Executing state salt.state for [install python dependencies] [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Sending event: tag = salt/run/20201230195643073922/args; data = {'type': 'state', 'tgt': 'wh-1c385b6305', 'name': 'install python dependencies', 'args': {'arg': ['sqlprovision.SQLProvision'], 'kwarg': {'queue': False, 'concurrent': False}, 'ret': '', 'timeout': None, 'tgt_type': 'glob', 'ssh': False, 'expect_minions': True}, 'stamp': '2020-12-30T19:56:46.256245'} [DEBUG ] Closing IPCMessageClient instance [DEBUG ] LazyLoaded saltutil.cmd [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/salt-api.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/salt-api.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: wh-140a786872.svr.us.jpmchase.net [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'wh-140a786872.svr.us.jpmchase.net_master', 'tcp://127.0.0.1:4506', 'clear') [DEBUG ] Connecting the Minion to the Master URI (for the return server): tcp://127.0.0.1:4506 [DEBUG ] Trying to connect to: tcp://127.0.0.1:4506 [DEBUG ] Closing AsyncZeroMQReqChannel instance [DEBUG ] LazyLoaded local_cache.get_load [DEBUG ] Reading minion list from /var/cache/salt/master/jobs/69/03dfb4c61c684b97c245902e3dc4508cdc97ae0432649c4cc5ee22a6eac53c/.minions.p [DEBUG ] get_iter_returns for jid 20201230195646311634 sent to {'wh-1c385b6305'} will timeout at 19:56:51.317016 [DEBUG ] jid 20201230195646311634 return from wh-1c385b6305 [DEBUG ] jid 20201230195646311634 found all minions {'wh-1c385b6305'} [DEBUG ] Closing IPCMessageSubscriber instance [DEBUG ] LazyLoaded state.check_result [ERROR ] {'out': 'highstate', 'ret': {'wh-1c385b6305': ["Rendering SLS 'base:sqlprovision.SQLProvision' failed: Jinja variable 'salt.utils.context.NamespacedDictWrapper object' has no attribute 'login'"]}} [INFO ] Completed state [install python dependencies] at time 19:56:46.847219 (duration_in_ms=592.958) [INFO ] Running state [run minion restart 1] at time 19:56:46.847406 [INFO ] Executing state salt.state for [run minion restart 1] [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Sending event: tag = salt/run/20201230195643073922/args; data = {'type': 'state', 'tgt': 'wh-1c385b6305', 'name': 'run minion restart 1', 'args': {'arg': ['sqlprovision.minion_restart'], 'kwarg': {'queue': False, 'concurrent': False}, 'ret': '', 'timeout': None, 'tgt_type': 'glob', 'ssh': False, 'expect_minions': True}, 'stamp': '2020-12-30T19:56:46.849026'} [DEBUG ] Closing IPCMessageClient instance [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Including configuration from '/etc/salt/master.d/salt-api.conf' [DEBUG ] Reading configuration from /etc/salt/master.d/salt-api.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: wh-140a786872.svr.us.jpmchase.net [DEBUG ] Missing configuration file: /root/.saltrc [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'wh-140a786872.svr.us.jpmchase.net_master', 'tcp://127.0.0.1:4506', 'clear') [DEBUG ] Connecting the Minion to the Master URI (for the return server): tcp://127.0.0.1:4506 [DEBUG ] Trying to connect to: tcp://127.0.0.1:4506 [DEBUG ] Closing AsyncZeroMQReqChannel instance [DEBUG ] LazyLoaded local_cache.get_load [DEBUG ] Reading minion list from /var/cache/salt/master/jobs/8e/9efc021f3425c5ccb90a2f84a02317eadc8a11b8087eefc68f6ab8d149db86/.minions.p [DEBUG ] get_iter_returns for jid 20201230195646896923 sent to {'wh-1c385b6305'} will timeout at 19:56:51.902082 [DEBUG ] jid 20201230195646896923 return from wh-1c385b6305 [DEBUG ] jid 20201230195646896923 found all minions {'wh-1c385b6305'} [DEBUG ] Closing IPCMessageSubscriber instance [INFO ] {'out': 'highstate', 'ret': {'wh-1c385b6305': {'cmd|-have a minion restart itself|-sleep 30 && salt-call --local service.restart salt-minion --out-file /dev/null _|-run': {'name': 'sleep 30 && salt-call --local service.restart salt-minion --out-file /dev/null ', 'changes': {'pid': 32208, 'retcode': None, 'stdout': '', 'stderr': ''}, 'result': True, 'comment': 'Command "sleep 30 && salt-call --local service.restart salt-minion --out-file /dev/null " run', 'sls': 'sqlprovision.minion_restart', 'run_num': 0, 'start_time': '19:56:47.207758', 'duration': 8.268, 'id': 'have a minion restart itself'}}}} [INFO ] Completed state [run minion restart 1] at time 19:56:47.325716 (duration_in_ms=478.31) [INFO ] Running state [salt/minion//start] at time 19:56:47.326096 [INFO ] Executing state salt.wait_for_event for [salt/minion//start] [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] wait_for_event: Skipping unmatched event 'salt/auth' [DEBUG ] wait_for_event: Skipping unmatched event 'minion/refresh/wh-1c385b6305' [DEBUG ] wait_for_event: Skipping unmatched event 'minion_start' [DEBUG ] wait_for_event: Event identifier 'wh-1c385b6305' removed from id_list; 0 items remaining. [INFO ] {'minions_seen': ['wh-1c385b6305']} [INFO ] Completed state [salt/minion//start] at time 19:57:25.169851 (duration_in_ms=37843.753) [DEBUG ] File /var/cache/salt/master/accumulator/140266385599288 does not exist, no need to cleanup [DEBUG ] LazyLoaded state.check_result [DEBUG ] LazyLoaded state.check_result [DEBUG ] LazyLoaded local_cache.prep_jid [DEBUG ] Sending event: tag = salt/run/20201230195643073922/ret; data = {'fun': 'runner.state.orchestrate', 'jid': '20201230195643073922', 'user': 'root', 'fun_args': ['sqlprovision', {'pillar': {'target': 'wh-1c385b6305', 'login': 'ccc', 'pass': '9WJVpFpp', 'sapass': '9WJVpFpp', 'inputfile': '/home/SQLInstall/linux_gss_inputfile.txt'}, 'orchestration_jid': '20201230195643073922'}], 'stamp': '2020-12-30T19:57:25.172976', 'return': {'data': {'wh-140a786872.svr.us.jpmchase.net_master': {'salt|-install python dependencies_|-install python dependencies_|-state': {'name': 'install python dependencies', 'changes': {'out': 'highstate', 'ret': {'wh-1c385b6305': ["Rendering SLS 'base:sqlprovision.SQLProvision' failed: Jinja variable 'salt.utils.context.NamespacedDictWrapper object' has no attribute 'login'"]}}, 'comment': 'Run failed on minions: wh-1c385b6305', 'result': False, 'jid': '20201230195646311634', 'sls': 'sqlprovision', 'run_num': 0, 'start_time': '19:56:46.254261', 'duration': 592.958, 'id': 'install python dependencies'}, 'salt_|-run minion restart 1_|-run minion restart 1_|-state': {'name': 'run minion restart 1', 'changes': {'out': 'highstate', 'ret': {'wh-1c385b6305': {'cmd_|-have a minion restart itself_|-sleep 30 && salt-call --local service.restart salt-minion --out-file /dev/null |-run': {'name': 'sleep 30 && salt-call --local service.restart salt-minion --out-file /dev/null ', 'changes': {'pid': 32208, 'retcode': None, 'stdout': '', 'stderr': ''}, 'result': True, 'comment': 'Command "sleep 30 && salt-call --local service.restart salt-minion --out-file /dev/null " run', 'sls': 'sqlprovision.minion_restart', 'run_num': 0, 'start_time': '19:56:47.207758', 'duration': 8.268, 'id': 'have a minion restart itself'}}}}, 'comment': 'States ran successfully. Updating wh-1c385b6305.', 'result': True, 'jid': '20201230195646896923', 'sls': 'sqlprovision', 'run_num': 1, 'start_time': '19:56:46.847406', 'duration': 478.31, 'id': 'run minion restart 1'}, 'salt|-wait for minion to restart 1_|-salt/minion//start_|-wait_for_event': {'name': 'salt/minion//start', 'changes': {'minions_seen': ['wh-1c385b6305']}, 'comment': 'All events seen in 37.84255075454712 seconds.', 'result': True, 'sls': 'sqlprovision', 'run_num': 2, 'start_time': '19:56:47.326098', 'duration': 37843.753, 'id': 'wait for minion to restart 1'}}}, 'outputter': 'highstate', 'retcode': 1}, 'success': False} [DEBUG ] Closing IPCMessageSubscriber instance [DEBUG ] LazyLoaded highstate.output [DEBUG ] LazyLoaded nested.output [DEBUG ] LazyLoaded nested.output wh-140a786872.svr.us.jpmchase.net_master:

      ID: install python dependencies
Function: salt.state
  Result: False
 Comment: Run failed on minions: wh-1c385b6305
 Started: 19:56:46.254261
Duration: 592.958 ms
 Changes:
          wh-1c385b6305:
              Data failed to compile:
          ----------
              Rendering SLS 'base:sqlprovision.SQLProvision' failed: Jinja variable 'salt.utils.context.NamespacedDictWrapper object' has no attribute 'login'

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) Salt Version: Salt: 2019.2.7

Dependency Versions: cffi: 1.9.1 cherrypy: unknown dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.11.1 libgit2: Not Installed libnacl: Not Installed M2Crypto: 0.35.2 Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.5.6 mysql-python: Not Installed pycparser: 2.14 pycrypto: Not Installed pycryptodome: Not Installed pygit2: Not Installed Python: 3.6.8 (default, Aug 13 2020, 07:46:32) python-gnupg: Not Installed PyYAML: 3.13 PyZMQ: 15.3.0 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.4.2 ZMQ: 4.1.4

System Versions: dist: redhat 7.7 Maipo locale: UTF-8 machine: x86_64 release: 3.10.0-1062.18.1.el7.x86_64 system: Linux version: Red Hat Enterprise Linux Server 7.7 Maipo

ronak2303 avatar Dec 30 '20 20:12 ronak2303

seems like using missed spelled statename

ronak2303 avatar Dec 30 '20 20:12 ronak2303