Browse Source

Merge "[queens only] Add registry login support" into stable/queens

tags/8.5.1
Zuul 1 month ago
parent
commit
b123931159
1 changed files with 33 additions and 11 deletions
  1. 33
    11
      manifests/profile/base/docker.pp

+ 33
- 11
manifests/profile/base/docker.pp View File

@@ -62,6 +62,11 @@
62 62
 #   String. Value to configure the deployment user.
63 63
 #   Defaults to hiera('deployment_user', undef)
64 64
 #
65
+# [*registry_credentials*]
66
+#   Hash. A hash of registry credentials used with docker login. This should
67
+#   be in { 'registry_host' => { 'username' => 'password' } } format.
68
+#   Defaults to {}
69
+#
65 70
 # DEPRECATED PARAMETERS
66 71
 #
67 72
 # [*insecure_registry_address*]
@@ -79,17 +84,18 @@
79 84
 #   is enabled (defaults to false)
80 85
 #
81 86
 class tripleo::profile::base::docker (
82
-  $insecure_registries = undef,
83
-  $registry_mirror     = false,
84
-  $docker_options      = '--log-driver=journald --signature-verification=false --iptables=false --live-restore',
85
-  $additional_sockets  = undef,
86
-  $configure_network   = false,
87
-  $network_options     = '',
88
-  $configure_storage   = true,
89
-  $storage_options     = '-s overlay2',
90
-  $step                = Integer(hiera('step')),
91
-  $debug               = false,
92
-  $deployment_user     = hiera('deployment_user', undef),
87
+  $insecure_registries  = undef,
88
+  $registry_mirror      = false,
89
+  $docker_options       = '--log-driver=journald --signature-verification=false --iptables=false --live-restore',
90
+  $additional_sockets   = undef,
91
+  $configure_network    = false,
92
+  $network_options      = '',
93
+  $configure_storage    = true,
94
+  $storage_options      = '-s overlay2',
95
+  $step                 = Integer(hiera('step')),
96
+  $debug                = false,
97
+  $deployment_user      = hiera('deployment_user', undef),
98
+  $registry_credentials = {},
93 99
   # DEPRECATED PARAMETERS
94 100
   $insecure_registry_address = undef,
95 101
   $docker_namespace = undef,
@@ -283,6 +289,22 @@ class tripleo::profile::base::docker (
283 289
         'notify'  => Service['docker'],
284 290
       })
285 291
     }
292
+  }
286 293
 
294
+  if $step == 1 {
295
+    $registry_credentials.each |$host, $cred| {
296
+      $cred.each |$user, $pass| {
297
+        exec { "Login to ${host} as ${user}":
298
+          path        => ['/bin', '/usr/bin'],
299
+          command     => 'docker login -u $USER -p $PASS $HOST',
300
+          environment => [
301
+            "USER=${user}",
302
+            "PASS=${pass}",
303
+            "HOST=${host}",
304
+          ],
305
+          require     => Service['docker'],
306
+        }
307
+      }
308
+    }
287 309
   }
288 310
 }

Loading…
Cancel
Save