X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fpostgresql%2Fspec%2Facceptance%2Fremote_access_spec.rb;fp=3rdparty%2Fmodules%2Fpostgresql%2Fspec%2Facceptance%2Fremote_access_spec.rb;h=9dd31de1b60536af4d99d2187887f69fe2af8a22;hb=a69999e580f8b3abd12446c2d6ad59e517651813;hp=0000000000000000000000000000000000000000;hpb=e7b6b352165009c385c52fcfe5a1055690dbfa4b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/postgresql/spec/acceptance/remote_access_spec.rb b/3rdparty/modules/postgresql/spec/acceptance/remote_access_spec.rb new file mode 100644 index 000000000..9dd31de1b --- /dev/null +++ b/3rdparty/modules/postgresql/spec/acceptance/remote_access_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper_acceptance' + +describe 'remote-access', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + before do + skip "These tests require the spec/acceptance/nodesets/centos-64-x64-2-hosts nodeset" + end + + describe "configuring multi-node postgresql" do + + # Get the database's IP to connect to from the database + 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