Created
June 17, 2016 15:31
-
-
Save petems/8fb93e29cb32d280125964557e5eb2f2 to your computer and use it in GitHub Desktop.
Run Beaker on
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOSTS: | |
database: | |
roles: | |
- default | |
- database | |
platform: el-6-x86_64 | |
box : centos-64-x64-vbox4210-nocm | |
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box | |
hypervisor : vagrant | |
client: | |
roles: | |
- client | |
platform: el-6-x86_64 | |
box : centos-64-x64-vbox4210-nocm | |
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box | |
hypervisor : vagrant | |
CONFIG: | |
type: foss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper_acceptance' | |
describe 'remote-access', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do | |
if hosts.length > 1 | |
describe "configuring multi-node postgresql" do | |
# Get the database's IP to connect to from the client | |
let(:database_ip_address) do | |
hosts_as('database').inject({}) do |memo,host| | |
fact_on host, "ipaddress_eth1" | |
end | |
end | |
hosts_as('database').each do |host| | |
it "should be able to configure a host as database on #{host}" do | |
pp = <<-EOS | |
# Stop firewall so we can easily connect | |
service {'iptables': | |
ensure => 'stopped', | |
} | |
class { 'postgresql::server': | |
ip_mask_allow_all_users => '0.0.0.0/0', | |
listen_addresses => '*', | |
} | |
postgresql::server::db { 'puppet': | |
user => 'puppet', | |
password => postgresql_password('puppet', 'puppet'), | |
} | |
postgresql::server::pg_hba_rule { 'allow full yolo access password': | |
type => 'host', | |
database => 'all', | |
user => 'all', | |
address => '0.0.0.0/0', | |
auth_method => 'password', | |
order => '002', | |
} | |
EOS | |
apply_manifest_on(host, pp, :catch_failures => true) | |
end | |
end | |
hosts_as('client').each do |host| | |
it "should be able to configure a host as client on #{host} and then access database" do | |
pp = <<-EOS | |
class { 'postgresql::client':} | |
$connection_settings = { | |
'PGUSER' => "puppet", | |
'PGPASSWORD' => "puppet", | |
'PGHOST' => "#{database_ip_address}", | |
'PGPORT' => "5432", | |
'PGDATABASE' => "puppet", | |
} | |
postgresql_psql { 'run using connection_settings': | |
command => 'select 1', | |
psql_user => 'root', | |
psql_group => 'root', | |
connect_settings => $connection_settings, | |
} | |
EOS | |
apply_manifest_on(host, pp, :catch_failures => true) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment