Skip to content

Error using sudoers.included #6

Description

@brandentimm

I am experiencing errors with the sudoers.included state related to the 'sudoers' variable in the /etc/sudoers template. Here is my configuration:

In top.sls, sudoers is applied globally, and sudoers.included is applied to the host experiencing the error:
top.sls

base:
  '*':
    - sudoers
  'myhost':
    - sudoers.included

The pillar data for myhost is as follows:

sudoers:
  groups:
    itops: 'ALL=(ALL) ALL'
    sudo: 'ALL=(ALL) ALL'
  includedir: /etc/sudoers.d
  included_files:
    /etc/sudoers.d/git-salt:
      - users:
        - git: 'ALL= /usr/bin/salt-call'

However when salt is called, I receive the following error:

          ID: /etc/sudoers.d/git-salt
    Function: file.managed
      Result: False
     Comment: Unable to manage file: Jinja variable 'list object' has no attribute 'get'; line 18

              ---
              [...]
                  {%- set users = sudoers.get('users', {}) %}
                  {%- set groups = sudoers.get('groups', {}) %}
                {%- endif %}
                {%- set includedir = sudoers.get('includedir', '/etc/sudoers.d') -%}
              {%- else %}
                {%- set defaults = sudoers.get('defaults', []) %}    <======================
                {%- set users = sudoers.get('users', {}) %}
                {%- set groups = sudoers.get('groups', {}) %}
                {%- set includedir = sudoers.get('includedir', None) %}
              {%- endif %}
              {%- set aliases = sudoers.get('aliases', {}) %}
              [...]
              ---

From looking at the code, it seems that indeed sudoers is not initialized if the file is included, which it is from sudoers.included. sudoers.included does initialize sudoers from pillar, but I'm not sure how or if the context gets passed between the included file.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions