From 499e31dd49ba12335577a464469ee426cda9127f Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Fri, 16 Jul 2021 14:06:34 +0200 Subject: [PATCH] Use setup_acceptance_node.pp This uses features from voxpupuli-acceptance to reduce spec_helper_acceptance's size. Another benefit is that editors recognize the .pp extension and you get syntax highlighting. --- spec/setup_acceptance_node.pp | 48 +++++++++++++++++++++++++++ spec/spec_helper_acceptance.rb | 60 ++-------------------------------- 2 files changed, 50 insertions(+), 58 deletions(-) create mode 100644 spec/setup_acceptance_node.pp diff --git a/spec/setup_acceptance_node.pp b/spec/setup_acceptance_node.pp new file mode 100644 index 0000000..5b11d9a --- /dev/null +++ b/spec/setup_acceptance_node.pp @@ -0,0 +1,48 @@ +# The omnibus installer use the following algorithm to know what to do. +# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/runit/recipes/default.rb +# If this peace of code trigger docker case, the installer hang indefinitly. +file {'/.dockerenv': + ensure => absent, +} + +package { 'curl': + ensure => present, +} + +# https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2229 +# There is no /usr/share/zoneinfo in latest Docker image for ubuntu 16.04 +# Gitlab installer fail without this file +if $facts['os']['release']['major'] in ['16.04', '18.04'] { + package { 'tzdata': + ensure => present, + } +} + +# Setup Puppet Bolt +$bolt_config = @("BOLTPROJECT"/L) +modulepath: "/etc/puppetlabs/code/modules:/etc/puppetlabs/code/environments/production/modules" +analytics: false +| BOLTPROJECT + +package { 'puppet-bolt': + ensure => installed, +} + +file { [ '/root/.puppetlabs', '/root/.puppetlabs/bolt', '/root/.puppetlabs/etc', '/root/.puppetlabs/etc/bolt']: + ensure => directory, +} + +# Needs to existing to not trigger a warning sign... +file { '/root/.puppetlabs/etc/bolt/analytics.yaml': + ensure => file, +} + +file { '/root/.puppetlabs/bolt/bolt-project.yaml': + ensure => file, + content => $bolt_config, +} + +file_line { '/etc/hosts-gitlab': + path => '/etc/hosts', + line => "${facts['gitlab_ip']} gitlab", +} diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 600fee0..e260638 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,63 +1,7 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' +ENV['BEAKER_FACTER_GITLAB_IP'] = File.read(File.expand_path('~/GITLAB_IP')).chomp + configure_beaker do |host| install_module_from_forge_on(host, 'puppetlabs/docker', '>= 0') - - # The omnibus installer use the following algorithm to know what to do. - # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/runit/recipes/default.rb - # If this peace of code trigger docker case, the installer hang indefinitly. - pp = %( - file {'/.dockerenv': - ensure => absent, - } - package { ['curl']: - ensure => present, - } - ) - - apply_manifest_on(host, pp, catch_failures: true) - - # https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2229 - # There is no /usr/share/zoneinfo in latest Docker image for ubuntu 16.04 - # Gitlab installer fail without this file - tzdata = %( - package { ['tzdata']: - ensure => present, - } - ) - - apply_manifest_on(host, tzdata, catch_failures: true) if fact('os.release.major') =~ %r{(16.04|18.04)} - - # Setup Puppet Bolt - gitlab_ip = File.read(File.expand_path('~/GITLAB_IP')).chomp - bolt = <<-MANIFEST - $bolt_config = @("BOLTPROJECT"/L) - modulepath: "/etc/puppetlabs/code/modules:/etc/puppetlabs/code/environments/production/modules" - analytics: false - | BOLTPROJECT - - package { 'puppet-bolt': - ensure => installed, - } - - file { [ '/root/.puppetlabs', '/root/.puppetlabs/bolt', '/root/.puppetlabs/etc', '/root/.puppetlabs/etc/bolt']: - ensure => directory, - } - - # Needs to existing to not trigger a warning sign... - file { '/root/.puppetlabs/etc/bolt/analytics.yaml': - ensure => file, - } - - file { '/root/.puppetlabs/bolt/bolt-project.yaml': - ensure => file, - content => $bolt_config, - } - - file_line { '/etc/hosts-gitlab': - path => '/etc/hosts', - line => '#{gitlab_ip} gitlab', - } - MANIFEST - apply_manifest_on(host, bolt, catch_failures: true) end