From c9ec9ab0fe71c5eb0967e5901e6f6c15eb1a5087 Mon Sep 17 00:00:00 2001
From: Fabien Combernous <fabien.combernous@adullact.org>
Date: Tue, 14 May 2019 16:06:23 +0200
Subject: [PATCH] Resolve "add ubuntu 1804 as supported OS"

---
 .gitlab-ci.yml                 | 30 +++++++++++++++++++++++++
 .sync.yml                      | 28 ++++++++++++++++++++++++
 metadata.json                  |  3 ++-
 spec/spec_helper_acceptance.rb | 40 +++++++++++++++++++++++++++-------
 4 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e18ae32..b021b47 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -48,6 +48,21 @@ acceptance with Puppet5 Ubuntu1604:
   tags:
     - puppet-tests
 
+acceptance with Puppet5 Ubuntu1804:
+  stage: 'acceptance'
+  variables:
+    RBENV_VERSION: '2.5.1'
+    PUPPET_INSTALL_TYPE: 'agent'
+    BEAKER_IS_PE: 'no'
+    BEAKER_PUPPET_COLLECTION: 'puppet5'
+    BEAKER_debug: 'true'
+    BEAKER_setfile: 'ubuntu1804-64'
+    BEAKER_HYPERVISOR: 'docker'
+  script:
+    - bundle exec rake beaker
+  tags:
+    - puppet-tests
+
 acceptance with Puppet5 Debian8:
   stage: 'acceptance'
   variables:
@@ -93,6 +108,21 @@ acceptance with Puppet6 Ubuntu1604:
   tags:
     - puppet-tests
 
+acceptance with Puppet6 Ubuntu1804:
+  stage: 'acceptance'
+  variables:
+    RBENV_VERSION: '2.5.1'
+    PUPPET_INSTALL_TYPE: 'agent'
+    BEAKER_IS_PE: 'no'
+    BEAKER_PUPPET_COLLECTION: 'puppet6'
+    BEAKER_debug: 'true'
+    BEAKER_setfile: 'ubuntu1804-64'
+    BEAKER_HYPERVISOR: 'docker'
+  script:
+    - bundle exec rake beaker
+  tags:
+    - puppet-tests
+
 acceptance with Puppet6 Debian8:
   stage: 'acceptance'
   variables:
diff --git a/.sync.yml b/.sync.yml
index e576e11..fe5747a 100644
--- a/.sync.yml
+++ b/.sync.yml
@@ -44,6 +44,20 @@ appveyor.yml:
           - bundle exec rake beaker
         tags:
           - puppet-tests
+      acceptance with Puppet5 Ubuntu1804:
+        stage: acceptance
+        variables:
+          RBENV_VERSION: '2.5.1'
+          PUPPET_INSTALL_TYPE: 'agent'
+          BEAKER_IS_PE: 'no'
+          BEAKER_PUPPET_COLLECTION: 'puppet5'
+          BEAKER_debug: 'true'
+          BEAKER_setfile: 'ubuntu1804-64'
+          BEAKER_HYPERVISOR: 'docker'
+        script:
+          - bundle exec rake beaker
+        tags:
+          - puppet-tests
       acceptance with Puppet5 Debian8:
         stage: acceptance
         variables:
@@ -86,6 +100,20 @@ appveyor.yml:
           - bundle exec rake beaker
         tags:
           - puppet-tests
+      acceptance with Puppet6 Ubuntu1804:
+        stage: acceptance
+        variables:
+          RBENV_VERSION: '2.5.1'
+          PUPPET_INSTALL_TYPE: 'agent'
+          BEAKER_IS_PE: 'no'
+          BEAKER_PUPPET_COLLECTION: 'puppet6'
+          BEAKER_debug: 'true'
+          BEAKER_setfile: 'ubuntu1804-64'
+          BEAKER_HYPERVISOR: 'docker'
+        script:
+          - bundle exec rake beaker
+        tags:
+          - puppet-tests
       acceptance with Puppet6 Debian8:
         stage: acceptance
         variables:
diff --git a/metadata.json b/metadata.json
index 81dc05f..b721de6 100644
--- a/metadata.json
+++ b/metadata.json
@@ -28,7 +28,8 @@
     {
       "operatingsystem": "Ubuntu",
       "operatingsystemrelease": [
-        "16.04"
+        "16.04",
+        "18.04"
       ]
     }
   ],
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 85d7c2b..8909f1b 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -22,21 +22,45 @@ RSpec.configure do |c|
       on host, puppet('module', 'install', 'puppetlabs-apache')
       on host, puppet('module', 'install', 'puppet-archive')
 
+      # curl is used in tests to access at a wordpress newly installed
       if host[:platform] =~ %r{debian-8-amd64}
         # workaround the apache module try to install the following apache debs and fail.
-        # curl is used in tests to access at a wordpress newly installed
-        on(host, 'apt-get update', acceptable_exit_codes: [0]).stdout
-        on(host, 'apt install php5-cli php5-mysql --yes', acceptable_exit_codes: [0]).stdout
-        on(host, 'apt install curl libapache2-mod-php5 apache2-mpm-itk --yes', acceptable_exit_codes: [0]).stdout
+        pp_specific = <<-EOF
+        package { ['curl','php5-cli','php5-mysql','libapache2-mod-php5','apache2-mpm-itk'] :
+          ensure => present,
+        }
+        EOF
+        apply_manifest_on(agents, pp_specific, catch_failures: true)
       elsif host[:platform] =~ %r{ubuntu-16.04-amd64}
-        on(host, 'apt-get update', acceptable_exit_codes: [0]).stdout
-        # curl is used in tests to access at a wordpress newly installed
-        on(host, 'apt install curl php7.0-cli php7.0-mysql --yes', acceptable_exit_codes: [0]).stdout
+        pp_specific = <<-EOF
+        package { ['curl','php7.0-cli','php7.0-mysql'] :
+          ensure => present,
+        }
+        EOF
+        apply_manifest_on(agents, pp_specific, catch_failures: true)
+      elsif host[:platform] =~ %r{ubuntu-18.04-amd64}
+        # perl-modules-5.26 required by debconf: Can't locate Term/ReadLine.pm in @INC
+        pp_specific = <<-EOF
+        package { ['curl','tzdata','perl-modules-5.26','php7.2-cli','php7.2-mysql'] :
+          ensure => present,
+        }
+        EOF
+        apply_manifest_on(agents, pp_specific, catch_failures: true)
       end
     end
 
     pp = <<-EOS
-    include '::mysql::server'
+    case $facts['os']['distro']['codename'] {
+      'jessie': {
+        $_dbpackage = 'mysql-server'
+      }
+      default: {
+        $_dbpackage = 'mariadb-server'
+      }
+    }
+    class { 'mysql::server':
+      package_name => $_dbpackage,
+    }
 
     $myfqdn = 'localhost'
     accounts::user { 'wp' :}
-- 
GitLab