diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9bae94ec..8a2971a5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -65,12 +65,8 @@ steps: name: test_prepare - powershell: | - $domain = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | - Select -ExpandProperty DNSDomain | - Select -First 1 Write-Host 'Writing compose config to disk' $content = @" - AZURE_DOMAIN=$domain VOLUME_ROOT=$ENV:TempVolumeRoot "@ $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False diff --git a/docker-compose.yml b/docker-compose.yml index 392f1597..ec0f38b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,26 +2,30 @@ version: '3' services: puppet: - hostname: puppet + hostname: puppet.local image: puppet/puppetserver ports: - 8140:8140 environment: + # necessary to set certname and server in puppet.conf, required by + # puppetserver ca cli application + - PUPPETSERVER_HOSTNAME=puppet.local # DNS_ALT_NAMES must be set before starting the stack the first time, # and must list all the names under which the puppetserver can be - # reached. 'puppet' must be one of them, otherwise puppetdb won't be + # reached. 'puppet.local' must be one of them, otherwise puppetdb won't be # able to get a cert. Add other names as a comma-separated list - - DNS_ALT_NAMES=puppet,${DNS_ALT_NAMES:-} + - DNS_ALT_NAMES=puppet,puppet.local,${DNS_ALT_NAMES:-} - PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-true} - - PUPPETDB_SERVER_URLS=https://puppetdb:8081 + - PUPPETDB_SERVER_URLS=https://puppetdb.local:8081 volumes: - ${VOLUME_ROOT:-.}/volumes/code:/etc/puppetlabs/code/ - ${VOLUME_ROOT:-.}/volumes/puppet:/etc/puppetlabs/puppet/ - ${VOLUME_ROOT:-.}/volumes/serverdata:/opt/puppetlabs/server/data/puppetserver/ + dns_search: '.local' networks: default: aliases: - - puppet.${AZURE_DOMAIN:-} + - puppet.local postgres: image: postgres:9.6 @@ -34,14 +38,20 @@ services: volumes: - ${VOLUME_ROOT:-.}/volumes/puppetdb-postgres/data:/var/lib/postgresql/data - ./postgres-custom:/docker-entrypoint-initdb.d + dns_search: '.local' + networks: + default: + aliases: + - postgres.local puppetdb: - hostname: puppetdb + hostname: puppetdb.local image: puppet/puppetdb environment: - PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-true} # This name is an FQDN so the short name puppet doesn't collide outside compose network - - PUPPETSERVER_HOSTNAME=puppet.${AZURE_DOMAIN:-} + - PUPPETSERVER_HOSTNAME=puppet.local + - PUPPETDB_DATABASE_CONNECTION="//postgres.local:5432/puppetdb" - PUPPETDB_PASSWORD=puppetdb - PUPPETDB_USER=puppetdb ports: @@ -52,3 +62,8 @@ services: - puppet volumes: - ${VOLUME_ROOT:-.}/volumes/puppetdb/ssl:/etc/puppetlabs/puppet/ssl/ + dns_search: '.local' + networks: + default: + aliases: + - puppetdb.local diff --git a/gem/lib/pupperware/spec_helper.rb b/gem/lib/pupperware/spec_helper.rb index 6f1387c2..b00baab1 100644 --- a/gem/lib/pupperware/spec_helper.rb +++ b/gem/lib/pupperware/spec_helper.rb @@ -225,11 +225,10 @@ def wait_on_puppetserver_status(seconds = 180) end end + # agent_name is the fully qualified name of the node def clean_certificate(agent_name) - result = run_command('docker-compose --no-ansi exec -T puppet facter domain') - domain = result[:stdout].chomp - STDOUT.puts "cleaning cert for #{agent_name}.#{domain}" - result = run_command("docker-compose --no-ansi exec -T puppet puppetserver ca clean --certname #{agent_name}.#{domain}") + STDOUT.puts "cleaning cert for #{agent_name}" + result = run_command("docker-compose --no-ansi exec -T puppet puppetserver ca clean --certname #{agent_name}") return result[:status].exitstatus end @@ -245,11 +244,10 @@ def run_agent(agent_name, network, server = get_container_hostname(get_service_c return result[:status].exitstatus end + # agent_name is the fully qualified name of the node def check_report(agent_name) pdb_uri = URI::join(get_service_base_uri('puppetdb', 8080), '/pdb/query/v4') - result = run_command("docker-compose --no-ansi exec -T puppet facter domain") - domain = result[:stdout].chomp - body = "{ \"query\": \"nodes { certname = \\\"#{agent_name}.#{domain}\\\" } \" }" + body = "{ \"query\": \"nodes { certname = \\\"#{agent_name}\\\" } \" }" return retry_block_up_to_timeout(120) do Net::HTTP.start(pdb_uri.hostname, pdb_uri.port) do |http| diff --git a/spec/dockerfile_spec.rb b/spec/dockerfile_spec.rb index b9c91999..edfdc664 100644 --- a/spec/dockerfile_spec.rb +++ b/spec/dockerfile_spec.rb @@ -14,7 +14,9 @@ ] before(:all) do - @test_agent = "puppet_test#{Random.rand(1000)}" + # append .local to make sure Docker DNS resolver is used + # rather than appending a search domain due to resolv.conf + @test_agent = "puppet_test#{Random.rand(1000)}.local" @timestamps = [] status = run_command('docker-compose --no-ansi version')[:status] if status.exitstatus != 0