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

[BUG] lgpo.set fails to set bool elements when mixed in with enums in 3005.1 #63473

Closed
2 tasks
rudeb0t opened this issue Jan 12, 2023 · 8 comments · Fixed by #64414
Closed
2 tasks

[BUG] lgpo.set fails to set bool elements when mixed in with enums in 3005.1 #63473

rudeb0t opened this issue Jan 12, 2023 · 8 comments · Fixed by #64414
Assignees
Labels
Bug broken, incorrect, or confusing behavior Chlorine v3007.0 lgpo State-Module Windows

Comments

@rudeb0t
Copy link

rudeb0t commented Jan 12, 2023

Description

When using lgpo.set to set a mix of enum and bool elements only the enum elements are set. This was working properly in Salt 3004.1. For example:

configure_automatic_updates:
  lgpo.set:
    - computer_policy:
        'Configure Automatic Updates':
          'Configure automatic updating': 4 - Auto download and schedule the install
          'Install during automatic maintenance': False
          'Scheduled install day': 0 - Every day
          'Scheduled install time': 03:00
          'Install updates for other Microsoft products': False
          'Every week': False
          'First week of the month': False
          'Second week of the month': False
          'Third week of the month': False
          'Fourth week of the month': False

Would result in:

          ID: configure_automatic_updates                                                                                
    Function: lgpo.set                                                                                                                                                                        
      Result: True                                                                                                                                                                            
     Comment: The following policies changed:                                                                                                                                                 
              Configure Automatic Updates                                                                                                                                                     
     Started: 08:10:59.720845                                                                                                                                                                 
    Duration: 1141.429 ms                                                                                                                                                                     
     Changes:                                                                                                                                                                                 
              ----------                                                                                                                                                                      
              new:                                                                                                                                                                            
                  ----------                                                                                                                                                                  
                  Computer Configuration:                                                                                                                                                     
                      ----------                                                                                                                                                              
                      Configure Automatic Updates:                                                                                                                                            
                          ----------                                                                                                                                                          
                          Configure automatic updating:                                                                                                                                       
                              4 - Auto download and schedule the install                                                                                                                      
                          Scheduled install day:                                                                                                                                              
                              0 - Every day                                                                                                                                                   
                          Scheduled install time:                                                                                                                                             
                              03:00                                                                                                                                                           
              old:                                                                                                                                                                            
                  ----------                                                                                                                                                                  
                  Computer Configuration:                                                                                                                                                     
                      ----------                                                                                                                                                              
                      Configure Automatic Updates:                                                                                                                                            
                          Not Configured                                                                                                                                                      

Setup

  • Virtualbox Windows Server 2016
  • Salt Version 3005.1

Steps to Reproduce the behavior

SLS file configure_automatic_updates.sls:

configure_automatic_updates:
  lgpo.set:
    - computer_policy:
        'Configure Automatic Updates':
          'Configure automatic updating': 4 - Auto download and schedule the install
          'Install during automatic maintenance': False
          'Scheduled install day': 0 - Every day
          'Scheduled install time': 03:00
          'Install updates for other Microsoft products': False
          'Every week': False
          'First week of the month': False
          'Second week of the month': False
          'Third week of the month': False
          'Fourth week of the month': False

salt 'window-minions.*' state.apply configure_automatic_updates

Expected behavior

lgpo.set should set both enum and bool elements on the policy.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:                                                                                                                   
          Salt: 3005.1                                                                                                          
                                                                                                                                
Dependency Versions:                                                                                                            
          cffi: 1.14.6                                                                                                          
      cherrypy: 18.6.1                                                                                                          
      dateutil: 2.8.1                                                                                                           
     docker-py: Not Installed                                                                                                   
         gitdb: 4.0.7                                                                                                           
     gitpython: Not Installed                                                                                                   
        Jinja2: 3.1.0                                                                                                           
       libgit2: Not Installed                                                                                                   
      M2Crypto: Not Installed                                                                                                   
          Mako: 1.1.4                                                                                                           
       msgpack: 1.0.2                                                                                                           
  msgpack-pure: Not Installed                                                                                                   
  mysql-python: Not Installed                                                                                                   
     pycparser: 2.21                                                                                                            
      pycrypto: Not Installed                                                                                                   
  pycryptodome: 3.10.1                                                                                                          
        pygit2: Not Installed                                                                                                   
        Python: 3.8.15 (tags/v3.8.15:44adf8a, Nov  8 2022, 17:20:07) [MSC v.1929 64 bit (AMD64)]                                
  python-gnupg: 0.4.8                                                                                                           
        PyYAML: 5.4.1                                                                                                           
         PyZMQ: 22.0.3                                                                                                          
         smmap: 4.0.0                                                                                                           
       timelib: 0.2.4                                                                                                           
       Tornado: 4.5.3                                                                                                           
           ZMQ: 4.3.4                                                                                                           
                                                                                                                                
