From 399f1b5a405a78b3dd1ab191fccac9bc432626b9 Mon Sep 17 00:00:00 2001
From: Fabien COMBERNOUS <fabien.combernous@adullact.org>
Date: Wed, 23 Nov 2022 10:09:43 +0100
Subject: [PATCH] add Ubuntu2204 as supported OS

---
 .gitlab-ci.yml      | 32 ++++++++++++++++++++++++++++++++
 .sync.yml           | 32 ++++++++++++++++++++++++++++++++
 manifests/goose.pp  |  2 +-
 manifests/params.pp | 16 ++++++++++++++--
 metadata.json       |  3 ++-
 5 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9b92ed4..f005b1c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -74,6 +74,38 @@ acceptance with puppet7 ubuntu2004:
   - bundle exec rake beaker
   tags:
   - puppet-tests
+acceptance with puppet6 ubuntu2204:
+  needs:
+  - parallel_spec-Ruby 2.7.5-Puppet ~> 6
+  stage: acceptance
+  variables:
+    RBENV_VERSION: 2.7.5
+    PUPPET_INSTALL_TYPE: agent
+    BEAKER_IS_PE: 'no'
+    BEAKER_PUPPET_COLLECTION: puppet6
+    BEAKER_debug: 'true'
+    BEAKER_setfile: ubuntu2204-64
+    BEAKER_HYPERVISOR: docker
+  script:
+  - bundle exec rake beaker
+  tags:
+  - puppet-tests
+acceptance with puppet7 ubuntu2204:
+  needs:
+  - parallel_spec-Ruby 2.7.5-Puppet ~> 7
+  stage: acceptance
+  variables:
+    RBENV_VERSION: 2.7.5
+    PUPPET_INSTALL_TYPE: agent
+    BEAKER_IS_PE: 'no'
+    BEAKER_PUPPET_COLLECTION: puppet7
+    BEAKER_debug: 'true'
+    BEAKER_setfile: ubuntu2204-64
+    BEAKER_HYPERVISOR: docker
+  script:
+  - bundle exec rake beaker
+  tags:
+  - puppet-tests
 module release:
   stage: release
   image: ruby:2.7.5
diff --git a/.sync.yml b/.sync.yml
index 605eb6b..54f5a9d 100644
--- a/.sync.yml
+++ b/.sync.yml
@@ -76,6 +76,38 @@ appveyor.yml:
           - bundle exec rake beaker
         tags:
           - puppet-tests
+      acceptance with puppet6 ubuntu2204:
+        needs:
+          - parallel_spec-Ruby 2.7.5-Puppet ~> 6
+        stage: acceptance
+        variables:
+          RBENV_VERSION: '2.7.5'
+          PUPPET_INSTALL_TYPE: 'agent'
+          BEAKER_IS_PE: 'no'
+          BEAKER_PUPPET_COLLECTION: 'puppet6'
+          BEAKER_debug: 'true'
+          BEAKER_setfile: 'ubuntu2204-64'
+          BEAKER_HYPERVISOR: 'docker'
+        script:
+          - bundle exec rake beaker
+        tags:
+          - puppet-tests
+      acceptance with puppet7 ubuntu2204:
+        needs:
+          - parallel_spec-Ruby 2.7.5-Puppet ~> 7
+        stage: acceptance
+        variables:
+          RBENV_VERSION: '2.7.5'
+          PUPPET_INSTALL_TYPE: 'agent'
+          BEAKER_IS_PE: 'no'
+          BEAKER_PUPPET_COLLECTION: 'puppet7'
+          BEAKER_debug: 'true'
+          BEAKER_setfile: 'ubuntu2204-64'
+          BEAKER_HYPERVISOR: 'docker'
+        script:
+          - bundle exec rake beaker
+        tags:
+          - puppet-tests
       module release:
         stage: release
         image: ruby:2.7.5
diff --git a/manifests/goose.pp b/manifests/goose.pp
index 133ec78..7746f1a 100644
--- a/manifests/goose.pp
+++ b/manifests/goose.pp
@@ -18,7 +18,7 @@ class cfssl::goose {
     target => $cfssl::params::go_targetlink,
   }
   -> exec { 'install goose':
-    command     => '/usr/local/bin/go get bitbucket.org/liamstask/goose/cmd/goose',
+    command     => '/usr/local/bin/go install bitbucket.org/liamstask/goose/cmd/goose@latest',
     creates     => "/home/${cfssl::sysuser}/go/bin/goose",
     user        => $cfssl::sysuser,
     environment => ["HOME=/home/${cfssl::sysuser}"],
diff --git a/manifests/params.pp b/manifests/params.pp
index bcfe87a..9088a36 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -10,6 +10,18 @@ class cfssl::params {
   $db_config_json = 'db-config.json'
   $systemd_unitdir = '/etc/systemd/system'
   $systemd_unit_file = "${systemd_unitdir}/cfssl.service"
-  $go_package = 'golang-1.16'
-  $go_targetlink = '/usr/lib/go-1.16/bin/go'
+
+  case $facts['os']['release']['major'] {
+    '20.04':  {
+      $go_package = 'golang-1.16-go'
+      $go_targetlink = '/usr/lib/go-1.16/bin/go'
+    }
+    '22.04':  {
+      $go_package = 'golang-1.17-go'
+      $go_targetlink = '/usr/lib/go-1.17/bin/go'
+    }
+    default:  {
+      fail("${module_name} does not support OS ${facts['os']['name']}-${facts['os']['release']['major']}")
+    }
+  }
 }
diff --git a/metadata.json b/metadata.json
index 6f3b3f4..35eeeb6 100644
--- a/metadata.json
+++ b/metadata.json
@@ -29,7 +29,8 @@
     {
       "operatingsystem": "Ubuntu",
       "operatingsystemrelease": [
-        "20.04"
+        "20.04",
+        "22.04"
       ]
     }
   ],
-- 
GitLab