Custom state and module = KeyError

156 views
Skip to first unread message

Peter L

unread,
Mar 25, 2015, 11:27:29 AM3/25/15
to salt-...@googlegroups.com
Hello,

I am having a problem with a custom state and module.  (Using Salt 2014.7.2 and salt-cloud to bootstrap a vm, which runs successfully.)

If I run "salt vm saltutil.sync_all" and then ssh into the vm I can see the custom state and module files in /var/cache/salt/minion/files and /var/cache/salt/minion/extmods.

However, when I run state.highstate the first time, the custom state fails to find the custom module.  I'm calling the custom module from the custom state with __state__['module.method'](args...) and the first time it fails with KeyError for 'module.method'.

When I run state.highstate a second time, it works fine.

I've searched this forum and the github issues but haven't found a match for my problem. Anybody have any ideas?

Thanks
~Peter

Wolodja Wentland

unread,
Mar 25, 2015, 11:59:52 AM3/25/15
to Salt-users

Does it work if you restart the minion after syncing? What about saltutil.refresh_modules?

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter L

unread,
Mar 25, 2015, 12:15:07 PM3/25/15
to salt-...@googlegroups.com
Doing either of those makes no difference. The files show up in the cache but so far, only running state.highstate twice seems to load the module into the minion.

Peter L

unread,
Mar 25, 2015, 1:45:31 PM3/25/15
to salt-...@googlegroups.com
Here's the problem:

My custom module depends on apt and pip installing a couple of things before it's loadable, so the minion won't load it until *after* those have been installed.  Hence state.highstate working the second time, since the deps have been installed and the modules refreshed.

I've changed my module to follow the pattern in here
https://github.com/saltstack/salt/blob/develop/salt/modules/aptpkg.py
so that it doesn't fail on ImportError

Stephen Spencer

unread,
Mar 29, 2015, 1:38:48 AM3/29/15
to salt-...@googlegroups.com

You might consider a simple reactor definition to take care of installing package and/or python module installation. You could key off of salt/cloud/*/created. Then your minion would be ready to go on your first highstate run.

-S

--
Reply all
Reply to author
Forward
0 new messages