System Versions:                                                                                                                
          dist:                                                                                                                 
        locale: cp1252                                                                                                          
       machine: AMD64                                                                                                           
       release: 2016Server                                                                                                      
        system: Windows                                                                                                         
       version: 2016Server 10.0.14393 SP0 Multiprocessor Free                                                                   
                                                                                                                                

Additional context
Add any other context about the problem here.

@rudeb0t rudeb0t added Bug broken, incorrect, or confusing behavior needs-triage labels Jan 12, 2023
@welcome
Copy link

welcome bot commented Jan 12, 2023

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@twangboy
Copy link
Contributor

Just ran on a new VM:

(venv) PS C:\src\salt> salt-call --local state.apply test
local:
----------
          ID: configure_automatic_updates
    Function: lgpo.set
      Result: False
     Comment: Invalid element name: Every week
              Invalid element name: First week of the month
              Invalid element name: Second week of the month
              Invalid element name: Third week of the month
              Invalid element name: Fourth week of the month
     Started: 17:30:05.090417
    Duration: 6921.899 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   6.922 s

Probably needs an update... I'll try again after patching the system.

@twangboy
Copy link
Contributor

My fully patched version of Windows Server 2016 has a policy for Automatic updates that looks like this:
image
On my Windows Server 2019 box that policy looks like this:
image

So, it looks like those enums for the weeks are only available on Windows Server 2019 and newer.

@dstoliker
Copy link

The behavior is present on a 2016 machine with the WindowsUpdate.admx/adml template installed.

Without templates:
2016 no templates

With templates:
2016 with templates

@dstoliker dstoliker reopened this Jan 17, 2023
@dstoliker
Copy link

dstoliker commented Jan 17, 2023

Output from 2016 machines with the WindowsUpdate.admx/admx template installed and the Configure Automatic Updates configured like this:
configured policy
With Salt 3005.1, the output received by running salt-call --local lgpo.get_policy 'Configure Automatic Updates' machine:

local:
    ----------
    Configure automatic updating:
        4 - Auto download and schedule the install
    Scheduled install day:
        0 - Every day
    Scheduled install time:
        03:00

The same machine after downgrading to Salt 3004.2 and running the same command:

local:
    ----------
    Configure automatic updating:
        4 - Auto download and schedule the install
    Every week:
        True
    First week of the month:
        False
    Fourth week of the month:
        False
    Install during automatic maintenance:
        False
    Install updates for other Microsoft products:
        False
    Scheduled install day:
        0 - Every day
    Scheduled install time:
        03:00
    Second week of the month:
        False
    Third week of the month:
        False

@rudeb0t
Copy link
Author

rudeb0t commented Jan 17, 2023

Running the same SLS on a Windows Server 2019 VM with Salt 3005.1

local:
----------
          ID: configure_automatic_updates
    Function: lgpo.set
      Result: True
     Comment: The following policies changed:
              Configure Automatic Updates
     Started: 15:57:28.668392
    Duration: 2390.946 ms
     Changes:
              ----------
              new:
                  ----------
                  Computer Configuration:
                      ----------
                      Configure Automatic Updates:
                          ----------
                          Configure automatic updating:
                              4 - Auto download and schedule the install
                          Scheduled install day:
                              0 - Every day
                          Scheduled install time:
                              03:00
              old:
                  ----------
                  Computer Configuration:
                      ----------
                      Configure Automatic Updates:
                          Not Configured

Downgraded to Salt 3004.2 and re-running the same SLS:

local:
----------
          ID: configure_automatic_updates
    Function: lgpo.set
      Result: True
     Comment: The following policies changed:
              Configure Automatic Updates
     Started: 16:10:56.507170
    Duration: 2732.247 ms
     Changes:
              ----------
              new:
                  ----------
                  Computer Configuration:
                      ----------
                      Configure Automatic Updates:
                          ----------
                          Configure automatic updating:
                              4 - Auto download and schedule the install
                          Every week:
                              False
                          First week of the month:
                              False
                          Fourth week of the month:
                              False
                          Install during automatic maintenance:
                              False
                          Install updates for other Microsoft products:
                              False
                          Scheduled install day:
                              0 - Every day
                          Scheduled install time:
                              03:00
                          Second week of the month:
                              False
                          Third week of the month:
                              False
              old:
                  ----------
                  Computer Configuration:
                      ----------
                      Configure Automatic Updates:
                          Not Configured

