remove vc/1, vc/2, etc. lines from /etc/securetty using augeas

96 views
Skip to first unread message

KC

unread,
Apr 7, 2016, 7:21:44 PM4/7/16
to Puppet Users
Hi All!

I'm trying to remove the vc/1-11 lines in my /etc/securetty file.

Is there a way to elegantly do this?

console
vc/1
vc/2
vc/3
.
.
vc/10
vc/11
tty/1
tty/2
tty/3
.
.
.
tty/10
tty/11

Doing:

rm /files/etc/securetty/*[.='vc/1'] works for one line
but
rm /files/etc/securetty/*[.='vc/*'] doesn't appear to iterate for the other vc lines.

Any suggestions?

-Kris

David Lutterkort

unread,
Apr 8, 2016, 2:37:38 PM4/8/16
to Puppet Users
Hi Kris,


On Thursday, April 7, 2016 at 4:21:44 PM UTC-7, KC wrote:

rm /files/etc/securetty/*[.='vc/1'] works for one line
but
rm /files/etc/securetty/*[.='vc/*'] doesn't appear to iterate for the other vc lines.

Any suggestions?

The trick is that you need to tell Augeas that you want to match a glob; in your second example, Augeas will look for nodes that have literally 'vc/*' in it. This should work:

 rm /files/etc/securetty/*[. =~ glob('vc/*') ]

David

KC

unread,
Apr 8, 2016, 8:33:15 PM4/8/16
to Puppet Users
It works! Thank you David!!!
Reply all
Reply to author
Forward
0 new messages