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

State augeas.change do not update config file #50016

Closed
abednarik opened this issue Oct 12, 2018 · 10 comments

Comments

@abednarik
Copy link
Contributor

commented Oct 12, 2018

Description of Issue/Question

We have a state to update /etc/service and include a new entry. After applying that state, we don't the change in configuration file.

BTW This is working with salt 2017.7.5 but not in 2018.3.2

Setup

Here is a sample state file

python-augeas:
  pkg.installed

mysqlchk-service:
  augeas.change:
    - lens: services.lns
    - context: /files/etc/services
    - changes:
      - ins service-name after service-name[last()]
      - set service-name[last()] "mysqlchk"
      - set "service-name[. = 'mysqlchk']/port" 9200
      - set "service-name[. = 'mysqlchk']/protocol" tcp
      - set "service-name[. = 'mysqlchk']/#comment" "MySQL HAProxy health check"
    - require:
      - pkg: python-augeas
    - unless: grep -qi "mysqlchk" /etc/services

Here is the relevant part of the log

python-augeas:
  pkg.installed

mysqlchk-service:
  augeas.change:
    - lens: services.lns
    - context: /files/etc/services
    - changes:
      - ins service-name after service-name[last()]
      - set service-name[last()] "mysqlchk"
      - set "service-name[. = 'mysqlchk']/port" 9200
      - set "service-name[. = 'mysqlchk']/protocol" tcp
      - set "service-name[. = 'mysqlchk']/#comment" "MySQL HAProxy health check"
    - require:
      - pkg: python-augeas
    - unless: grep -qi "mysqlchk" /etc/services


[DEBUG   ] Results of YAML rendering:
OrderedDict([(u'python-augeas', u'pkg.installed'), (u'mysqlchk-service', OrderedDict([(u'augeas.change', [OrderedDict([(u'lens', u'services.lns')]), OrderedDict([(u'context', u'/files/etc/services')]), OrderedDict([(u'changes', [u'ins service-name after service-name[last()]', u'set service-name[last()] "mysqlchk"', u'set "service-name[. = \'mysqlchk\']/port" 9200', u'set "service-name[. = \'mysqlchk\']/protocol" tcp', u'set "service-name[. = \'mysqlchk\']/#comment" "MySQL HAProxy health check"'])]), OrderedDict([(u'require', [OrderedDict([(u'pkg', u'python-augeas')])])]), OrderedDict([(u'unless', u'grep -qi "mysqlchk" /etc/services')])])]))])
[DEBUG   ] Could not LazyLoad augeas.mod_run_check: 'augeas.mod_run_check' is not available.
[INFO    ] Executing command 'grep -qi "mysqlchk" /etc/services' in directory '/root'
[DEBUG   ] retcode: 1
[DEBUG   ] Last command return code: 1
[DEBUG   ] insert: {u'path': u'/files/etc/services/service-name[last()]', u'before': False, u'label': u'service-name'}
[DEBUG   ] set: {u'path': u'/files/etc/services/service-name[last()]', u'value': u'mysqlchk'}
[DEBUG   ] set: {u'path': u"/files/etc/services/service-name[. = 'mysqlchk']/port", u'value': u'9200'}
[DEBUG   ] set: {u'path': u"/files/etc/services/service-name[. = 'mysqlchk']/protocol", u'value': u'tcp'}
[DEBUG   ] set: {u'path': u"/files/etc/services/service-name[. = 'mysqlchk']/#comment", u'value': u'MySQL HAProxy health check'}
[INFO    ] No changes made
[INFO    ] Completed state [mysqlchk-service] at time 06:38:36.563527 (duration_in_ms=414.774)

and this is salt output

local:
----------
          ID: python-augeas
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed
     Started: 06:38:35.827478
    Duration: 319.361 ms
     Changes:
----------
          ID: mysqlchk-service
    Function: augeas.change
      Result: True
     Comment: No changes made
     Started: 06:38:36.148753
    Duration: 414.774 ms
     Changes:

Summary for local
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
Total run time: 734.135 ms

Steps to Reproduce Issue

Just create a state like the one posted above and run it. Check /etc/service and find out that the file does not include the new entry

Versions Report

Salt Version:
           Salt: 2018.3.2

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: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.6 (default, Nov 23 2017, 15:49:48)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
         locale: UTF-8
        machine: x86_64
        release: 3.13.0-158-generic
         system: Linux
        version: Ubuntu 14.04 trusty

Not sure if this could be related to unicode change

@whytewolf

This comment has been minimized.

Copy link
Contributor

commented Oct 12, 2018

This might be a version issue.

After it worked fine in centos 7 I decided to check ubuntu. 14.04 didn't work however if i uninstalled the python-augeas ubuntu package. Than forced setuptools and wheel to upgrade.. and installed gcc, python-dev and libffi-dev. I could pip install python-augeas. After all that it worked correctly in ubuntu 14.04.

ubuntu 16.04 didn't have the problem and worked with the package installed by the os.

@whytewolf whytewolf added the ZD label Oct 12, 2018

@whytewolf

This comment has been minimized.

Copy link
Contributor

commented Oct 12, 2018

zd-2891

@abednarik

This comment has been minimized.

Copy link
Contributor Author

commented Oct 12, 2018

Thanks for the quick response @whytewolf !

Will try that, as a workaround, until this issue is fixed. Will let you now how this one goes.

Cheers.

@abednarik

This comment has been minimized.

Copy link
Contributor Author

commented Oct 19, 2018

Did that and worked. We have time to wait for a real fix.

Thanks.

@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.

@abednarik

This comment has been minimized.

Copy link
Contributor Author

commented Jan 10, 2019

Hi @garethgreenaway

What we did was a hack. Ideally salt should work with python-augeas provides by the OS or either when you bootstrap salt, that version should be installed.

Cheers.

@garethgreenaway

This comment has been minimized.

Copy link
Member

commented Jan 10, 2019

@abednarik Did you get a chance to try PR #50690?

@abednarik

This comment has been minimized.

Copy link
Contributor Author

commented Jan 10, 2019

Yeah, I can try that. Not sure which version of salt contains that fix @garethgreenaway

@garethgreenaway

This comment has been minimized.

Copy link
Member

commented Jan 10, 2019

@abednarik unfortunately the fix is not in a released version yet so would need to manually patch it or download the file from GitHub, from the 2018.3 branch. It will be available once we released the next minor version of 2018.3 though.

@abednarik

This comment has been minimized.

Copy link
Contributor Author

commented Jan 10, 2019

Thanks @garethgreenaway . At point, I;m super busy with work things, Will see what I can do in the future. For sure once new salt version based on branch 2018.3 is released will upgrade and check this.

Thanks.

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.