salt icon indicating copy to clipboard operation
salt copied to clipboard

[salt-ssh] Custom pillar data present in pillar.items, but not in custom execution module through __pillar__ dictionary

Open adrianhj opened this issue 10 years ago • 9 comments

(Encountered in version 2015.8.3)

Hello!

I am running into an interesting issue using salt-ssh to execute custom modules relying on pillar data.

When querying for the target's pillar using: salt-ssh '*' pillar.items the custom pillar entries are present, however within a custom execution module the __pillar__ entry only contains the default set of master pillar entries, none of the custom entries.

Checking the pillar.json that is deployed via salt-ssh to the target in salt_state.tgz the full pillar is visible.

The custom module that I have resulted to testing with whilst attempting to debug is:

def test():
    return __pillar__

Has anyone ran into anything similar? I can find some open issues regarding salt-ssh and pillars but most of these seem to be in regards to failing to render the pillar at all.

adrianhj avatar Feb 03 '16 12:02 adrianhj

To add some more information, if I call my custom module from within a simple state wrapper:

pillar_test_state:
    module.run:
        - name: pillartest.test

The __pillar__ dictionary holds the full pillar with all my custom values.

adrianhj avatar Feb 03 '16 14:02 adrianhj

@adrianhj, thanks for the report. Do you know if this happens with normal minions as well?

jfindlay avatar Feb 04 '16 00:02 jfindlay

Testing against a master/minion setup the module outlined above works as intended (i.e. it returns the fully populated pillar).

--versions-report is as follows:

Salt Version:
           Salt: 2015.8.3

Dependency Versions:
         Jinja2: unknown
       M2Crypto: 0.20.2
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.5.0
         Python: 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.4.1
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: redhat 6.6 Santiago
        machine: x86_64
        release: 2.6.32-504.16.2.el6.x86_64
         system: Red Hat Enterprise Linux Server 6.6 Santiago

adrianhj avatar Feb 04 '16 08:02 adrianhj

@adrianhj, thanks for the confirmation.

jfindlay avatar Feb 05 '16 21:02 jfindlay

May be related to #28503.

jfindlay avatar Mar 07 '16 23:03 jfindlay

ZD-936

rickh563 avatar Sep 06 '16 23:09 rickh563

By experimenting with salt/client/ssh/__init__.py I was able to narrow this down a little bit. When run with salt-call, custom modules are loaded into the local context and are executed using run_wfunc(). Under salt-ssh functions are called using the method cmd.block():

def run(self, deploy_attempted=False):
    ...
    elif self.fun in self.wfuncs or self.mine:
        stdout, retcode = self.run_wfunc()
    else:
        stdout, stderr, retcode = self.cmd_block()

This second branch will execute the custom module from /tmp/.USER_XXXX_salt/running_data/var/cache/salt/minion/extmods/modules/ on the target machine. I don't yet see how to change the invocation of this module in order to include the pillar data.

eradman avatar Nov 21 '17 03:11 eradman

Some further details; cmd_block() ultimately runs salt_call in a subprocess on the target machine:

/var/tmp/.USER_XXXXXX_salt/salt-call --retcode-passthrough --local --metadata --out json -l quiet
    -c /var/tmp/.USER_XXXXXX_salt -- module.function

I just noticed that pillar.json is not deployed at all via salt-ssh. @adrianhj: is this file deployed in your environment?

eradman avatar Nov 22 '17 19:11 eradman

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Mar 17 '19 19:03 stale[bot]