Skip to content

Instantly share code, notes, and snippets.

@Resisty
Last active August 29, 2015 14:16
Show Gist options
  • Save Resisty/d5f150e9ad277b9f6d29 to your computer and use it in GitHub Desktop.
Save Resisty/d5f150e9ad277b9f6d29 to your computer and use it in GitHub Desktop.
define sudoers::add_sudoer (
$theguy = $name,
$pass = '',
# variables here
) {
realize(Concat['/etc/sudoers'])
concat::fragment { $theguy:
target => '/etc/sudoers',
content => "${theguy} ALL=(ALL:ALL) NOPASSWD:ALL",
order => 90,
}
}
puppet module --modulepath modules list
/home/Resisty/puppet/modules
├── nocdevusers (???)
├── packages (???)
├── puppetlabs-concat (v1.2.0)
├── puppetlabs-stdlib (v4.5.1)
├── setup_nocdev (???)
├── sudoers (???)
└── test (???)
class nocdevusers (
# variables here
) {
$users = hiera('users', {})
create_resources('nocdevusers::create_users', $users)
create_resources('sudoers::add_sudoer', $users)
}
class setup_nocdev(
# variables here
) {
include 'packages'
include 'sudoers'
include 'nocdevusers'
}
# ultimately run via `puppet apply --noop -d --trace --verbose --hiera_config hiera.yaml --modulepath modules/ -e "include setup_nocdev"`
class sudoers(
# variables here
) {
$sudoers = '/etc/sudoers'
@concat { $sudoers :
owner => root,
group => root,
mode => 0440,
}
concat::fragment { 'sudoers_header':
target => $sudoers,
source => 'puppet:///modules/sudoers/sudoers',
order => 1,
}
}
Debug: /Stage[main]/Nocdevusers/Sudoers::Add_sudoer[Resisty]/Concat::Fragment[Resisty]/File[/home/Resisty/.puppet/var/concat/_etc_sudoers/fragments/90_Resisty]: The container Concat::Fragment[Resisty] will propagate my refresh event
Error: /Stage[main]/Sudoers/Concat[/etc/sudoers]/Exec[concat_/etc/sudoers]: Could not evaluate: Could not find command '/home/Resisty/.puppet/var/concat/bin/concatfragments.sh'
/usr/lib/ruby/vendor_ruby/puppet/provider/exec/posix.rb:21:in `checkexe'
/usr/lib/ruby/vendor_ruby/puppet/provider/exec.rb:12:in `run'
/usr/lib/ruby/vendor_ruby/puppet/provider/exec/posix.rb:45:in `run'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:410:in `check'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:537:in `block (2 levels) in check_all_attributes'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:536:in `each'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:536:in `block in check_all_attributes'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:531:in `each'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:531:in `check_all_attributes'
/usr/lib/ruby/vendor_ruby/puppet/type/exec.rb:95:in `retrieve'
/usr/lib/ruby/vendor_ruby/puppet/type.rb:1045:in `block in retrieve'
/usr/lib/ruby/vendor_ruby/puppet/type.rb:1040:in `each'
/usr/lib/ruby/vendor_ruby/puppet/type.rb:1040:in `retrieve'
/usr/lib/ruby/vendor_ruby/puppet/type.rb:1063:in `retrieve_resource'
/usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:223:in `from_resource'
/usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:19:in `evaluate'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:174:in `apply'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:187:in `eval_resource'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:117:in `call'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:117:in `block (2 levels) in evaluate'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:327:in `block in thinmark'
/usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:326:in `thinmark'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:117:in `block in evaluate'
/usr/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:118:in `traverse'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:108:in `evaluate'
/usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:164:in `block in apply'
/usr/lib/ruby/vendor_ruby/puppet/util/log.rb:149:in `with_destination'
/usr/lib/ruby/vendor_ruby/puppet/transaction/report.rb:108:in `as_logging_destination'
/usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:163:in `apply'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:125:in `block in apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:161:in `block in benchmark'
/usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:160:in `benchmark'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:124:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:192:in `run'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:268:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:218:in `main'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:146:in `run_command'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in `block (2 levels) in run'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:470:in `plugin_hook'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in `block in run'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:478:in `exit_on_fail'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in `run'
/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'
/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:91:in `execute'
/usr/bin/puppet:4:in `<main>'
# `cp modules/concat/files/* ~/.puppet/var/concat/bin`
Error: /Stage[main]/Sudoers/Concat[/etc/sudoers]/File[/etc/sudoers]: Could not evaluate: Could not retrieve information from environment production source(s) file:/home/Resisty/.puppet/var/concat/_etc_sudoers/fragments.concat.out
/usr/lib/ruby/vendor_ruby/puppet/util/errors.rb:97:in `fail'
/usr/lib/ruby/vendor_ruby/puppet/type/file/source.rb:181:in `metadata'
/usr/lib/ruby/vendor_ruby/puppet/type/file/source.rb:111:in `copy_source_values'
/usr/lib/ruby/vendor_ruby/puppet/type/file.rb:637:in `retrieve'
/usr/lib/ruby/vendor_ruby/puppet/type.rb:1063:in `retrieve_resource'
/usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:223:in `from_resource'
/usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:19:in `evaluate'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:174:in `apply'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:187:in `eval_resource'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:117:in `call'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:117:in `block (2 levels) in evaluate'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:327:in `block in thinmark'
/usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:326:in `thinmark'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:117:in `block in evaluate'
/usr/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:118:in `traverse'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:108:in `evaluate'
/usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:164:in `block in apply'
/usr/lib/ruby/vendor_ruby/puppet/util/log.rb:149:in `with_destination'
/usr/lib/ruby/vendor_ruby/puppet/transaction/report.rb:108:in `as_logging_destination'
/usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:163:in `apply'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:125:in `block in apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:161:in `block in benchmark'
/usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:160:in `benchmark'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:124:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:192:in `run'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:268:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:218:in `main'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:146:in `run_command'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in `block (2 levels) in run'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:470:in `plugin_hook'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in `block in run'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:478:in `exit_on_fail'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in `run'
/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'
/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:91:in `execute'
/usr/bin/puppet:4:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment