Added Pieter Vogelaar's merge request in manually. Thank you, great idea. Added attribute to do custom search queries instead of just hosts:fqdn, updated documentation
This commit is contained in:
parent
a9dfd4447f
commit
80a671a8d7
2 changed files with 20 additions and 12 deletions
18
README.md
18
README.md
|
@ -13,8 +13,9 @@ Attributes
|
|||
#### sudo_rules::default
|
||||
|
||||
Key | Type | Description | Default
|
||||
---------------------------- | ------ | ------------------------------------ | ----------
|
||||
-------------------------------- | ------ | ---------------------------------------------------------- | ----------
|
||||
`['sudo_rules']['data_bag']` | String | Name of data bag to use for entries. | sudo_rules
|
||||
`['sudo_rules']['search_query']` | String | Custom search query for matching instead of just host:fqdn | None
|
||||
|
||||
#### data bag
|
||||
|
||||
|
@ -71,12 +72,13 @@ And provide properly formatted data bag:
|
|||
|
||||
Contributing
|
||||
------------
|
||||
1. Fork the repository on Github
|
||||
2. Create a named feature branch (like `add_component_x`)
|
||||
3. Write your change
|
||||
4. Write tests for your change (if applicable)
|
||||
5. Run the tests, ensuring they all pass
|
||||
6. Submit a Pull Request using Github
|
||||
1. Fork the repository on Github.
|
||||
2. Switch to the develop branch.
|
||||
3. Create a named feature branch off develop (like `add_component_x`).
|
||||
4. Write your change.
|
||||
5. Write tests for your change (if applicable).
|
||||
6. Run the tests, ensuring they all pass.
|
||||
7. Submit a Pull Request using Github to develop branch.
|
||||
|
||||
or
|
||||
|
||||
|
@ -85,5 +87,5 @@ or
|
|||
License and Authors
|
||||
-------------------
|
||||
Authors: Eric Renfro <erenfro@linux-help.org>
|
||||
|
||||
Contributers: Pieter Vogelaar
|
||||
|
||||
|
|
|
@ -12,10 +12,16 @@ include_recipe "sudo"
|
|||
node.override['authorization']['sudo']['include_sudoers_d'] = true
|
||||
search_node = node['fqdn']
|
||||
|
||||
if node['sudo_rules'].key?('search_query') && node['sudo_rules']['search_query'] != ''
|
||||
search_query = node['sudo_rules']['search_query']
|
||||
else
|
||||
search_query = "hosts:#{search_node}"
|
||||
end
|
||||
|
||||
if Chef::Config[:solo] and nod chef_solo_search_installed?
|
||||
Chef::Log.warn("This recipe uses search. Chef Solo does not support search unless you install the chef-solo-search cookbook.")
|
||||
else
|
||||
search(node['sudo_rules']['data_bag'], "hosts:#{search_node}").each do |rule|
|
||||
search(node['sudo_rules']['data_bag'], search_query).each do |rule|
|
||||
# Name
|
||||
if rule["name"].kind_of?(String)
|
||||
rule_name = rule["name"]
|
||||
|
|
Loading…
Reference in a new issue