Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jinja variable 'salt.utils.odict.OrderedDict object' has no attribute 'maxretry' #3

Closed
kartnico opened this issue Jun 23, 2019 · 4 comments

Comments

@kartnico
Copy link
Contributor

Hi,

When I try to use nut-formula, I have this error :

      ID: ups_conf
Function: file.managed
    Name: /etc/ups/ups.conf
  Result: False
 Comment: Unable to manage file: Jinja variable 'salt.utils.odict.OrderedDict object' has no attribute 'maxretry'
 Started: 12:00:41.313716
Duration: 118.689 ms
 Changes:   

My salt-minion version :

salt-call --versions-report
Salt Version:
       Salt: 2019.2.0

Dependency Versions:
       cffi: Not Installed
   cherrypy: Not Installed
   dateutil: Not Installed
  docker-py: Not Installed
      gitdb: Not Installed
  gitpython: Not Installed
      ioflo: Not Installed
     Jinja2: 2.7.2
    libgit2: Not Installed
    libnacl: Not Installed
   M2Crypto: Not Installed
       Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
 mysql-python: Not Installed
  pycparser: Not Installed
   pycrypto: 2.6.1
 pycryptodome: Not Installed
     pygit2: Not Installed
     Python: 2.7.5 (default, Apr  9 2019, 14:30:50)
 python-gnupg: Not Installed
     PyYAML: 3.10
      PyZMQ: 15.3.0
       RAET: Not Installed
      smmap: Not Installed
    timelib: Not Installed
    Tornado: 4.2.1
        ZMQ: 4.1.4

System Versions:
       dist: centos 7.6.1810 Core
     locale: UTF-8
    machine: x86_64
    release: 3.10.0-957.12.2.el7.x86_64
     system: Linux
    version: CentOS Linux 7.6.1810 Core

I have the error only for "ups_conf" state. All other states are "ok".

I tried also with "pillars" to change "maxretry" parameter, but I always have the error.
I also have the error for every parameters in "ups_config" dict.

Regards,

Nicolas

@noelmcloughlin
Copy link
Member

I think this is evaluating to False:

{% set ups_config = nut.server.ups if nut.server.ups is defined else {} %}

@kartnico
Copy link
Contributor Author

It is strange because state.show_sls give me :

ups_conf:
    ----------
    __env__:
        base
    __sls__:
        nut.server
    file:
        |_
          ----------
          name:
              /etc/ups/ups.conf
        |_
          ----------
          source:
              salt://nut/templates/ups-conf.jinja
        |_
          ----------
          context:
              ----------
              ups:
                  ----------
                  u'config':
                      u'ups.conf'
                  u'enabled':
                      True
                  u'maxretry':
                      3
                  u'retrydelay':
                      1
                  u'service':
                      u'nut-driver'
                  u'units':
                      ----------
        |_
          ----------
          template:
              jinja
        |_
          ----------
          mode:
              640
        |_
          ----------
          user:
              root
        |_
          ----------
          group:
              nut
        |_
          ----------
          require:
              |_
                ----------
                pkg:
                    nut_server
        |_
          ----------
          require_in:
              |_
                ----------
                service:
                    upsd_service
        |_
          ----------
          watch_in:
              |_
                ----------
                service:
                    upsd_service
        - managed
        |_
          ----------
          order:
              10002

@kartnico
Copy link
Contributor Author

Sorry, I must RTFM :) : https://docs.saltstack.com/en/develop/topics/releases/2019.2.0.html#non-backward-compatible-change-to-yaml-renderer

With "tojson" filter it works :

ups_conf:
file.managed:
  - name: {{ nut.config_dir }}/{{ nut.server.ups.config }}
  - source: salt://nut/templates/ups-conf.jinja
  - context:
      ups: {{ ups_config|tojson }}
  - template: jinja
  - mode: 640
  - user: root
  - group: nut
  - require:
    - pkg: nut_server
  - require_in:
    - service: upsd_service
  - watch_in:
    - service: upsd_service

I will try to send a PR.

Regards,

Nicolas

@myii
Copy link
Member

myii commented Jul 10, 2019

Closing since fixed in #4.

@myii myii closed this as completed Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants