Skip to content

Commit

Permalink
pushing few missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
unixbhaskar committed Nov 6, 2013
1 parent f0e90dc commit 85e3c39
Show file tree
Hide file tree
Showing 36 changed files with 2,881 additions and 0 deletions.
105 changes: 105 additions & 0 deletions acceptance/tests/databinding/hiera/auto_lookup_for_class_parameters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
confine :except, :platform => 'solaris'
begin test_name "Auto lookup for class parameters"

step "Setup"

apply_manifest_on master, <<-PP
file { '/etc/puppet/hieradata':
ensure => directory,
recurse => true,
purge => true,
force => true,
}
file { '/etc/puppet/hiera.yaml':
ensure => present,
content => '---
:backends:
- "puppet"
- "yaml"
:logger: "console"
:hierarchy:
- "%{fqdn}"
- "%{environment}"
- "global"
:yaml:
:datadir: "/etc/puppet/hieradata"
'
}
PP

testdir = master.tmpdir('databinding')

create_remote_file(master, "#{testdir}/puppet.conf", <<END)
[main]
manifest = "#{testdir}/site.pp"
modulepath = "#{testdir}/modules"
END

on master, "mkdir -p #{testdir}/modules/ssh/manifests"
on master, "mkdir -p #{testdir}/modules/ntp/manifests"

agent_names = agents.map { |agent| "'#{agent.to_s}'" }.join(', ')
create_remote_file(master, "#{testdir}/site.pp", <<-PP)
node default {
include ssh::server
}
PP

create_remote_file(master, "#{testdir}/modules/ssh/manifests/init.pp", <<-PP)
class ssh::server($port, $usepam, $listenaddress) {
notify { "port from hiera":
message => "SSH server port: ${port}"
}
notify { "usepam from hiera":
message => "SSH server UsePam: ${usepam}"
}
notify { "listenaddress from hiera":
message => "SSH server ListenAddress: ${listenaddress}"
}
}
PP

on master, "chown -R root:puppet #{testdir}"
on master, "chmod -R g+rwX #{testdir}"

step "Setup Hiera data"

apply_manifest_on master, <<-PP
file { '/etc/puppet/hieradata/global.yaml':
ensure => present,
content => "---
'ssh::server::port': 22
'ssh::server::usepam': 'yes'
'ssh::server::listenaddress': '0.0.0.0'
"
}
PP

step "Should lookup class paramters from Hiera"

with_master_running_on(master, "--config #{testdir}/puppet.conf --debug --verbose --daemonize --dns_alt_names=\"puppet,$(facter hostname),$(facter fqdn)\" --autosign true") do
agents.each do |agent|
run_agent_on(agent, "--no-daemonize --onetime --verbose --server #{master}")

assert_match("SSH server port: 22", stdout)
assert_match("SSH server UsePam: yes", stdout)
assert_match("SSH server ListenAddress: 0.0.0.0", stdout)
end
end

ensure step "Teardown"
on master, "rm -rf #{testdir}"
apply_manifest_on master, <<-PP
file { '/etc/puppet/hieradata':
ensure => directory,
recurse => true,
purge => true,
force => true,
}
file { '/etc/puppet/hiera.yaml':
ensure => absent,
}
PP
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
begin test_name "Lookup data using the hiera parser function"

step 'Setup'
testdir = master.tmpdir('hiera')

create_remote_file(master, "#{testdir}/puppet.conf", <<END)
[main]
data_binding_terminus = 'hiera'
manifest = "#{testdir}/site.pp"
modulepath = "#{testdir}/modules"
END

on master, "mkdir -p #{testdir}/modules/apache/manifests"
on master, "mkdir -p /var/lib/hiera"

apply_manifest_on master, <<-PP
file { '/var/lib/hiera/global.yaml':
ensure => present,
content => "---
apache::port: 8080
"
}
file { '/etc/puppet/hiera.yaml':
ensure => present,
content => '---
:backends:
- "puppet"
- "yaml"
:logger: "console"
:hierarchy:
- "%{fqdn}"
- "%{environment}"
- "global"
:yaml:
:datadir: "/var/lib/hiera"
'
}
PP

agent_names = agents.map { |agent| "'#{agent.to_s}'" }.join(', ')
create_remote_file(master, "#{testdir}/site.pp", <<-PP)
node default {
include apache
}
PP

create_remote_file(master, "#{testdir}/modules/apache/manifests/init.pp", <<-PP)
class apache($port) {
notify { "port from hiera":
message => "apache server port: ${port}"
}
}
PP

on master, "chown -R root:puppet #{testdir}"
on master, "chmod -R g+rwX #{testdir}"


step "Try to lookup string data"

with_master_running_on(master, "--config #{testdir}/puppet.conf --debug --verbose --daemonize --dns_alt_names=\"puppet,$(facter hostname),$(facter fqdn)\" --autosign true") do
agents.each do |agent|
run_agent_on(agent, "--no-daemonize --onetime --verbose --server #{master}")

assert_match("apache server port: 8080", stdout)
end
end


