Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making sudoers for puppetrun_cmd conditional #271

Closed
wants to merge 1 commit into from
Closed

Making sudoers for puppetrun_cmd conditional #271

wants to merge 1 commit into from

Conversation

lazyfrosch
Copy link
Member

Not yet done, but to be the base of discussion.

It would be a good idea to only setup the sudo command if puppetrun_provider is actually puppet. Which is not set by default.

I'd like to get the opinion of the team.

intend to fix #269

@lazyfrosch
Copy link
Member Author

Opinions? anybody?

@ekohl
Copy link
Member

ekohl commented Aug 15, 2016

I think that it's a good idea.

Not sure how the exact implementation is going to look, but I was thinking about a base class (foreman_proxy::sudo) and something that concats the rules together.

@domcleal
Copy link
Contributor

Indeed, I definitely agree that the puppetrun command should only be in the sudo rules when that provider's active.

Refactoring can be done separately, if needed at all.

@lazyfrosch
Copy link
Member Author

My updated commit does the following in Augeas:

set /files/etc/sudoers/spec[user = 'foreman-proxy'][1]/user foreman-proxy
set /files/etc/sudoers/spec[user = 'foreman-proxy'][1]/host_group/host ALL
set /files/etc/sudoers/spec[user = 'foreman-proxy'][1]/host_group/command '/usr/bin/puppet cert *'
set /files/etc/sudoers/spec[user = 'foreman-proxy'][1]/host_group/command/runas_user root
set /files/etc/sudoers/spec[user = 'foreman-proxy'][1]/host_group/command/tag NOPASSWD
rm /files/etc/sudoers/spec[user = 'foreman-proxy'][1]/host_group/command[position() > 1]

set /files/etc/sudoers/spec[user = 'foreman-proxy'][2]/user foreman-proxy
set /files/etc/sudoers/spec[user = 'foreman-proxy'][2]/host_group/host ALL
set /files/etc/sudoers/spec[user = 'foreman-proxy'][2]/host_group/command '/usr/bin/puppet kick *'
set /files/etc/sudoers/spec[user = 'foreman-proxy'][2]/host_group/command/runas_user puppet
set /files/etc/sudoers/spec[user = 'foreman-proxy'][2]/host_group/command/tag NOPASSWD
rm /files/etc/sudoers/spec[user = 'foreman-proxy'][2]/host_group/command[position() > 1]

rm /files/etc/sudoers/spec[user = 'foreman-proxy'][position() > 2] # deletes all other rules for foreman proxy

set /files/etc/sudoers/Defaults[type = ':foreman-proxy']/type :foreman-proxy
set /files/etc/sudoers/Defaults[type = ':foreman-proxy']/requiretty/negate ''

Not sure if we should do the last rm, any opinions?

@ekohl
Copy link
Member

ekohl commented Aug 25, 2016

Not an expert on augeas but can't you start with an rm for all and then add everything back? That would make it easier to extend.

@lazyfrosch
Copy link
Member Author

@ekohl fixing specs, than you can see the template

@lazyfrosch
Copy link
Member Author

Updated the change, please review.

The Augeas part has been refactored so it is easier to understand (I hope)

@lazyfrosch
Copy link
Member Author

Please review, waiting on you guys 😉 🎐

@mmoll
Copy link
Contributor

mmoll commented Oct 1, 2016

I can't say too much about the augeas part, but at least in my install, the result seems correct.

Copy link
Contributor

@domcleal domcleal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes all look fine to me too, untested at the moment. Please also remove the "WIP" from the commit message & title if it's ready to be reviewed/merged.

rm spec[user = '<%= user %>'][<%=index%>]/host_group/command[position() > 1]<%# delete any other command in the rule %>
<% end -%>
<%- # TODO: should we delete all other rules for user?? -%>
rm spec[user = '<%= user %>'][position() > <%= index %>]<%# delete any other rule for the user %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the templates should do this, it should probably be limited in what it manages as sudoers might be maintained by further Augeas resources - the point of this method I think is to allow the user to customise the sudoers file in addition to using this module.

Refactor augeas for sudo rules

fixes #269
@lazyfrosch lazyfrosch changed the title WIP: Making sudoers for puppetrun_cmd conditional Making sudoers for puppetrun_cmd conditional Oct 3, 2016
@lazyfrosch
Copy link
Member Author

Removed TODO there, ready to merge

@domcleal It was marked WIP due to the TODO you commented on 😉

@domcleal
Copy link
Contributor

domcleal commented Oct 4, 2016

Works well, thanks. Tests will currently error due to a regression in stdlib.

@mmoll mmoll closed this in 4cc408a Oct 5, 2016
@mmoll
Copy link
Contributor

mmoll commented Oct 5, 2016

merged, danke @lazyfrosch!

juliantodt pushed a commit to juliantodt/puppet-foreman_proxy that referenced this pull request Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sudo issues w/ puppet proxy (without pupeptca or puppetrun)
4 participants