[BUG] augeas formatting and saving errors with httpd.lns
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
Reopening #24274 and #34918, two augeas httpd.lns bugs that were marked as stale and closed, but are still present in salt 3006.3. The straightforward implementation fails with "Invalid formatted command". When adding extra quotes to pacify that error, the state fails with "Error: Augeas.save() failed: No error". Both the additional quoting and removing "lens: httpd.lns" are needed to work around the issues.
Setup
pypi install of salt 3006.3 and python-augeas on Ubuntu 22.04.
Steps to Reproduce the behavior
First, as a reference, here is the augtool command that works fine:
augtool set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
Here is the straightforward salt state:
/etc/apache2/sites-available/default-ssl.conf:
augeas.change:
- lens: httpd.lns
- context: /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost
- changes:
- set directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
When I run this, I get the following error. Excerpt from the -l all log (the full log doesn't seem to have any other useful info):
[TRACE ] Slot processing list value: set directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
[ERROR ] set takes (1, 2) args: ['directive[.', '=', 'SSLCertificateFile]/arg', '/etc/ssl/certs/cert1.pem']
[ERROR ] Error: Invalid formatted command, see debug log for details: directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
[...]
ID: /etc/apache2/sites-available/default-ssl.conf
Function: augeas.change
Result: False
Comment: Error: Invalid formatted command, see debug log for details: directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
Started: 12:14:15.057841
Duration: 8.454 ms
Changes:
Adding quotes to the changes in the state:
/etc/apache2/sites-available/default-ssl.conf:
augeas.change:
- lens: httpd.lns
- context: /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost
- changes:
- "set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = \"SSLCertificateFile\"]/arg' /etc/ssl/certs/cert1.pem"
When I run this, I get:
[TRACE ] Slot processing list value: set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
[DEBUG ] set: {'path': '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg', 'value': '/etc/ssl/certs/cert1.pem'}
[ERROR ] Error: Augeas.save() failed: No error
[INFO ] Completed state [/etc/apache2/sites-available/default-ssl.conf] at time 12:32:26.598838 (duration_in_ms=9.537)
[...]
ID: /etc/apache2/sites-available/default-ssl.conf
Function: augeas.change
Result: False
Comment: Error: Augeas.save() failed: No error
Started: 12:32:26.589301
Duration: 9.537 ms
Changes:
Finally, when I remove httpd.lns:
/etc/apache2/sites-available/default-ssl.conf:
augeas.change:
- context: /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost
- changes:
- "set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = \"SSLCertificateFile\"]/arg' /etc/ssl/certs/cert1.pem"
It works:
[TRACE ] Slot processing list value: set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
[DEBUG ] set: {'path': '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg', 'value': '/etc/ssl/certs/cert1.pem'}
[INFO ] {'updates': ['set \'/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg\' /etc/ssl/certs/cert1.pem']}
[...]
ID: /etc/apache2/sites-available/default-ssl.conf
Function: augeas.change
Result: True
Comment: Changes have been saved
Started: 12:35:33.694015
Duration: 1963.578 ms
Changes:
----------
updates:
- set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
Expected behavior
Expected behavior is to run the first example state above without errors. Please fix both bugs -- the need to remove httpd.lns (previously reported as #24274), and the need to add the extra quotes (previously reported as #34918; if the quoting is now intentionally needed, please document this).
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3006.3
Python Version:
Python: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
Dependency Versions:
cffi: 1.15.1
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.6
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.0
pygit2: Not Installed
python-gnupg: Not Installed
PyYAML: 6.0.1
PyZMQ: 25.1.1
relenv: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: ubuntu 22.04.3 jammy
locale: utf-8
machine: x86_64
release: 5.15.0-79-generic
system: Linux
version: Ubuntu 22.04.3 jammy
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Salt's augeas.change state and reproduce both failures using the provided httpd.lns state examples on Ubuntu 22.04 with Salt 3006.3 and python-augeas. Compare the working augtool command with Salt's change parsing and save behavior; done means the unquoted state works with httpd.lns and Augeas.save succeeds without removing the lens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100