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

sysctl in test=True mode results in [ERROR ] Could not open sysctl file #50292

Closed
dstoliker opened this issue Oct 29, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@dstoliker
Copy link

commented Oct 29, 2018

Description of Issue/Question

When applying a sysctl state in test=True mode, if the default sysctl configuration is not yet present, will result in an error.

Setup

Assuming a clean CentOS 7 setup, ensure the file /etc/sysctl.d/99-salt.conf does not exist.
Example SLS file:

#sysctl-example.sls
no_ip_forward:
  sysctl.present:
    - name: net.ipv4.ip_forward
    - value: 0

Steps to Reproduce Issue

If the default configuration file does not exist, applying the state in test mode will result in an error.

$ sudo salt-call --local state.sls sysctl-example test=True
[ERROR   ] Could not open sysctl file
local:
----------
          ID: no_ip_forward
    Function: sysctl.present
        Name: net.ipv4.ip_forward
      Result: None
     Comment: Sysctl option net.ipv4.ip_forward might be changed, we failed to check config file at /etc/sysctl.d/99-salt.conf. The file is either unreadable, or missing.
     Started: 20:27:16.941814
    Duration: 68.069 ms
     Changes:

Summary for local
------------
Succeeded: 1 (unchanged=1)
Failed:    0
------------
Total states run:     1
Total run time:  68.069 ms

If the state is applied, the configuration file gets created and the sysctl changes are applied.

$ sudo salt-call --local state.sls sysctl-example
local:
----------
          ID: no_ip_forward
    Function: sysctl.present
        Name: net.ipv4.ip_forward
      Result: True
     Comment: Updated sysctl value net.ipv4.ip_forward = 0
     Started: 20:45:10.860314
    Duration: 14.629 ms
     Changes:
              ----------
              net.ipv4.ip_forward:
                  0

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:  14.629 ms

Once the config file exists, an accurate representation of what would or would not change is communicated in test mode.

$ sudo salt-call --local state.sls sysctl-example test=True
local:
----------
          ID: no_ip_forward
    Function: sysctl.present
        Name: net.ipv4.ip_forward
      Result: True
     Comment: Sysctl value net.ipv4.ip_forward = 0 is already set
     Started: 20:47:11.895131
    Duration: 35.995 ms
     Changes:

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  35.995 ms

Versions Report

Salt Version:
           Salt: 2018.3.3

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.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Jul 13 2018, 13:06:57)
   python-gnupg: Not Installed
         PyYAML: 3.11
          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.5.1804 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-862.11.6.el7.x86_64
         system: Linux
        version: CentOS Linux 7.5.1804 Core

@dwoz dwoz added Bug P4 labels Oct 30, 2018

@dwoz dwoz added this to the Approved milestone Oct 30, 2018

@dwoz

This comment has been minimized.

Copy link
Contributor

commented Oct 30, 2018

@dstoliker Thank you for reporting this. It's some odd behavior. :)

@rallytime

This comment has been minimized.

Copy link
Contributor

commented Nov 8, 2018

@dstoliker This is fixed with #50423

@garethgreenaway garethgreenaway self-assigned this Nov 26, 2018

@garethgreenaway

This comment has been minimized.

Copy link
Member

commented Jan 9, 2019

Closing this out, if the problem persists please comment & we'll re-open the issue or feel free to open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.