saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.14k stars 5.47k forks source link

Function: augeas.change - Error: Unable to save to file! #43935

Closed nima0102 closed 5 years ago

nima0102 commented 7 years ago

Description of Issue/Question

Hello Salt team, I picked up an issue when I was trying to update a config file by augeas.change function. I noticed if the config file contains an empty property, ( key without any value, something like "KeyEmpty="), salt is not able to update the file and it returns " Error: Unable to save to file!"

here is my sls to update the file

`{% set config_file_path = '/tmp/file.propertis' %} {% set task_date = None | strftime("%Y%m%d-%H%M%S") %} Backup_file {{ task_date }}: file.copy:

Config_update 1 {{ task_date }}: augeas.change:

Versions Report

salt --versions-report Salt Version: Salt: 2016.3.0

Dependency Versions: cffi: Not Installed cherrypy: Not Installed dateutil: 1.4.1 gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.7.3 libgit2: Not Installed libnacl: Not Installed M2Crypto: 0.20.2 Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.6 mysql-python: Not Installed pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed Python: 2.6.6 (r266:84292, Oct 15 2013, 07:32:41) python-gnupg: Not Installed PyYAML: 3.11 PyZMQ: 14.5.0 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.2.1 ZMQ: 4.0.5

System Versions: dist: redhat 6.5 Santiago machine: x86_64 release: 3.8.13-16.2.1.el6uek.x86_64 system: Linux version: Red Hat Enterprise Linux Server 6.5 Santiago

gtmanfred commented 7 years ago

Can you run the augeas state from the minion using salt-call -l debug state.apply <state> and provide the log for that? I am wondering if there are any telling tracebacks.

Thanks, Daniel

nima0102 commented 7 years ago

Hi

Please find attached the debug file ( i ran the command you mentioned )

salt-debug_20171005.txt

gtmanfred commented 7 years ago

hrm, can you provide me with the file.properties file, so that I can fully replicate this issue?

Thanks, Daniel

nima0102 commented 7 years ago

Hi Here is content of file.properties:

key=A key1=B key2=C key3= key4=E key5=F key1001 = BB

dgersic commented 6 years ago

I believe I'm seeing a related issue here, same symptom, with a different lens. I'm using Salt from within SUSE Manager, with a state like:

Test1-SuSEfirewall2: augeas.change:

/tmp/SuSEfirewall2 contents:

The content of those files is merged into

FWSERVICES$zone_$protocol, ie has precedence over

FW_SERVICESACCEPT*

#

Example: "samba-server nfs-kernel-server"

FW_CONFIGURATIONS_EXT="foo bar baz"

The result is the above noted error message ("Error: Unable to save to file!").

augeas|-Test1-SuSEfirewall2|-Test1-SuSEfirewall2_|-change: comment: 'Error: Unable to save to file!' name: Test1-SuSEfirewall2 start_time: '15:28:58.063775' result: false duration: 26.417 __run_num: 19.0 changes: { } id__: Test1-SuSEfirewall2

I can make the change using augtool and it works fine. I'm coming back to this after ~6 months away, and I'm pretty sure that I had this working when I last looked at it. But now trying to update something I did, and testing it, I've run it to this not working.

Salt Version: Salt: 2016.11.4

Dependency Versions: cffi: 1.5.2 cherrypy: Not Installed dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.7.3 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: 2.10 pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: Not Installed Python: 2.7.13 (default, Jan 11 2017, 10:56:06) [GCC] python-gnupg: Not Installed PyYAML: 3.12 PyZMQ: 14.0.0 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.2.1 ZMQ: 4.0.4

System Versions: dist: SuSE 12 x86_64 machine: x86_64 release: 4.4.103-92.56-default system: Linux version: SUSE Linux Enterprise Server 12 x86_64

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.