salt: listen_in/watch_in and AttributeError: 'str' object has no attribute 'iteritems'

Tried to test/apply following scenario:

crontab-env:
  file.replace:
    - name: /etc/crontab
    - pattern: '^MAILTO=.*$'
    - repl: 'MAILTO=""'
    - prepend_if_not_found: True
    - listen_in:
      - cron-service

cron-service:
  service.running:
    - name: crond
    - enable: True

and got an error:

# salt 'minion1' state.highstate

minion1:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/salt/minion.py", line 1332, in _thread_return
        return_data = executor.execute()
      File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 28, in execute
        return self.func(*self.args, **self.kwargs)
      File "/usr/lib/python2.7/site-packages/salt/modules/state.py", line 722, in highstate
        whitelist=kwargs.get('whitelist')
      File "/usr/lib/python2.7/site-packages/salt/state.py", line 3274, in call_highstate
        return self.state.call_high(high)
      File "/usr/lib/python2.7/site-packages/salt/state.py", line 2280, in call_high
        ret = self.call_listen(chunks, ret)
      File "/usr/lib/python2.7/site-packages/salt/state.py", line 2182, in call_listen
        for key, val in six.iteritems(l_in):
      File "/usr/lib/python2.7/site-packages/salt/ext/six.py", line 583, in iteritems
        return iter(d.iteritems(**kw))
    AttributeError: 'str' object has no attribute 'iteritems'

Also it does not restart the service when I replace listen_in with watch_in, but the error disappears:

# salt 'minion1' state.highstate

minion1:
----------
          ID: crontab-env
    Function: file.replace
        Name: /etc/crontab
      Result: True
     Comment: Changes were made
     Started: 01:26:43.944672
    Duration: 38.07 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1,6 +1,6 @@
                   SHELL=/bin/bash
                   PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
                  -MAILTO="root"
                  +MAILTO=""

                   # For details see man 4 crontabs
----------
          ID: cron-service
    Function: service.running
        Name: crond
      Result: True
     Comment: The service crond is already running
     Started: 01:26:44.652253
    Duration: 104.541 ms
     Changes:   

Summary for minion1
------------
Succeeded: 2 (changed=1)
Failed:    0
------------
Total states run:     2
Total run time: 142.611 ms

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 1
  • Comments: 22 (11 by maintainers)

Most upvoted comments

This bug was verified in 3006.7. . . you can’t close it because “a lot has changed in almost 10 years”.

Are you closing ALL bugs every time there is a minor release and asking people to re-verify in the new minor release as a condition for re-opening?

Please take a minute and read the history of this bug.

The bug has been open for 8 years.

  • Reported in ver 2016.3.3 in Oct 2016
  • closed as stale
  • Confirmed as not fixed in ver 2018.3.3, in Nov 2018 (when duplicate bug #50682 filed)
  • assigned to 5 different developers
  • closed as stale
  • Confirmed as not fixed in ver 3005.1 in Mar 2023
  • closed as stale
  • Confirmed as not fixed in ver 3006.1 in Oct 2023
  • Confirmed as not fixed in ver 3006.7 in Aug 1, 2024
  • Developer demands report against 3006.9 because “A lot has changed in 10 years” Aug 1, 2024
  • closed as “unresponsive” Aug 14, 2024