You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
salt.states.augeas.change example from docs fails with exception #16383
P2Priority 2PlatformRelates to OS, containers, platform-based utilities like FS, system based appsbugbroken, incorrect, or confusing behaviorfixed-pls-verifyfix is linked, bug author to confirm fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Running CentOS 7 Vagrant box w/ salt provisioner configured and masterless salt v2014.7.0rc3, also tried the latest develop branch.
An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/state.py", line 1529, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/site-packages/salt/states/augeas.py", line 182, in change
result = __salt__['augeas.execute'](context=context, lens=lens, commands=changes)
File "/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.py", line 159, in execute
func(**args)
File "/usr/lib/python2.7/site-packages/augeas.py", line 266, in insert
raise ValueError("Unable to insert label!")
ValueError: Unable to insert label!
To reproduce:
zabbix-service:
augeas.change:
- lens: services
- context: /files/etc/services
- changes:
- ins service-name after service-name[last()]
- set service-name[last()] zabbix-agent
- set service-name[. = 'zabbix-agent']/#comment "Zabbix Agent service"
- set service-name[. = 'zabbix-agent']/port 10050
- set service-name[. = 'zabbix-agent']/protocol tcp
test-service:
augeas.change:
- lens: services
- context: /files/etc/services
- changes:
- ins service-name after service-name[last()]
- set service-name[last()] test-service
- set service-name[. = 'test-service']/port 10075
- set service-name[. = 'test-service']/protocol tcp
- ins service-name after service-name[last()]
- set service-name[last()] test-service
- set service-name[. = 'test-service'][2]/port 10075
- set service-name[. = 'test-service'][2]/protocol udp
- unless: grep "test-service" /etc/services
This runs fine in augtool:
ins service-name after /files/etc/services/service-name[last()]
set /files/etc/services/service-name[last()] test-service
set /files/etc/services/service-name[. = 'test-service']/port 10075
set /files/etc/services/service-name[. = 'test-service']/protocol tcp
ins service-name after /files/etc/services/service-name[last()]
set /files/etc/services/service-name[last()] test-service
set /files/etc/services/service-name[. = 'test-service'][2]/port 10075
set /files/etc/services/service-name[. = 'test-service'][2]/protocol udp
Another example:
pam-su:
augeas.change:
- lens: pam
- context: /files/etc/pam.d/su
- changes:
- ins 01 after *[module = 'pam_rootok.so'][control = 'sufficient'][type ='auth'][last()]
- set 01/type auth
- set 01/control requisite
- set 01/module pam_wheel.so
- set 01/argument group=wheel
- unless: grep "group=wheel" /etc/pam.d/su
This runs fine in augtool:
ins 01 after /files/etc/pam.d/su/*[module = 'pam_rootok.so'][control = 'sufficient'][type ='auth'][last()]
set /files/etc/pam.d/su/01/type auth
set /files/etc/pam.d/su/01/control requisite
set /files/etc/pam.d/su/01/module pam_wheel.so
set /files/etc/pam.d/su/01/argument group=wheel
I ran into this problem as well. It looks like the arguments to the augeas insert function weren't being parsed in the correct order. Above is a patch that resolves the issue.
Sorry to comment on a closed issue, but I'm struggling with something that looks very much like this. I get this exception when I try to use augeas to modify /etc/pam.d/system-auth:
ID: system-auth_augeas
Function: augeas.change
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/state.py", line 1723, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1650, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/states/augeas.py", line 283, in change
commands=changes, load_path=load_path)
File "/usr/lib/python2.7/site-packages/salt/modules/augeas_cfg.py", line 245, in execute
func(**args)
File "/usr/lib/python2.7/site-packages/augeas.py", line 369, in insert
raise ValueError("Unable to insert label!")
ValueError: Unable to insert label!
Started: 12:11:16.559663
Duration: 8.564 ms
Changes:
This is the SLS code:
python-augeas:
pkg.installedsystem-auth_augeas:
augeas.change:
- require:
- pkg: python-augeas
- lens: pam
- context: /files/etc/pam.d/system-auth/
- changes:
- ins 02 after *[type='auth'][control='sufficient'][module='pam_unix.so']
- set 02/type auth
- set 02/control sufficient
- set 02/module pam_faillock.so
- set 02/argument authsucc
This works if I run it through augtool. This is my input:
ins 02 after /files/etc/pam.d/system-auth/*[type='auth'][control='sufficient'][module='pam_unix.so']
set /files/etc/pam.d/system-auth/02/type auth
set /files/etc/pam.d/system-auth/02/control sufficient
set /files/etc/pam.d/system-auth/02/module pam_faillock.so
set /files/etc/pam.d/system-auth/02/argument authsucc
save
I'm using CentOS 7 and Saltstack 2016.3.1. Am I doing something wrong?
I took out - lens: pam in your code and it worked -- does that work for you as well? If so, the problem might be related to issue #24274 which is still open, although that has a different error message.
No, sorry, removing "lens: pam" changes nothing. But something weird is happening, because if I change "lens: pam" to a lens that doesn't exist ("lens: whatever"), the same error appears. It's as if the lens wasn't being used at all.
Strange that removing the lens worked for me but not for you. Not sure what to make of it at this point. I'd suggest opening up a separate issue for the problem that you're seeing so that it can get better attention from the developers. It may still be related to #24274, or it may be a new issue.
P2Priority 2PlatformRelates to OS, containers, platform-based utilities like FS, system based appsbugbroken, incorrect, or confusing behaviorfixed-pls-verifyfix is linked, bug author to confirm fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
cachedout commentedon Oct 6, 2014
Thanks for the report. We'll investigate this.
interjection commentedon Oct 6, 2014
Just adding some quick examples to test against:
This runs fine in augtool:
Another example:
This runs fine in augtool:
mens commentedon Dec 16, 2014
The problem seems to be the #comment part. I haven't found a working way to do something like:
set /files/etc/hosts/#comment[2] "this is the second comment"{code}This always results in the error above.
Update augeas_cfg.py
kartiksubbarao commentedon May 20, 2015
I ran into this problem as well. It looks like the arguments to the augeas insert function weren't being parsed in the correct order. Above is a patch that resolves the issue.
rsuarezsoto commentedon Jul 26, 2016
Sorry to comment on a closed issue, but I'm struggling with something that looks very much like this. I get this exception when I try to use augeas to modify /etc/pam.d/system-auth:
This is the SLS code:
This works if I run it through augtool. This is my input:
I'm using CentOS 7 and Saltstack 2016.3.1. Am I doing something wrong?
Thanks in advance.
kartiksubbarao commentedon Aug 1, 2016
I took out
- lens: pamin your code and it worked -- does that work for you as well? If so, the problem might be related to issue #24274 which is still open, although that has a different error message.rsuarezsoto commentedon Aug 2, 2016
No, sorry, removing "lens: pam" changes nothing. But something weird is happening, because if I change "lens: pam" to a lens that doesn't exist ("lens: whatever"), the same error appears. It's as if the lens wasn't being used at all.
kartiksubbarao commentedon Aug 2, 2016
Strange that removing the lens worked for me but not for you. Not sure what to make of it at this point. I'd suggest opening up a separate issue for the problem that you're seeing so that it can get better attention from the developers. It may still be related to #24274, or it may be a new issue.