Salt State Exception: OSError 2

Salt State Exception: OSError 2

01 August 2015

I was scratching my head on this one. A salt minion reported this in it's log file and some states were not applied to my Windows Virtual Machine.

2015-07-15 22:47:52,427 [salt.state       ][ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "salt/state.py", line 1379, in call
  File "c:\salt\var\cache\salt\minion\extmods\states\archive.py", line 96, in extracted
    file_result = __salt__['state.high'](data)
  File "salt/modules/state.py", line 172, in high
  File "salt/state.py", line 535, in __init__
  File "salt/state.py", line 552, in _gather_pillar
  File "salt/pillar/__init__.py", line 44, in get_pillar
  File "salt/pillar/__init__.py", line 58, in __init__
  File "salt/transport/__init__.py", line 24, in factory
  File "salt/transport/__init__.py", line 50, in __init__
  File "salt/crypt.py", line 519, in __init__
  File "salt/crypt.py", line 531, in __authenticate
  File "salt/crypt.py", line 363, in sign_in
  File "salt/crypt.py", line 242, in minion_sign_in_payload
  File "salt/utils/__init__.py", line 1166, in mkstemp
  File "tempfile.py", line 304, in mkstemp
  File "tempfile.py", line 239, in _mkstemp_inner
OSError: [Errno 2] No such file or directory: 'c:\\users\\buildu~1\\appdata\\local\\temp\\1\\tmpyllbfy'

It then dawned on me. I recently wrote a salt state to clean the NUnit shadowcache.

nunit_shadow_cache:
  file.absent:
    - name: 'C:/users/buildUser/appData/local/temp'

It looks as though it was removing all salt temp files causing the above error. I changed the path to delete the nunit20 folder in the temp folder.s

nunit_shadow_cache:
  file.absent:
    - name: 'C:/users/buildUser/appData/local/temp/nunit20'

Happy days!

SaltStack