ensure step "Teardown"
apply_manifest_on master, <<-PP
file { '/var/lib/hiera':
ensure => directory,
recurse => true,
purge => true,
force => true,
}
file { '/etc/puppet/hiera.yaml':
ensure => absent,
}
PP
end
36 changes: 36 additions & 0 deletions acceptance/tests/modules/list/without_installed_modules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
test_name "puppet module list (without installed modules)"

step "Setup"
apply_manifest_on master, <<-PP
file {
[
'/etc/puppet/modules',
'/usr/share/puppet/modules',
]: ensure => directory,
recurse => true,
purge => true,
force => true;
}
PP
teardown do
on master, "rm -rf /etc/puppet/modules"
on master, "rm -rf /usr/share/puppet/modules"
end

step "List the installed modules"
on master, puppet('module list') do
assert_equal '', stderr
assert_equal <<-STDOUT, stdout
/etc/puppet/modules (no modules installed)
/usr/share/puppet/modules (no modules installed)
STDOUT
end

step "List the installed modules as a dependency tree"
on master, puppet('module list') do
assert_equal '', stderr
assert_equal <<-STDOUT, stdout
/etc/puppet/modules (no modules installed)
/usr/share/puppet/modules (no modules installed)
STDOUT
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
test_name "#11727: support stdin parsing in puppet parser validate"
confine :except, :platform => 'windows'

step "validate with a tty parses the default manifest"
on agents, puppet('parser', 'validate'), :pty => true do
assert_match(/Validating the default manifest/, stdout,
"no message about validating default manifest")
end

step "validate with redirection parses STDIN"
agents.each do |agent|
pp = agent.tmpfile('11727.pp')
create_remote_file agent, pp, 'notice("hello")'

on agent, puppet('parser', 'validate', '<', pp) do
assert_no_match(/Validating the default manifest/, stdout,
"there was message about validating default manifest despite redirect")
end
end
16 changes: 16 additions & 0 deletions examples/mac_automount.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env puppet
# Jeff McCune <mccune@math.ohio-state.edu>
#
# Apple's Automounter spawns a child that sends the parent
# a SIGTERM. This makes it *very* difficult to figure out
# if the process started correctly or not.
#

service {"automount-test":
provider => base,
hasrestart => false,
pattern => '/tmp/hometest',
start => "/usr/sbin/automount -m /tmp/home /dev/null -mnt /tmp/hometest",
stop => "ps auxww | grep '/tmp/hometest' | grep -v grep | awk '{print \$2}' | xargs kill",
ensure => running
}
4 changes: 4 additions & 0 deletions examples/mcx_dock_absent.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mcx { '/Groups/mcx_dock':
ensure => 'absent',
content => 'absent'
}
118 changes: 118 additions & 0 deletions examples/mcx_dock_default.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
mcx { '/Groups/mcx_dock':
ensure => 'present',
content => '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.dock</key>
<dict>
<key>AppItems-Raw</key>
<dict>
<key>state</key>
<string>always</string>
<key>upk</key>
<dict>
<key>mcx_input_key_names</key>
<array>
<string>AppItems-Raw</string>
</array>
<key>mcx_output_key_name</key>
<string>static-apps</string>
<key>mcx_remove_duplicates</key>
<true/>
</dict>
<key>value</key>
<array>
<dict>
<key>mcx_typehint</key>
<integer>1</integer>
<key>tile-data</key>
<dict>
<key>file-data</key>
<dict>
<key>_CFURLString</key>
<string>/Applications/Mail.app</string>
<key>_CFURLStringType</key>
<integer>0</integer>
</dict>
<key>file-label</key>
<string>Mail</string>
</dict>
<key>tile-type</key>
<string>file-tile</string>
</dict>
<dict>
<key>mcx_typehint</key>
<integer>1</integer>
<key>tile-data</key>
<dict>
<key>file-data</key>
<dict>
<key>_CFURLString</key>
<string>/Applications/Safari.app</string>
<key>_CFURLStringType</key>
<integer>0</integer>
</dict>
<key>file-label</key>
<string>Safari</string>
</dict>
<key>tile-type</key>
<string>file-tile</string>
</dict>
</array>
</dict>
<key>DocItems-Raw</key>
<dict>
<key>state</key>
<string>always</string>
<key>upk</key>
<dict>
<key>mcx_input_key_names</key>
<array>
<string>DocItems-Raw</string>
</array>
<key>mcx_output_key_name</key>
<string>static-others</string>
<key>mcx_remove_duplicates</key>
<true/>
</dict>
<key>value</key>
<array/>
</dict>
<key>MCXDockSpecialFolders-Raw</key>
<dict>
<key>state</key>
<string>always</string>
<key>upk</key>
<dict>
<key>mcx_input_key_names</key>
<array>
<string>MCXDockSpecialFolders-Raw</string>
</array>
<key>mcx_output_key_name</key>
<string>MCXDockSpecialFolders</string>
<key>mcx_remove_duplicates</key>
<true/>
</dict>
<key>value</key>
<array/>
</dict>
<key>contents-immutable</key>
<dict>
<key>state</key>
<string>always</string>
<key>value</key>
<false/>
</dict>
<key>static-only</key>
<dict>
<key>state</key>
<string>always</string>
<key>value</key>
<false/>
</dict>
</dict>
</dict>
</plist>
'
}

0 comments on commit 85e3c39

Please sign in to comment.