Changing up the SLS a bit and adding some True boolean settings:

configure_automatic_updates:                                                                                                                                                           
  lgpo.set:                                                                                                                                                                                   
    - computer_policy:                                                                                                                                                                        
        'Configure Automatic Updates':                                                                                                                                                        
          'Configure automatic updating': 4 - Auto download and schedule the install                                                                                                          
          'Install during automatic maintenance': False                                                                                                                                       
          'Scheduled install day': 0 - Every day                                                                                                                                              
          'Scheduled install time': 03:00                                                                                                                                                     
          'Install updates for other Microsoft products': True                                                                                                                                
          'Every week': True                                                                                                                                                                  
          'First week of the month' : False                                                                                                                                                   
          'Second week of the month' : False                                                                                                                                                  
          'Third week of the month' : False                                                                                                                                                   
          'Fourth week of the month' : False                                                                                                                                                  
                                                                                                                                                                                              

Running it with Salt 3005.1:

local:
----------
          ID: configure_automatic_updates
    Function: lgpo.set
      Result: True
     Comment: The following policies changed:
              Configure Automatic Updates
     Started: 16:29:49.750695
    Duration: 2635.991 ms
     Changes:
              ----------
              new:
                  ----------
                  Computer Configuration:
                      ----------
                      Configure Automatic Updates:
                          ----------
                          Configure automatic updating:
                              4 - Auto download and schedule the install
                          Scheduled install day:
                              0 - Every day
                          Scheduled install time:
                              03:00
              old:
                  ----------
                  Computer Configuration:
                      ----------
                      Configure Automatic Updates:
                          Not Configured

@jtraub91
Copy link
Contributor

I'm seeing issues similar to this with salt 3005.1 and Windows 2022 Server, but not necessarily as stated in this issue's title.

Mixed enums and bools has seemed to be configured correctly, with the following state file.

test_configure_automatic_updates.sls

configure_automatic_updates:
  lgpo.set:
    - computer_policy:
        "Windows Components\\Windows Update\\Configure Automatic Updates":
          Configure automatic updating: 4 - Auto download and schedule the install
          Install during automatic maintenance: False
          Scheduled install day: 0 - Every day
          Scheduled install time: "00:00"
          Every week: False
          First week of the month: True
          Second week of the month: False
          Third week of the month: True
          Fourth week of the month: False
          Install updates for other Microsoft products: False

I see the following output

# salt \* state.sls test_configure_automatic_updates
windows-2022-minion:
----------
          ID: configure_automatic_updates
    Function: lgpo.set
      Result: True
     Comment: The following policies changed:
              Windows Components\Windows Update\Configure Automatic Updates
     Started: 19:53:08.218930
    Duration: 4718.734 ms
     Changes:   
              ----------
              new:
                  ----------
                  Computer Configuration:
                      ----------
                      Windows Components\Windows Update\Configure Automatic Updates:
                          ----------
                          Configure automatic updating:
                              4 - Auto download and schedule the install
                          Scheduled install day:
                              0 - Every day
                          Scheduled install time:
                              00:00
              old:
                  ----------
                  Computer Configuration:
                      ----------
                      Windows Components\Windows Update\Configure Automatic Updates:
                          Not Configured

Summary for windows-2022-minion
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   4.719 s

image

However, a re-application of the state throws an error (though the policy remains unchanged).

# salt \* state.sls test_configure_automatic_updates
windows-2022-minion:
----------
          ID: configure_automatic_updates
    Function: lgpo.set
      Result: False
     Comment: Failed to set the following policies:
              Windows Components\Windows Update\Configure Automatic Updates
     Started: 20:00:24.090038
    Duration: 7671.811 ms
     Changes:   

Summary for windows-2022-minion
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   7.672 s

The fact that the "Every week", "First week of the month", etc. boolean keys don't show up in the salt state changes from the first state run, seems noteworthy, and potentially a source of this error.

@twangboy
Copy link
Contributor

The above PRs should fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Chlorine v3007.0 lgpo State-Module Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants