Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-31-2012, 09:17 AM
|
#1
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Rep:
|
Modify group(%admin) with username in sudoers file
Hi,
How can I transform/modify group(%admin) in sudoers file where users are added in the admin group as "%admin ALL=(ALL) ALL" but I want to relect with user name on thome the system belongs which should fetch username from a file or database.
Is there any bash script or other to process the same through puppet ?
Any solution will be appreciated.
|
|
|
05-31-2012, 09:25 AM
|
#2
|
Senior Member
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
|
Quote:
Originally Posted by smilemukul
I want to relect with user name on thome the system belongs which should fetch username from a file or database.
|
I'm not entirely clear on what exactly you want to be able to do... Could you clarify it?
|
|
|
05-31-2012, 09:49 AM
|
#3
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Original Poster
Rep:
|
Actually I have a list of username from my domain where users are added in %admin group as specified in /etc/sudoers file but I want to specify username instead of %admin for all the users which are in the list according to the owner of the system such as,
File (list of users):-
David
Mapple
---------------
so want to replace %admin ALL=(ALL) ALL with David ALL=(ALL) ALL <--- System Owner is David
Mapple ALL=(ALL) ALL <--- System Owner is Mapple
|
|
|
06-01-2012, 07:12 AM
|
#4
|
Senior Member
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
|
And why are you wanting to do that? The 'admin' group is much more convenient and flexible in general...
However, if you wanted to systematically replace '%admin' then the following should help:
Code:
name='Mapple'
cp /etc/sudoers{,.bak}
chmod +w /etc/sudoers
sed "s/^%admin\( ALL=(ALL) ALL\)/${name}\1/" /etc/sudoers.bak > /etc/sudoers
chmod -w /etc/sudoers
I'm still not 100% sure on exactly what you want to achieve, but if you were to SSH to each machine and execute this code with the appropriate value for 'name' as root, then it would do what I think you want to do.
Needless to say, MAKE A BACKUP before doing ANYTHING with the /etc/sudoers file without using the visudo command. Or else.
|
|
|
06-08-2012, 02:11 AM
|
#5
|
Member
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292
Original Poster
Rep:
|
Actually I want to replace the username's in the /etc/sudoers from a list of users from a database & also the users list should be compared with the system's owners name means,
if system owner (David) = David (from users list from database)
then replace "David ALL=(ALL) ALL" in /etc/sudoers instead of "%admin ALL=(ALL) ALL"
Also the same I want to push through puppet.
I hope now it should be cleared.
|
|
|
06-08-2012, 02:39 AM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
OK, so you have an abstract (NON-POSIX) group list out there somewhere, and you want to use that list under puppet to customize the sudoers file on a range of systems?
So first up, don't. Stick with user groups, I expect there's some way to keep this simpler model.
But after that, if this really is what you're going to do (and TBH I can see why it's not so bad - you have to make some sort of arbitrary mapping at some point, so maybe this point is OK) what is the association between the system and the user? It seems like an extremely puppet based solution is pretty simple. First thought to use an external arbitrary text list is to use an extlookup - http://docs.puppetlabs.com/reference...html#extlookup within a simple template file, but plenty of other solutions are also out there. I like using puppet-dashboard for this finer detail of config, in which you could add all the nodes within dashboard and use external node processing in puppet to pull in these little scrappy bits of data which you can manage fairly painlessly through a web interface.
|
|
|
All times are GMT -5. The time now is 06:52 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|